Search in sources :

Example 36 with IResource

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()]);
}
Also used : IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Example 37 with IResource

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);
}
Also used : MultiRule(org.eclipse.core.runtime.jobs.MultiRule) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 38 with IResource

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IResource(org.eclipse.core.resources.IResource)

Example 39 with IResource

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);
    }
}
Also used : IResource(org.eclipse.core.resources.IResource)

Example 40 with IResource

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);
}
Also used : DeleteResourceChange(org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange) IResource(org.eclipse.core.resources.IResource) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Aggregations

IResource (org.eclipse.core.resources.IResource)1487 IFile (org.eclipse.core.resources.IFile)390 CoreException (org.eclipse.core.runtime.CoreException)390 IPath (org.eclipse.core.runtime.IPath)315 IProject (org.eclipse.core.resources.IProject)286 ArrayList (java.util.ArrayList)237 IFolder (org.eclipse.core.resources.IFolder)187 IContainer (org.eclipse.core.resources.IContainer)175 Path (org.eclipse.core.runtime.Path)141 File (java.io.File)124 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)109 IOException (java.io.IOException)103 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)95 IStatus (org.eclipse.core.runtime.IStatus)89 List (java.util.List)83 IJavaProject (org.eclipse.jdt.core.IJavaProject)75 HashSet (java.util.HashSet)71 Status (org.eclipse.core.runtime.Status)66 HashMap (java.util.HashMap)60 IAdaptable (org.eclipse.core.runtime.IAdaptable)59