use of org.eclipse.core.runtime.jobs.MultiRule in project che by eclipse.
the class Resource method isConflicting.
@Override
public boolean isConflicting(ISchedulingRule rule) {
if (this == rule)
return true;
//must not schedule at same time as notification
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 (isConflicting(children[i]))
return true;
return false;
}
if (!(rule instanceof IResource))
return false;
IResource resource = (IResource) rule;
if (!workspace.equals(resource.getWorkspace()))
return false;
IPath otherPath = resource.getFullPath();
return path.isPrefixOf(otherPath) || otherPath.isPrefixOf(path);
}
use of org.eclipse.core.runtime.jobs.MultiRule in project che by eclipse.
the class Resource method contains.
@Override
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;
IResource resource = (IResource) rule;
if (!workspace.equals(resource.getWorkspace()))
return false;
return path.isPrefixOf(resource.getFullPath());
}
use of org.eclipse.core.runtime.jobs.MultiRule in project che by eclipse.
the class Rules method validateEditRule.
/**
* Combines rules for each parameter to validateEdit from the corresponding
* rule factories.
*/
public ISchedulingRule validateEditRule(IResource[] resources) {
if (resources.length == 0)
return null;
//optimize rule for single file
if (resources.length == 1) {
if (resources[0].getType() == IResource.ROOT)
return root;
return factoryFor(resources[0]).validateEditRule(resources);
}
//gather rules for each resource from appropriate factory
HashSet<ISchedulingRule> rules = new HashSet<ISchedulingRule>();
IResource[] oneResource = new IResource[1];
for (int i = 0; i < resources.length; i++) {
if (resources[i].getType() == IResource.ROOT)
return root;
oneResource[0] = resources[i];
ISchedulingRule rule = factoryFor(resources[i]).validateEditRule(oneResource);
if (rule != null)
rules.add(rule);
}
if (rules.isEmpty())
return null;
if (rules.size() == 1)
return rules.iterator().next();
ISchedulingRule[] ruleArray = rules.toArray(new ISchedulingRule[rules.size()]);
return new MultiRule(ruleArray);
}
use of org.eclipse.core.runtime.jobs.MultiRule in project che by eclipse.
the class Rules method validateEditRule.
/**
* Combines rules for each parameter to validateEdit from the corresponding
* rule factories.
*/
public ISchedulingRule validateEditRule(IResource[] resources) {
if (resources.length == 0)
return null;
//optimize rule for single file
if (resources.length == 1) {
if (resources[0].getType() == IResource.ROOT)
return root;
return factoryFor(resources[0]).validateEditRule(resources);
}
//gather rules for each resource from appropriate factory
HashSet<ISchedulingRule> rules = new HashSet<ISchedulingRule>();
IResource[] oneResource = new IResource[1];
for (int i = 0; i < resources.length; i++) {
if (resources[i].getType() == IResource.ROOT)
return root;
oneResource[0] = resources[i];
ISchedulingRule rule = factoryFor(resources[i]).validateEditRule(oneResource);
if (rule != null)
rules.add(rule);
}
if (rules.isEmpty())
return null;
if (rules.size() == 1)
return rules.iterator().next();
ISchedulingRule[] ruleArray = rules.toArray(new ISchedulingRule[rules.size()]);
return new MultiRule(ruleArray);
}
use of org.eclipse.core.runtime.jobs.MultiRule in project eclipse.platform.text by eclipse.
the class GenericFileBufferOperationRunner method computeCommitRule.
protected ISchedulingRule computeCommitRule(IFileBuffer[] fileBuffers) {
ArrayList<ISchedulingRule> list = new ArrayList<>();
for (IFileBuffer fileBuffer : fileBuffers) {
ISchedulingRule rule = fileBuffer.computeCommitRule();
if (rule != null)
list.add(rule);
}
ISchedulingRule[] rules = new ISchedulingRule[list.size()];
list.toArray(rules);
return new MultiRule(rules);
}
Aggregations