use of org.eclipse.core.resources.IResource 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.resources.IResource 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.resources.IResource 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.resources.IResource in project che by eclipse.
the class Workspace method delete.
@Override
public IStatus delete(IResource[] resources, int updateFlags, IProgressMonitor monitor) throws CoreException {
monitor = Policy.monitorFor(monitor);
try {
int opWork = Math.max(resources.length, 1);
int totalWork = Policy.totalWork * opWork / Policy.opWork;
String message = Messages.resources_deleting_0;
monitor.beginTask(message, totalWork);
message = Messages.resources_deleteProblem;
MultiStatus result = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, message, null);
if (resources.length == 0)
return result;
// to avoid concurrent changes to this array
resources = resources.clone();
try {
prepareOperation(getRoot(), monitor);
beginOperation(true);
for (int i = 0; i < resources.length; i++) {
Policy.checkCanceled(monitor);
Resource resource = (Resource) resources[i];
if (resource == null) {
monitor.worked(1);
continue;
}
try {
resource.delete(updateFlags, Policy.subMonitorFor(monitor, 1));
} catch (CoreException e) {
// Don't really care about the exception unless the resource is still around.
ResourceInfo info = resource.getResourceInfo(false, false);
if (resource.exists(resource.getFlags(info), false)) {
message = NLS.bind(Messages.resources_couldnotDelete, resource.getFullPath());
result.merge(new org.eclipse.core.internal.resources.ResourceStatus(IResourceStatus.FAILED_DELETE_LOCAL, resource.getFullPath(), message));
result.merge(e.getStatus());
}
}
}
if (result.matches(IStatus.ERROR))
throw new ResourceException(result);
return result;
} catch (OperationCanceledException e) {
getWorkManager().operationCanceled();
throw e;
} finally {
endOperation(getRoot(), true, Policy.subMonitorFor(monitor, totalWork - opWork));
}
} finally {
monitor.done();
}
}
use of org.eclipse.core.resources.IResource in project che by eclipse.
the class ResourceChangeDescriptionFactory method getDelta.
private ProposedResourceDelta getDelta(IResource resource) {
ProposedResourceDelta delta = (ProposedResourceDelta) root.findMember(resource.getFullPath());
if (delta != null) {
return delta;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource iResource = resource.getParent();
if (iResource == null) {
iResource = ((Workspace) workspace).newResource(resource.getFullPath().removeLastSegments(1), IResource.FOLDER);
}
ProposedResourceDelta parent = getDelta(iResource);
delta = new ProposedResourceDelta(resource);
parent.add(delta);
return delta;
}
Aggregations