Search in sources :

Example 71 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 72 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 73 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 74 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 75 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)559 CoreException (org.eclipse.core.runtime.CoreException)141 IFile (org.eclipse.core.resources.IFile)140 IPath (org.eclipse.core.runtime.IPath)119 IProject (org.eclipse.core.resources.IProject)104 IContainer (org.eclipse.core.resources.IContainer)88 ArrayList (java.util.ArrayList)84 IFolder (org.eclipse.core.resources.IFolder)64 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)52 IStatus (org.eclipse.core.runtime.IStatus)47 IOException (java.io.IOException)46 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)44 Path (org.eclipse.core.runtime.Path)42 File (java.io.File)39 Status (org.eclipse.core.runtime.Status)38 IJavaProject (org.eclipse.jdt.core.IJavaProject)31 IJavaElement (org.eclipse.jdt.core.IJavaElement)30 ISelection (org.eclipse.jface.viewers.ISelection)26 List (java.util.List)25 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)22