use of org.eclipse.core.runtime.jobs.ISchedulingRule in project polymap4-core by Polymap4.
the class Resource method deleteMarkers.
/* (non-Javadoc)
* @see IResource#deleteMarkers(String, boolean, int)
*/
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
final ISchedulingRule rule = workspace.getRuleFactory().markerRule(this);
try {
workspace.prepareOperation(rule, null);
ResourceInfo info = getResourceInfo(false, false);
checkAccessible(getFlags(info));
workspace.beginOperation(true);
workspace.getMarkerManager().removeMarkers(this, type, includeSubtypes, depth);
} finally {
workspace.endOperation(rule, false, null);
}
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project polymap4-core by Polymap4.
the class Workspace method build.
/* (non-Javadoc)
* @see IWorkspace#build(int, IProgressMonitor)
*/
public void build(int trigger, IProgressMonitor monitor) throws CoreException {
monitor = Policy.monitorFor(monitor);
final ISchedulingRule rule = getRuleFactory().buildRule();
try {
// $NON-NLS-1$
monitor.beginTask("", Policy.opWork);
try {
prepareOperation(rule, monitor);
beginOperation(true);
aboutToBuild(this, trigger);
IStatus result;
try {
result = getBuildManager().build(trigger, Policy.subMonitorFor(monitor, Policy.opWork));
} finally {
// must fire POST_BUILD if PRE_BUILD has occurred
broadcastBuildEvent(this, IResourceChangeEvent.POST_BUILD, trigger);
}
if (!result.isOK())
throw new ResourceException(result);
} finally {
// building may close the tree, but we are still inside an operation so open it
if (tree.isImmutable())
newWorkingTree();
endOperation(rule, false, Policy.subMonitorFor(monitor, Policy.endOpWork));
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project polymap4-core by Polymap4.
the class Workspace method checkpoint.
/* (non-Javadoc)
* @see IWorkspace#checkpoint(boolean)
*/
public void checkpoint(boolean build) {
try {
final ISchedulingRule rule = getWorkManager().getNotifyRule();
try {
prepareOperation(rule, null);
beginOperation(true);
broadcastPostChange();
} finally {
endOperation(rule, build, null);
}
} catch (CoreException e) {
Policy.log(e.getStatus());
}
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project polymap4-core by Polymap4.
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 rules = new HashSet();
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 (ISchedulingRule) rules.iterator().next();
ISchedulingRule[] ruleArray = (ISchedulingRule[]) rules.toArray(new ISchedulingRule[rules.size()]);
return new MultiRule(ruleArray);
}
use of org.eclipse.core.runtime.jobs.ISchedulingRule in project polymap4-core by Polymap4.
the class SavedState method processResourceChangeEvents.
public void processResourceChangeEvents(IResourceChangeListener listener) {
try {
final ISchedulingRule rule = workspace.getRoot();
try {
workspace.prepareOperation(rule, null);
if (oldTree == null || newTree == null)
return;
workspace.beginOperation(true);
ResourceDelta delta = ResourceDeltaFactory.computeDelta(workspace, oldTree, newTree, Path.ROOT, -1);
// free trees to prevent memory leak
forgetTrees();
workspace.getNotificationManager().broadcastChanges(listener, IResourceChangeEvent.POST_BUILD, delta);
} finally {
workspace.endOperation(rule, false, null);
}
} catch (CoreException e) {
// this is unlikely to happen, so, just log it
Policy.log(e);
}
}
Aggregations