Refine search
IProgressMonitor progressMonitor = new NullProgressMonitor(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject project = root.getProject("DesiredProjectName"); project.create(progressMonitor); project.open(progressMonitor);
private IFile getFile(IPath path) { if (path.segmentCount() > 1) { return ResourcesPlugin.getWorkspace().getRoot().getFile(path); } return null; }
private String ensureUniqueProjectName(String projectName) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); String newName = projectName; int index = 0; IProject proj = root.getProject(newName); while (proj.exists()) { index++; newName = projectName + index; proj = root.getProject(newName); } return newName; }
public static Validator<File> nonWorkspaceFolderValidator(final String prefix) { final File workspaceDir = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(); return new Validator<File>() { @Override public Optional<String> validate(File file) { if (workspaceDir.equals(file)) { return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_WorkspaceDirectory, prefix)); } else { return Optional.absent(); } } }; }
private String getExpandedPath(String path) { if (path == null || path.length() == 0) return null; IResource resource = PDECore.getWorkspace().getRoot().findMember(new Path(path)); if (resource != null) { IPath fullPath = resource.getLocation(); return fullPath == null ? null : fullPath.toOSString(); } return null; }
private boolean hasClosedProjectsInWorkspace() { IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); for (int i = 0; i < projects.length; i++) { if (!projects[i].isOpen()) return true; } return false; }
private IResource createSourceResource(IResourceDelta delta) { IPath sourcePath = delta.getMovedFromPath(); IResource resource = delta.getResource(); IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); switch (resource.getType()) { case IResource.PROJECT : return wsRoot.getProject(sourcePath.segment(0)); case IResource.FOLDER : return wsRoot.getFolder(sourcePath); case IResource.FILE : return wsRoot.getFile(sourcePath); } return null; }
public static String getWorkspaceDirectory() { if (!alreadyComputeWorkspaceDirectory){ workspaceDirectory = ResourcesPlugin.getWorkspace().getRoot() .getLocation().toOSString(); alreadyComputeWorkspaceDirectory = true; } return workspaceDirectory; }
private void refreshProjectsList() { IProject[] knownProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); synchronized (locationsToProjects) { locationsToProjects.clear(); for (IProject project : knownProjects) { IPath location = project.getLocation(); if (location != null) { locationsToProjects.put(location, project); } } } }
private IFolder computeTargetFolder(IPackageFragment rootPackage, RenameArguments args, IPackageFragment pack) { IPath path= pack.getParent().getPath(); path= path.append(getNewPackageName(rootPackage, args.getNewName(), pack.getElementName()).replace('.', IPath.SEPARATOR)); IFolder target= ResourcesPlugin.getWorkspace().getRoot().getFolder(path); return target; }
private IResource getResource() { IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath); if (resource == null && fResourcePath.segmentCount() == 1) { resource= ResourcesPlugin.getWorkspace().getRoot().getProject(fResourcePath.segment(0)); } return resource; }
@Override public Object getNewElement() { IPath newPath= fProject.getPath().removeLastSegments(1).append(getNewElementName()); return JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().findMember(newPath)); }
public static class ClasspathResolutionBreakpointListener { public void breakpoint(int bp) { // override in listener implementation } }
/** * The path is known to match a source/library folder entry. * @param path IPath * @return IPackageFragmentRoot */ public IPackageFragmentRoot getFolderPackageFragmentRoot(IPath path) { if (path.segmentCount() == 1) { // default project root return getPackageFragmentRoot(this.project); } return getPackageFragmentRoot(this.project.getWorkspace().getRoot().getFolder(path)); }
private IPath getProjectPath() { String projName = (String)getProperty(FACET_PROJECT_NAME); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName); if (project.exists()){ return project.getLocation(); } IDataModel projModel = (IDataModel)getProperty(MASTER_PROJECT_DM); if (projModel.getBooleanProperty(IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION)){ return new Path(projModel.getStringProperty(IProjectCreationPropertiesNew.PROJECT_LOCATION)).append(projName); } return new Path(projModel.getStringProperty(IProjectCreationPropertiesNew.USER_DEFINED_LOCATION)).append(projName); }
private static Optional<IProject> findAccessibleJavaProject(String name) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); if (project != null && project.isAccessible() && hasJavaNature(project)) { return Optional.of(project); } else { return Optional.absent(); } }
private boolean isWorkspacePath(IPath path) { if (path == null || path.getDevice() != null) return false; IWorkspace workspace= ResourcesPlugin.getWorkspace(); if (workspace == null) return false; return workspace.getRoot().findMember(path) != null; }
static public IResource findWorkspaceResource(IPath path) { IWorkspaceRoot ws = ResourcesPlugin.getWorkspace().getRoot(); IPath wsPath = ws.getLocation(); if (wsPath.isPrefixOf(path)) { path = path.removeFirstSegments(wsPath.segmentCount()); path = path.setDevice(null); } return ws.findMember(path); }
private IResource internalGetResource(IPath fullPath, boolean container) { if (container) { if (fullPath.segmentCount() == 1) return ResourcesPlugin.getWorkspace().getRoot().getProject(fullPath.segment(0)); return ResourcesPlugin.getWorkspace().getRoot().getFolder(fullPath); } return ResourcesPlugin.getWorkspace().getRoot().getFile(fullPath); }
/** * @param path full absolute workspace path */ private static boolean isInternalContainerPath(IPath path) { IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot(); // in case this is full workspace path it should start with project segment int segmentCount = path.segmentCount(); if(segmentCount == 1 && wsRoot.getProject(path.segment(0)).exists()) { return true; } if(segmentCount > 1 && wsRoot.getFolder(path).exists()) { return true; } return false; }