use of org.eclipse.core.resources.IResource in project che by eclipse.
the class ModelProvider method getMappings.
/**
* Return the set of mappings that cover the given resources.
* This method is used to map operations on resources to
* operations on resource mappings. By default, this method
* calls <code>getMapping(IResource)</code> for each resource.
* <p>
* Subclasses may override this method.
* </p>
*
* @param resources the resources
* @param context a resource mapping context
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
* @return the set of mappings that cover the given resources
* @exception CoreException
*/
public ResourceMapping[] getMappings(IResource[] resources, org.eclipse.core.resources.mapping.ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
Set<ResourceMapping> mappings = new HashSet<ResourceMapping>();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
ResourceMapping[] resourceMappings = getMappings(resource, context, monitor);
if (resourceMappings.length > 0)
mappings.addAll(Arrays.asList(resourceMappings));
}
return mappings.toArray(new ResourceMapping[mappings.size()]);
}
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 ChangeDescription method createSourceResource.
private IResource createSourceResource(IResourceDelta delta) {
IPath sourcePath = delta.getMovedFromPath();
IResource resource = delta.getResource();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
switch(resource.getType()) {
case IResource.PROJECT:
return wsRoot.getProject(sourcePath.segment(0));
case IResource.FOLDER:
return wsRoot.getFolder(sourcePath);
case IResource.FILE:
return wsRoot.getFile(sourcePath);
}
return null;
}
use of org.eclipse.core.resources.IResource in project che by eclipse.
the class ChangeDescription method handleCopy.
private void handleCopy(IResourceDelta delta) {
if ((delta.getFlags() & IResourceDelta.COPIED_FROM) != 0) {
IResource source = createSourceResource(delta);
ensureResourceCovered(source, copiedRoots);
}
}
use of org.eclipse.core.resources.IResource in project che by eclipse.
the class UndoDeleteResourceChange method perform.
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
IResource created = fResourceDescription.createResource(pm);
created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1));
return new DeleteResourceChange(created.getFullPath(), true);
}
Aggregations