Search in sources :

Example 56 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 57 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 58 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 59 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 60 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)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