提交 6db7d497 编写于 作者: K kohsuke

deprecated LIST in favor of all() like all others

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15728 71c3de6d-444a-0410-be80-ed276b4c234a
上级 fb1ae088
......@@ -107,6 +107,18 @@ public class DescriptorExtensionList<T extends Describable<T>, D extends Descrip
return newInstanceFromRadioList(parent.getJSONObject(name));
}
/**
* Finds a descriptor by their {@link Descriptor#clazz}.
*
* If none is found, null is returned.
*/
public Descriptor<T> findByName(String fullyQualifiedClassName) {
for (Descriptor<T> d : this)
if(d.clazz.getName().equals(fullyQualifiedClassName))
return d;
return null;
}
/**
* Loading the descriptors in this case means filtering the descriptor from the master {@link ExtensionList}.
*/
......
......@@ -35,6 +35,7 @@ import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.DataBoundConstructor;
import hudson.model.Descriptor.FormException;
import hudson.Extension;
/**
* {@link View} that only contains projects for which the current user has access to.
......@@ -85,16 +86,7 @@ public class MyView extends View {
// noop
}
public ViewDescriptor getDescriptor() {
return DESCRIPTOR;
}
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
static {
LIST.add(DESCRIPTOR);
}
@Extension
public static final class DescriptorImpl extends ViewDescriptor {
private DescriptorImpl() {
super(MyView.class);
......
......@@ -26,6 +26,7 @@ package hudson.model;
import hudson.model.Descriptor.FormException;
import hudson.util.CaseInsensitiveComparator;
import hudson.Indenter;
import hudson.Extension;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -159,21 +160,16 @@ public class TreeView extends View implements ViewGroup {
}
}
public ViewDescriptor getDescriptor() {
return DESCRIPTOR;
}
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
static {
LIST.add(DESCRIPTOR);
// this feature is not public yet
@Extension
public static ViewDescriptor register() {
if(Boolean.getBoolean("hudson.TreeView"))
return new DescriptorImpl();
else
return null;
}
public static final class DescriptorImpl extends ViewDescriptor {
private DescriptorImpl() {
super(TreeView.class);
}
public String getDisplayName() {
return "Tree View";
}
......
......@@ -25,6 +25,8 @@ package hudson.model;
import hudson.ExtensionPoint;
import hudson.Util;
import hudson.Extension;
import hudson.DescriptorExtensionList;
import hudson.model.Descriptor.FormException;
import static hudson.model.Hudson.checkGoodName;
import hudson.scm.ChangeLogSet.Entry;
......@@ -524,13 +526,16 @@ public abstract class View extends AbstractModelObject implements AccessControll
/**
* A list of available view types.
* @deprecated as of 1.286
* Use {@link #all()} for read access, and use {@link Extension} for registration.
*/
public static final DescriptorList<View> LIST = new DescriptorList<View>(View.class);
static {
LIST.load(MyView.class);
if(Boolean.getBoolean("hudson.TreeView"))
LIST.load(TreeView.class);
/**
* Returns all the registered {@link ViewDescriptor}s.
*/
public static DescriptorExtensionList<View,ViewDescriptor> all() {
return Hudson.getInstance().getDescriptorList(View.class);
}
public static final Comparator<View> SORTER = new Comparator<View>() {
......@@ -561,7 +566,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
throw new FormException(Messages.Hudson_ViewAlreadyExists(name),"name");
// create a view
View v = LIST.findByName(req.getParameter("mode")).newInstance(req,req.getSubmittedForm());
View v = all().findByName(req.getParameter("mode")).newInstance(req,req.getSubmittedForm());
v.owner = owner;
// redirect to the config screen
......
......@@ -28,7 +28,6 @@ package hudson.model;
*
* @author Kohsuke Kawaguchi
* @since 1.269
* @see View#LIST
*/
public abstract class ViewDescriptor extends Descriptor<View> {
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册