@Override public Optional<IProjectDescription> findProjectDescriptor(File location, IProgressMonitor monitor) { IPath descriptorLocation = Path.fromOSString(location.getPath()).append(".project"); IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { IProjectDescription projectDescription = workspace.loadProjectDescription(descriptorLocation); return Optional.of(projectDescription); } catch (CoreException e) { return Optional.absent(); } }
/** * Create a record for a project based on the info in the file. * * @param file */ public ProjectRecord(File file) { projectSystemFile = file; IPath path = new Path(projectSystemFile.getPath()); try { description = ResourcesPlugin.getWorkspace() .loadProjectDescription(path); projectName = description.getName(); } catch (CoreException e) { description = null; projectName = path.lastSegment(); } }
/** * Set the project name using either the name of the * parent of the file or the name entry in the xml for * the file */ private void setProjectName(File projectFile) { //If there is no file or the user has already specified forget it if (projectFile == null) { return; } IPath path = new Path(projectFile.getPath()); IProjectDescription newDescription = null; try { newDescription = getWorkspace().loadProjectDescription(path); } catch (CoreException exception) { //no good couldn't get the name } if (newDescription == null) { this.description = null; this.projectNameField.setText(""); //$NON-NLS-1$ } else { this.description = newDescription; this.projectNameField.setText(this.description.getName()); } }
@Override public void runWithinEclipse() throws CoreException { // add all projects to the workspace IWorkspace workspace = ResourcesPlugin.getWorkspace(); for (File projectFile : host.projects) { Path path = new Path(projectFile.toString()); IProjectDescription description = workspace.loadProjectDescription(path); IProject project = workspace.getRoot().getProject(description.getName()); if (project.isOpen() == false) { project.create(description, null); project.open(null); } else { project.refreshLocal(IResource.DEPTH_INFINITE, null); } } } }
File expectedProjectDescriptionFile = new File(directory, IProjectDescription.DESCRIPTION_FILE_NAME); if (expectedProjectDescriptionFile.exists()) { desc = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(expectedProjectDescriptionFile.getAbsolutePath())); String expectedName = desc.getName(); IProject projectWithSameName = this.workspaceRoot.getProject(expectedName);
try { desc = ResourcesPlugin.getWorkspace() .loadProjectDescription(Path.fromOSString(dotProject.getAbsolutePath())); } catch (CoreException e) { projectNameError = Messages.DotnetNewWizardPage_projectError_invalidDotProjectFile;
.loadProjectDescription(stream); stream.close(); projectName = description.getName(); } else { description = IDEWorkbenchPlugin.getPluginWorkspace() .loadProjectDescription(path); projectName = description.getName();
IProjectDescription descriptor; try { descriptor = workspace.loadProjectDescription(dotProjectPath); String name = descriptor.getName(); if (!descriptor.hasNature(JavaCore.NATURE_ID)) {
IProjectDescription desc = ResourcesPlugin.getWorkspace().loadProjectDescription( folder.getLocation().append(IProjectDescription.DESCRIPTION_FILE_NAME)); desc.setLocation(folder.getLocation());