Search in sources :

Example 11 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 12 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 13 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)

Example 14 with IPath

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

the class MoveResourcesRefactoringContribution method retrieveArgumentMap.

/* (non-Javadoc)
	 * @see org.eclipse.ltk.core.refactoring.RefactoringContribution#retrieveArgumentMap(org.eclipse.ltk.core.refactoring.RefactoringDescriptor)
	 */
public Map retrieveArgumentMap(final RefactoringDescriptor descriptor) {
    HashMap map = new HashMap();
    if (descriptor instanceof MoveResourcesDescriptor) {
        MoveResourcesDescriptor moveDescriptor = (MoveResourcesDescriptor) descriptor;
        IPath[] paths = moveDescriptor.getResourcePathsToMove();
        String project = moveDescriptor.getProject();
        IPath destinationPath = moveDescriptor.getDestinationPath();
        map.put(ATTRIBUTE_NUMBER_OF_RESOURCES, String.valueOf(paths.length));
        for (int i = 0; i < paths.length; i++) {
            map.put(ATTRIBUTE_ELEMENT + (i + 1), ResourceProcessors.resourcePathToHandle(project, paths[i]));
        }
        map.put(ATTRIBUTE_DESTINATION, ResourceProcessors.resourcePathToHandle(project, destinationPath));
        //$NON-NLS-1$//$NON-NLS-2$
        map.put(ATTRIBUTE_UPDATE_REFERENCES, moveDescriptor.isUpdateReferences() ? "true" : "false");
        return map;
    }
    return null;
}
Also used : MoveResourcesDescriptor(org.eclipse.ltk.core.refactoring.resource.MoveResourcesDescriptor) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap)

Example 15 with IPath

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

the class ResourceModifications method addMove.

/**
	 * Adds the given resource to the list of resources
	 * to be moved.
	 *
	 * @param move the resource to be moved
	 * @param arguments the move arguments
	 */
public void addMove(IResource move, MoveArguments arguments) {
    if (fMove == null) {
        fMove = new ArrayList(2);
        fMoveArguments = new ArrayList(2);
    }
    fMove.add(move);
    fMoveArguments.add(arguments);
    if (fIgnoreCount == 0) {
        IPath destination = ((IResource) arguments.getDestination()).getFullPath().append(move.getName());
        internalAdd(new MoveDescription(move, destination));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList)

Aggregations

IPath (org.eclipse.core.runtime.IPath)500 Path (org.eclipse.core.runtime.Path)128 File (java.io.File)106 IFile (org.eclipse.core.resources.IFile)89 IResource (org.eclipse.core.resources.IResource)80 CoreException (org.eclipse.core.runtime.CoreException)74 ArrayList (java.util.ArrayList)72 IFolder (org.eclipse.core.resources.IFolder)63 IProject (org.eclipse.core.resources.IProject)60 IOException (java.io.IOException)57 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)51 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)40 IStatus (org.eclipse.core.runtime.IStatus)33 IJavaProject (org.eclipse.jdt.core.IJavaProject)33 URL (java.net.URL)26 InputStream (java.io.InputStream)23 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)23 Status (org.eclipse.core.runtime.Status)23 HashSet (java.util.HashSet)22 Test (org.junit.Test)22