提交 2d1846b7 编写于 作者: K kohsuke

extended filtering to Triggers

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16418 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ffb9bdf6
......@@ -1325,6 +1325,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
*
* @see BuildStepDescriptor#isApplicable(Class)
*/
@Override
public boolean isApplicable(Descriptor descriptor) {
return true;
}
......
......@@ -28,6 +28,8 @@ import org.kohsuke.stapler.StaplerRequest;
import java.util.List;
import java.util.ArrayList;
import hudson.tasks.BuildStepDescriptor;
/**
* {@link Descriptor} for {@link TopLevelItem}s.
*
......@@ -48,6 +50,20 @@ public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> {
protected TopLevelItemDescriptor() {
}
/**
* {@link TopLevelItemDescriptor}s often uses other descriptors to decorate itself.
* This method allows the subtype of {@link TopLevelItemDescriptor}s to filter them out.
*
* <p>
* This is useful for a workflow/company specific job type that wants to eliminate
* options that the user would see.
*
* @since 1.294
*/
public boolean isApplicable(Descriptor descriptor) {
return true;
}
/**
* {@inheritDoc}
*
......
......@@ -38,6 +38,8 @@ import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.Project;
import hudson.model.PeriodicWork;
import hudson.model.TopLevelItem;
import hudson.model.TopLevelItemDescriptor;
import hudson.scheduler.CronTab;
import hudson.scheduler.CronTabList;
import hudson.util.DoubleLaunchChecker;
......@@ -270,8 +272,14 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
public static List<TriggerDescriptor> for_(Item i) {
List<TriggerDescriptor> r = new ArrayList<TriggerDescriptor>();
for (TriggerDescriptor t : all()) {
if(t.isApplicable(i))
r.add(t);
if(!t.isApplicable(i)) continue;
if (i instanceof TopLevelItem) {// ugly
TopLevelItemDescriptor tld = ((TopLevelItem) i).getDescriptor();
if(!tld.isApplicable(t)) continue;
}
r.add(t);
}
return r;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册