提交 ffb9bdf6 编写于 作者: K kohsuke

generalized it so that we can have other Descriptors call this.

Since implementing this method involves in some kind of downcasting anyway, there's not much point in defining subtype-specific isApplicable methods

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16417 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0105dce2
......@@ -1308,19 +1308,24 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*/
public static abstract class AbstractProjectDescriptor extends TopLevelItemDescriptor {
/**
* {@link AbstractProject} subtypes can override this method to veto some {@link BuildStepDescriptor}s
* {@link AbstractProject} subtypes can override this method to veto some {@link Descriptor}s
* from showing up on their configuration screen. This is often useful when you are building
* a workflow specific project type, where generic builders and publishers don't make sense.
* a workflow/company specific project type, where you want to limit the number of choices
* given to the users.
*
* <p>
* This method works like AND in conjunction with {@link BuildStepDescriptor#isApplicable(Class)}.
* Both this method and that method need to return true in order for a given {@link BuildStepDescriptor}
* Some {@link Descriptor}s define their own schemes for controlling applicability
* (such as {@link BuildStepDescriptor#isApplicable(Class)}),
* This method works like AND in conjunction with them;
* Both this method and that method need to return true in order for a given {@link Descriptor}
* to show up for the given {@link Project}.
*
* <p>
* The default implementation returns true for everything.
*
* @see BuildStepDescriptor#isApplicable(Class)
*/
public boolean isApplicable(BuildStepDescriptor descriptor) {
public boolean isApplicable(Descriptor descriptor) {
return true;
}
}
......
......@@ -61,6 +61,7 @@ public abstract class BuildStepDescriptor<T extends BuildStep & Describable<T>>
*
* @return
* true to allow user to configure this post-promotion task for the given project.
* @see AbstractProjectDescriptor#isApplicable(Descriptor)
*/
public abstract boolean isApplicable(Class<? extends AbstractProject> jobType);
......@@ -75,10 +76,12 @@ public abstract class BuildStepDescriptor<T extends BuildStep & Describable<T>>
List<Descriptor<T>> r = new ArrayList<Descriptor<T>>(base.size());
for (Descriptor<T> d : base) {
if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(d))
continue;
if (d instanceof BuildStepDescriptor) {
BuildStepDescriptor<T> bd = (BuildStepDescriptor<T>) d;
if(!bd.isApplicable(type)) continue;
if(pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(bd)) continue;
r.add(bd);
} else {
// old plugins built before 1.150 may not implement BuildStepDescriptor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册