Search in sources :

Example 41 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project bndtools by bndtools.

the class ReleaseUtils method toWorkspaceResource.

public static IResource toWorkspaceResource(File workspaceFile) {
    IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
    IPath workingCopyPath = Path.fromOSString(workspaceFile.getAbsolutePath());
    IResource resource = wsRoot.getContainerForLocation(workingCopyPath);
    if (resource == null) {
        resource = wsRoot.getFileForLocation(workingCopyPath);
    }
    return resource;
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath) IResource(org.eclipse.core.resources.IResource)

Example 42 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project bndtools by bndtools.

the class ReleaseUtils method toResource.

public static IResource toResource(File file) {
    IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
    IPath workingCopyPath = Path.fromOSString(file.getAbsolutePath());
    IFile resource = wsRoot.getFileForLocation(workingCopyPath);
    return resource;
}
Also used : IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath)

Example 43 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project eclipse.platform.text by eclipse.

the class TextSearchPage method getEnclosingProjectScope.

private FileTextSearchScope getEnclosingProjectScope() {
    String[] enclosingProjectName = getContainer().getSelectedProjectNames();
    if (enclosingProjectName == null) {
        return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived);
    }
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IResource[] res = new IResource[enclosingProjectName.length];
    for (int i = 0; i < res.length; i++) {
        res[i] = root.getProject(enclosingProjectName[i]);
    }
    return FileTextSearchScope.newSearchScope(res, getExtensions(), fSearchDerived);
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IResource(org.eclipse.core.resources.IResource)

Example 44 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project eclipse.platform.text by eclipse.

the class ResourceFileBuffer method create.

@Override
public void create(IPath location, IProgressMonitor monitor) throws CoreException {
    SubMonitor subMonitor = SubMonitor.convert(monitor, FileBuffersMessages.ResourceFileBuffer_task_creatingFileBuffer, 2);
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(location);
    URI uri = file.getLocationURI();
    if (uri == null) {
        String message = NLSUtility.format(FileBuffersMessages.ResourceFileBuffer_error_cannot_determine_URI, location);
        throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null));
    }
    fLocation = location;
    fFile = file;
    fFileStore = EFS.getStore(uri);
    fFileSynchronizer = new FileSynchronizer();
    initializeFileBufferContent(subMonitor.split(1));
    fSynchronizationStamp = fFile.getModificationStamp();
    addFileBufferContentListeners();
    subMonitor.split(1);
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) SubMonitor(org.eclipse.core.runtime.SubMonitor) URI(java.net.URI)

Example 45 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project eclipse.platform.text by eclipse.

the class ResourceHelper method createProject.

public static IProject createProject(String projectName) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = root.getProject(projectName);
    if (!project.exists())
        project.create(NULL_MONITOR);
    else
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
    if (!project.isOpen())
        project.open(NULL_MONITOR);
    return project;
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IProject(org.eclipse.core.resources.IProject)

Aggregations

IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)172 IProject (org.eclipse.core.resources.IProject)69 IPath (org.eclipse.core.runtime.IPath)60 IResource (org.eclipse.core.resources.IResource)57 IFile (org.eclipse.core.resources.IFile)53 CoreException (org.eclipse.core.runtime.CoreException)50 IWorkspace (org.eclipse.core.resources.IWorkspace)34 File (java.io.File)30 Path (org.eclipse.core.runtime.Path)29 IContainer (org.eclipse.core.resources.IContainer)26 URI (java.net.URI)18 IFolder (org.eclipse.core.resources.IFolder)17 IOException (java.io.IOException)15 IProjectDescription (org.eclipse.core.resources.IProjectDescription)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)12 IStatus (org.eclipse.core.runtime.IStatus)11 IJavaProject (org.eclipse.jdt.core.IJavaProject)11 Location (ch.acanda.eclipse.pmd.domain.Location)10