Search in sources :

Example 21 with IResource

use of org.eclipse.core.resources.IResource in project che by eclipse.

the class ReorgUtils method isParentInWorkspaceOrOnDisk.

public static boolean isParentInWorkspaceOrOnDisk(IPackageFragmentRoot root, IJavaProject javaProject) {
    if (root == null)
        return false;
    IJavaElement rootParent = root.getParent();
    if (rootParent == null)
        return false;
    if (rootParent.equals(root))
        return true;
    IResource packageResource = ResourceUtil.getResource(root);
    IResource packageRootResource = ResourceUtil.getResource(javaProject);
    return isParentInWorkspaceOrOnDisk(packageResource, packageRootResource);
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IResource(org.eclipse.core.resources.IResource)

Example 22 with IResource

use of org.eclipse.core.resources.IResource in project che by eclipse.

the class ReorgUtils method containsElementOrParent.

public static boolean containsElementOrParent(Set<IAdaptable> elements, IResource element) {
    IResource curr = element;
    do {
        if (elements.contains(curr))
            return true;
        IJavaElement jElement = JavaCore.create(curr);
        if (jElement != null && jElement.exists()) {
            return containsElementOrParent(elements, jElement);
        }
        curr = curr.getParent();
    } while (curr != null);
    return false;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IResource(org.eclipse.core.resources.IResource)

Example 23 with IResource

use of org.eclipse.core.resources.IResource in project che by eclipse.

the class OverwriteHelper method willOverwrite.

/*
	 * Will resource override a member of destination?
	 */
private boolean willOverwrite(IResource resource) {
    if (resource == null)
        return false;
    IResource destinationResource = ResourceUtil.getResource(fDestination);
    if (destinationResource.equals(resource.getParent()))
        return false;
    if (destinationResource instanceof IContainer) {
        IContainer container = (IContainer) destinationResource;
        IResource member = container.findMember(resource.getName());
        if (member == null || !member.exists())
            return false;
        return true;
    }
    return false;
}
Also used : IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 24 with IResource

use of org.eclipse.core.resources.IResource in project che by eclipse.

the class ParentChecker method resourcesHaveCommonParent.

private boolean resourcesHaveCommonParent() {
    if (fResources.length == 0)
        return true;
    IResource firstParent = fResources[0].getParent();
    Assert.isNotNull(firstParent);
    for (int i = 1; i < fResources.length; i++) {
        if (!firstParent.equals(fResources[i].getParent()))
            return false;
    }
    return true;
}
Also used : IResource(org.eclipse.core.resources.IResource)

Example 25 with IResource

use of org.eclipse.core.resources.IResource in project che by eclipse.

the class ParentChecker method removeResourcesDescendantsOfJavaElements.

private void removeResourcesDescendantsOfJavaElements() {
    List<IResource> subResources = new ArrayList<IResource>(3);
    for (int i = 0; i < fResources.length; i++) {
        IResource subResource = fResources[i];
        for (int j = 0; j < fJavaElements.length; j++) {
            IJavaElement superElements = fJavaElements[j];
            if (isDescendantOf(subResource, superElements))
                subResources.add(subResource);
        }
    }
    removeFromSetToDelete(subResources.toArray(new IResource[subResources.size()]));
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) ArrayList(java.util.ArrayList) IResource(org.eclipse.core.resources.IResource)

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