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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations