use of org.eclipse.core.runtime.jobs.MultiRule in project polymap4-core by Polymap4.
the class Resource method contains.
/*
* (non-Javadoc)
* @see ISchedulingRule#contains(ISchedulingRule)
*/
public boolean contains(ISchedulingRule rule) {
if (this == rule)
return true;
// must allow notifications to nest in all resource rules
if (rule.getClass().equals(WorkManager.NotifyRule.class))
return true;
if (rule instanceof MultiRule) {
MultiRule multi = (MultiRule) rule;
ISchedulingRule[] children = multi.getChildren();
for (int i = 0; i < children.length; i++) if (!contains(children[i]))
return false;
return true;
}
if (!(rule instanceof IResource))
return false;
return path.isPrefixOf(((IResource) rule).getFullPath());
}
use of org.eclipse.core.runtime.jobs.MultiRule in project eclipse.platform.runtime by eclipse.
the class MultiRuleTest method testCombine.
public void testCombine() {
ISchedulingRule child1 = new PathRule("/a");
ISchedulingRule child2 = new PathRule("/b/c");
ISchedulingRule childOfChild1 = new PathRule("/a/b");
ISchedulingRule nonChild = new PathRule("/z/d");
MultiRule multi1 = new MultiRule(new ISchedulingRule[] { child1, child2 });
// add multi to its own children
assertEquals("1.0", multi1, MultiRule.combine(new ISchedulingRule[] { multi1 }));
assertEquals("1.1", multi1, MultiRule.combine(new ISchedulingRule[] { multi1, child1, child2, childOfChild1 }));
assertEquals("1.2", multi1, MultiRule.combine(multi1, child2));
assertEquals("1.3", multi1, MultiRule.combine(childOfChild1, multi1));
// null
assertEquals("1.4", null, MultiRule.combine(null, null));
assertEquals("1.5", multi1, MultiRule.combine(null, multi1));
assertEquals("1.6", child1, MultiRule.combine(child1, null));
MultiRule result = (MultiRule) MultiRule.combine(multi1, nonChild);
assertTrue("2.0" + result, result.contains(multi1));
assertTrue("2.1", result.contains(nonChild));
}
use of org.eclipse.core.runtime.jobs.MultiRule in project eclipse.platform.runtime by eclipse.
the class MultiRuleTest method testIsConflicting.
public void testIsConflicting() {
ISchedulingRule child1 = new PathRule("/a");
ISchedulingRule child2 = new PathRule("/b/c");
ISchedulingRule childOfChild1 = new PathRule("/a/b");
ISchedulingRule nonChild = new PathRule("/z/d");
MultiRule multi1 = new MultiRule(new ISchedulingRule[] { child1, child2 });
MultiRule multi2 = new MultiRule(new ISchedulingRule[] { childOfChild1, nonChild });
assertTrue("1.0", multi1.isConflicting(child1));
assertTrue("1.1", multi1.isConflicting(child2));
assertTrue("1.2", !multi1.isConflicting(nonChild));
assertTrue("1.3", multi1.isConflicting(childOfChild1));
assertTrue("1.4", multi1.isConflicting(multi2));
assertTrue("1.5", multi2.isConflicting(multi1));
assertTrue("1.6", multi1.isConflicting(multi1));
}
use of org.eclipse.core.runtime.jobs.MultiRule in project egit by eclipse.
the class RuleUtil method getRuleForContainers.
/**
* Calculates a {@link ISchedulingRule} for all containers of the paths that
* are in the workspace.
*
* @param paths
* @return scheduling rule
*/
public static ISchedulingRule getRuleForContainers(Collection<IPath> paths) {
List<ISchedulingRule> rules = new ArrayList<ISchedulingRule>();
IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
for (IPath path : paths) {
IResource resource = ResourceUtil.getResourceForLocation(path, false);
if (resource != null) {
IContainer container = resource.getParent();
ISchedulingRule rule = ruleFactory.modifyRule(container);
if (rule != null)
rules.add(rule);
}
}
if (rules.size() == 0)
return null;
else
return new MultiRule(rules.toArray(new ISchedulingRule[rules.size()]));
}
Aggregations