mirror of https://github.com/jenkinsci/jenkins.git
Move to extensionpoint
This commit is contained in:
parent
7827304ae1
commit
b746fba008
|
@ -48,7 +48,7 @@ import hudson.node_monitors.DiskSpaceMonitorNodeProperty;
|
|||
import hudson.node_monitors.NodeMonitor;
|
||||
import hudson.remoting.Channel;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.search.SearchGroup;
|
||||
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.security.Permission;
|
||||
|
@ -111,6 +111,7 @@ import jenkins.model.DisplayExecutor;
|
|||
import jenkins.model.IComputer;
|
||||
import jenkins.model.IDisplayExecutor;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.search.SearchGroup;
|
||||
import jenkins.security.ImpersonatingExecutorService;
|
||||
import jenkins.security.MasterToSlaveCallable;
|
||||
import jenkins.security.stapler.StaplerDispatchable;
|
||||
|
@ -1111,8 +1112,8 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSearchGroup() {
|
||||
return SearchGroup.COMPUTER;
|
||||
public SearchGroup getSearchGroup() {
|
||||
return SearchGroup.get(SearchGroup.ComputerSearchGroup.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ import hudson.model.listeners.ItemListener;
|
|||
import hudson.scm.ChangeLogSet;
|
||||
import hudson.scm.SCM;
|
||||
import hudson.search.QuickSilver;
|
||||
import hudson.search.SearchGroup;
|
||||
|
||||
import hudson.search.SearchIndex;
|
||||
import hudson.search.SearchIndexBuilder;
|
||||
import hudson.search.SearchItem;
|
||||
|
@ -101,6 +101,7 @@ import jenkins.model.ProjectNamingStrategy;
|
|||
import jenkins.model.RunIdMigrator;
|
||||
import jenkins.model.lazy.LazyBuildMixIn;
|
||||
import jenkins.scm.RunWithSCM;
|
||||
import jenkins.search.SearchGroup;
|
||||
import jenkins.security.HexStringConfidentialKey;
|
||||
import jenkins.security.stapler.StaplerNotDispatchable;
|
||||
import jenkins.triggers.SCMTriggerItem;
|
||||
|
@ -528,8 +529,8 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSearchGroup() {
|
||||
return SearchGroup.PROJECT;
|
||||
public SearchGroup getSearchGroup() {
|
||||
return SearchGroup.get(SearchGroup.JobSearchGroup.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,7 +40,7 @@ import hudson.XmlFile;
|
|||
import hudson.init.InitMilestone;
|
||||
import hudson.init.Initializer;
|
||||
import hudson.model.listeners.SaveableListener;
|
||||
import hudson.search.SearchGroup;
|
||||
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.security.SecurityRealm;
|
||||
|
@ -73,6 +73,7 @@ import jenkins.model.Jenkins;
|
|||
import jenkins.model.Loadable;
|
||||
import jenkins.model.ModelObjectWithContextMenu;
|
||||
import jenkins.scm.RunWithSCM;
|
||||
import jenkins.search.SearchGroup;
|
||||
import jenkins.security.ImpersonatingUserDetailsService2;
|
||||
import jenkins.security.LastGrantedAuthoritiesProperty;
|
||||
import jenkins.security.UserDetailsCache;
|
||||
|
@ -286,8 +287,8 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSearchGroup() {
|
||||
return SearchGroup.PEOPLE;
|
||||
public SearchGroup getSearchGroup() {
|
||||
return SearchGroup.get(SearchGroup.UserSearchGroup.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ import hudson.init.Initializer;
|
|||
import hudson.model.Descriptor.FormException;
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import hudson.search.CollectionSearchIndex;
|
||||
import hudson.search.SearchGroup;
|
||||
|
||||
import hudson.search.SearchIndexBuilder;
|
||||
import hudson.security.ACL;
|
||||
import hudson.security.AccessControlled;
|
||||
|
@ -95,6 +95,7 @@ import jenkins.model.ModelObjectWithContextMenu;
|
|||
import jenkins.model.item_category.Categories;
|
||||
import jenkins.model.item_category.Category;
|
||||
import jenkins.model.item_category.ItemCategory;
|
||||
import jenkins.search.SearchGroup;
|
||||
import jenkins.security.stapler.StaplerNotDispatchable;
|
||||
import jenkins.util.xml.XMLUtils;
|
||||
import jenkins.widgets.HasWidgets;
|
||||
|
@ -567,8 +568,8 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSearchGroup() {
|
||||
return SearchGroup.VIEW;
|
||||
public SearchGroup getSearchGroup() {
|
||||
return SearchGroup.get(SearchGroup.ViewSearchGroup.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package hudson.search;
|
||||
|
||||
public final class SearchGroup {
|
||||
|
||||
public static final String VIEW = Messages.SearchGroup_views();
|
||||
|
||||
public static final String BUILD = Messages.SearchGroup_builds();
|
||||
|
||||
public static final String COMPUTER = Messages.SearchGroup_nodes();
|
||||
|
||||
public static final String PROJECT = Messages.SearchGroup_projects();
|
||||
|
||||
public static final String PEOPLE = Messages.SearchGroup_people();
|
||||
|
||||
public static final String OTHER = Messages.SearchGroup_other();
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
package hudson.search;
|
||||
|
||||
import hudson.model.Build;
|
||||
import jenkins.search.SearchGroup;
|
||||
import org.jenkins.ui.icon.IconSpec;
|
||||
|
||||
/**
|
||||
|
@ -63,8 +64,8 @@ public interface SearchItem {
|
|||
return "symbol-search";
|
||||
}
|
||||
|
||||
default String getSearchGroup() {
|
||||
return SearchGroup.OTHER;
|
||||
default SearchGroup getSearchGroup() {
|
||||
return SearchGroup.get(SearchGroup.UnclassifiedSearchGroup.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package jenkins.search;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionList;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.model.ModelObject;
|
||||
|
||||
public interface SearchGroup extends ExtensionPoint, ModelObject {
|
||||
|
||||
static ExtensionList<SearchGroup> all() {
|
||||
return ExtensionList.lookup(SearchGroup.class);
|
||||
}
|
||||
|
||||
static @NonNull <T extends SearchGroup> T get(Class<T> type) {
|
||||
T category = all().get(type);
|
||||
if (category == null) {
|
||||
throw new AssertionError("Group not found. It seems the " + type + " is not annotated with @Extension and so not registered");
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
@Extension
|
||||
class UnclassifiedSearchGroup implements SearchGroup {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Other";
|
||||
}
|
||||
}
|
||||
|
||||
@Extension
|
||||
class JobSearchGroup implements SearchGroup {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Projects";
|
||||
}
|
||||
}
|
||||
|
||||
@Extension
|
||||
class ComputerSearchGroup implements SearchGroup {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Computers";
|
||||
}
|
||||
}
|
||||
|
||||
@Extension
|
||||
class ViewSearchGroup implements SearchGroup {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Views";
|
||||
}
|
||||
}
|
||||
|
||||
@Extension
|
||||
class UserSearchGroup implements SearchGroup {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Users";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,9 +21,3 @@
|
|||
# THE SOFTWARE.
|
||||
|
||||
UserSearchProperty.DisplayName=Setting for search
|
||||
SearchGroup.views=Views
|
||||
SearchGroup.builds=Builds
|
||||
SearchGroup.nodes=Nodes
|
||||
SearchGroup.other=Other
|
||||
SearchGroup.people=People
|
||||
SearchGroup.projects=Projects
|
||||
|
|
Loading…
Reference in New Issue