Search in sources :

Example 31 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class ResourceModifications method buildMoveDelta.

public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, MoveArguments args) {
    IPath destination = ((IResource) args.getDestination()).getFullPath().append(resource.getName());
    new MoveDescription(resource, destination).buildDelta(builder);
}
Also used : IPath(org.eclipse.core.runtime.IPath)

Example 32 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class ImportOperation method collectExistingReadonlyFiles.

/**
     * Prompts if existing resources should be overwritten. Recursively collects
     * existing read-only files to overwrite and resources that should not be
     * overwritten.
     *
     * @param sourceStart destination path to check for existing files
     * @param sources file system objects that may exist in the destination
     * @param noOverwrite files that were selected to be skipped (don't overwrite).
     * 	object type IPath
     * @param overwriteReadonly the collected existing read-only files to overwrite.
     * 	object type IPath
     * @param policy on of the POLICY constants defined in the
     * class.
     */
void collectExistingReadonlyFiles(IPath sourceStart, List sources, ArrayList noOverwrite, ArrayList overwriteReadonly, int policy) {
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    Iterator sourceIter = sources.iterator();
    IPath sourceRootPath = null;
    if (this.source != null) {
        sourceRootPath = new Path(provider.getFullPath(this.source));
    }
    while (sourceIter.hasNext()) {
        Object nextSource = sourceIter.next();
        IPath sourcePath = new Path(provider.getFullPath(nextSource));
        IPath newDestinationPath;
        IResource newDestination;
        if (sourceRootPath == null) {
            newDestinationPath = sourceStart.append(provider.getLabel(nextSource));
        } else {
            int prefixLength = sourcePath.matchingFirstSegments(sourceRootPath);
            IPath relativeSourcePath = sourcePath.removeFirstSegments(prefixLength);
            newDestinationPath = this.destinationPath.append(relativeSourcePath);
        }
        newDestination = workspaceRoot.findMember(newDestinationPath);
        if (newDestination == null) {
            continue;
        }
        IFolder folder = getFolder(newDestination);
        if (folder != null) {
            if (policy != POLICY_FORCE_OVERWRITE) {
                if (this.overwriteState == OVERWRITE_NONE || !queryOverwrite(newDestinationPath)) {
                    noOverwrite.add(folder);
                    continue;
                }
            }
            if (provider.isFolder(nextSource)) {
                collectExistingReadonlyFiles(newDestinationPath, provider.getChildren(nextSource), noOverwrite, overwriteReadonly, POLICY_FORCE_OVERWRITE);
            }
        } else {
            IFile file = getFile(newDestination);
            if (file != null) {
                if (!queryOverwriteFile(file, policy)) {
                    noOverwrite.add(file.getFullPath());
                } else if (file.isReadOnly()) {
                    overwriteReadonly.add(file);
                }
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath) Iterator(java.util.Iterator) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 33 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class ImportOperation method createFromRoot.

/**
     * Creates the folders that appear in the specified resource path
     * assuming that the destinationContainer begins at the root. Do not create projects.
     *
     * @param path the relative path of the resource
     * @return the container resource coresponding to the given path
     * @exception CoreException if this method failed
     */
private IContainer createFromRoot(IPath path) throws CoreException {
    int segmentCount = path.segmentCount();
    //Assume the project exists 
    IContainer currentFolder = ((IWorkspaceRoot) destinationContainer).getProject(path.segment(0));
    for (int i = 1; i < segmentCount; i++) {
        currentFolder = currentFolder.getFolder(new Path(path.segment(i)));
        if (!currentFolder.exists()) {
            ((IFolder) currentFolder).create(false, true, null);
        }
    }
    return currentFolder;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IContainer(org.eclipse.core.resources.IContainer) IFolder(org.eclipse.core.resources.IFolder)

Example 34 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class FileNamePatternSearchScope method addToList.

private static void addToList(ArrayList res, IResource curr, boolean includeDerived) {
    //		if (!includeDerived && curr.isDerived(IResource.CHECK_ANCESTORS)) {
    //			return;
    //		}
    IPath currPath = curr.getFullPath();
    for (int k = res.size() - 1; k >= 0; k--) {
        IResource other = (IResource) res.get(k);
        IPath otherPath = other.getFullPath();
        if (otherPath.isPrefixOf(currPath)) {
            return;
        }
        if (currPath.isPrefixOf(otherPath)) {
            res.remove(k);
        }
    }
    res.add(curr);
}
Also used : IPath(org.eclipse.core.runtime.IPath) IResource(org.eclipse.core.resources.IResource)

Example 35 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class ContainerDescription method recordStateFromHistory.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.internal.ide.undo.ResourceDescription#recordStateFromHistory(org.eclipse.core.resources.IResource,
	 *      org.eclipse.core.runtime.IProgressMonitor)
	 */
public void recordStateFromHistory(IResource resource, IProgressMonitor monitor) throws CoreException {
    monitor.beginTask(UndoMessages.FolderDescription_SavingUndoInfoProgress, 100);
    if (members != null) {
        for (int i = 0; i < members.length; i++) {
            if (members[i] instanceof FileDescription) {
                IPath path = resource.getFullPath().append(((FileDescription) members[i]).name);
                IFile fileHandle = resource.getWorkspace().getRoot().getFile(path);
                members[i].recordStateFromHistory(fileHandle, new SubProgressMonitor(monitor, 100 / members.length));
            } else if (members[i] instanceof FolderDescription) {
                IPath path = resource.getFullPath().append(((FolderDescription) members[i]).name);
                IFolder folderHandle = resource.getWorkspace().getRoot().getFolder(path);
                members[i].recordStateFromHistory(folderHandle, new SubProgressMonitor(monitor, 100 / members.length));
            }
        }
    }
    monitor.done();
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IPath (org.eclipse.core.runtime.IPath)800 Path (org.eclipse.core.runtime.Path)219 File (java.io.File)161 IFile (org.eclipse.core.resources.IFile)150 CoreException (org.eclipse.core.runtime.CoreException)135 IResource (org.eclipse.core.resources.IResource)112 IOException (java.io.IOException)100 ArrayList (java.util.ArrayList)92 IProject (org.eclipse.core.resources.IProject)85 IFolder (org.eclipse.core.resources.IFolder)80 Test (org.junit.Test)72 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)58 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)55 IStatus (org.eclipse.core.runtime.IStatus)48 InputStream (java.io.InputStream)44 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)42 Status (org.eclipse.core.runtime.Status)36 IJavaProject (org.eclipse.jdt.core.IJavaProject)36 URL (java.net.URL)33 IContainer (org.eclipse.core.resources.IContainer)33