Search in sources :

Example 41 with IPath

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

the class FileUndoState method createResourceHandle.

public IResource createResourceHandle() {
    IWorkspaceRoot workspaceRoot = parent.getWorkspace().getRoot();
    IPath fullPath = parent.getFullPath().append(name);
    return workspaceRoot.getFile(fullPath);
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath)

Example 42 with IPath

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

the class FolderUndoState method createResourceHandle.

public IResource createResourceHandle() {
    IWorkspaceRoot workspaceRoot = getWorkspace().getRoot();
    IPath folderPath = parent.getFullPath().append(name);
    return workspaceRoot.getFolder(folderPath);
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath)

Example 43 with IPath

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

the class ImportOperation method getDestinationContainerFor.

/**
     * Returns the container resource that the passed file system object should be
     * imported into.
     *
     * @param fileSystemObject the file system object being imported
     * @return the container resource that the passed file system object should be
     *     imported into
     * @exception CoreException if this method failed
     */
IContainer getDestinationContainerFor(Object fileSystemObject) throws CoreException {
    IPath pathname = new Path(provider.getFullPath(fileSystemObject));
    if (createContainerStructure) {
        return createContainersFor(pathname.removeLastSegments(1));
    }
    if (source == fileSystemObject) {
        return null;
    }
    IPath sourcePath = new Path(provider.getFullPath(source));
    IPath destContainerPath = pathname.removeLastSegments(1);
    IPath relativePath = destContainerPath.removeFirstSegments(sourcePath.segmentCount()).setDevice(null);
    return createContainersFor(relativePath);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath)

Example 44 with IPath

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

the class ImportOperation method importFileSystemObjects.

/**
     * Imports the specified file system objects into the workspace.
     * If the import fails, adds a status object to the list to be returned by
     * <code>getStatus</code>.
     *
     * @param filesToImport the list of file system objects to import
     *   (element type: <code>Object</code>)
     * @throws CoreException
     * @exception OperationCanceledException if canceled
     */
void importFileSystemObjects(List filesToImport) throws CoreException {
    Iterator filesEnum = filesToImport.iterator();
    while (filesEnum.hasNext()) {
        Object fileSystemObject = filesEnum.next();
        if (source == null) {
            // We just import what we are given into the destination
            IPath sourcePath = new Path(provider.getFullPath(fileSystemObject)).removeLastSegments(1);
            if (provider.isFolder(fileSystemObject) && sourcePath.isEmpty()) {
                // If we don't have a parent then we have selected the
                // file systems root. Roots can't copied (at least not
                // under windows).
                errorTable.add(new Status(IStatus.INFO, PlatformUI.PLUGIN_ID, 0, "DataTransferMessages.ImportOperation_cannotCopy", null));
                continue;
            }
            source = sourcePath.toFile();
        }
        importRecursivelyFrom(fileSystemObject, POLICY_DEFAULT);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) Iterator(java.util.Iterator)

Example 45 with IPath

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

the class MavenWorkspace method addSourcePathFromConfiguration.

private void addSourcePathFromConfiguration(ClasspathHelper helper, MavenProject project, Element configuration, List<String> attributes) {
    if (configuration != null) {
        Element sources = configuration.getChild("sources");
        if (sources != null) {
            for (Object element : sources.getChildren()) {
                final String path = ((Element) element).getTextTrim();
                final IPath projectLocation = project.getProject().getLocation();
                final String projectPath = projectLocation.toOSString();
                final String sourceFolder = path.contains(projectPath) ? path.substring(projectPath.length() + 1) : path;
                helper.addSourceEntry(project.getProject().getFullPath().append(sourceFolder));
                if (!attributes.contains(sourceFolder)) {
                    attributes.add(sourceFolder);
                }
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Element(org.jdom.Element)

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