@Override public String getNodeDescription() { try { final IProject project = getProject(); return project == null ? null : project.getDescription().getComment(); } catch (CoreException e) { log.debug(e); return null; } }
private void setProjectNatures(IProject project, IFeatureModel model, IProgressMonitor monitor) throws CoreException { IProjectDescription desc = project.getDescription(); if (needsJavaNature(model)) { desc.setNatureIds(new String[] {JavaCore.NATURE_ID, MDE.FEATURE_NATURE}); } else { desc.setNatureIds(new String[] {MDE.FEATURE_NATURE}); } project.setDescription(desc, new SubProgressMonitor(monitor, 1)); }
/** Test for Bug #5102. Never reproduced but interesting little test, worth keeping around */ public void testPR() throws Exception { // create a project with a RefreshLocalJavaFileBuilder and a SortBuilder on the classpath IProject project = getWorkspace().getRoot().getProject("P1"); project.create(null); project.open(null); IProjectDescription desc = project.getDescription(); ICommand one = desc.newCommand(); one.setBuilderName(RefreshLocalJavaFileBuilder.BUILDER_NAME); ICommand two = desc.newCommand(); two.setBuilderName(SortBuilder.BUILDER_NAME); desc.setBuildSpec(new ICommand[] {one, two}); project.setDescription(desc, null); // do a full build project.build(IncrementalProjectBuilder.FULL_BUILD, null); // do an incremental build by creating a file IFile file = project.getFile("Foo"); file.create(getRandomContents(), true, getMonitor()); }
/** Goes over the given projects and converts them */ private void processProjects(final IProject[] projects) throws CoreException, ModelException { ProjectsIterate: for (IProject project : projects) { // skip unaccessible projects if (!project.isAccessible()) { continue ProjectsIterate; } // verify that the project is a PHP project if (PHPToolkitUtil.isPhpProject(project)) { IProjectDescription projectDescription = project.getDescription(); ICommand[] commands = projectDescription.getBuildSpec(); // check if the Script Builder is installed for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(DLTKCore.BUILDER_ID)) { // when the builder exists - continue to the next // project continue ProjectsIterate; } } // perform modifications only if the builder is not installed modifyProject(project); } } }
/** * The worker method. It will create a new project, then create the appropriate Soar heirarchy and * files. */ private void doFinish(String projectName, IProgressMonitor monitor) throws CoreException { monitor.beginTask("Creating " + projectName, 7); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject newProject = root.getProject(projectName); // creation of the project if (newProject.exists()) { throwCoreException("Project \"" + projectName + "\" already exists"); } else { newProject.create(monitor); newProject.open(monitor); try { IProjectDescription description = newProject.getDescription(); String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = SoarProjectNature.NATURE_ID; description.setNatureIds(newNatures); newProject.setDescription(description, IResource.FORCE, monitor); newProject.setPersistentProperty(DataMap.VERTEX_ID, "0"); } catch (CoreException e) { e.printStackTrace(); } // catch } // else monitor.worked(2); // Create the contents of the project's root directory IFolder folderAll = newProject.getFolder("all"); if (!folderAll.exists()) { folderAll.create(true, true, monitor); } // if FileMarker.markResource(folderAll, "file"); IFolder folderElaborations = newProject.getFolder("elaborations"); if (!folderElaborations.exists()) { folderElaborations.create(true, true, monitor); } // if FileMarker.markResource(folderElaborations, "file"); IFile file_firstload = newProject.getFile("_firstload.soar"); if (!file_firstload.exists()) { file_firstload.create( Utility.getFileTemplate(file_firstload, "_firstload.soar"), true, monitor); } // if FileMarker.markResource(file_firstload, "file"); IFile filedatamap = newProject.getFile("datamap.xdm"); if (!filedatamap.exists()) { filedatamap.create(Utility.getFileTemplate(filedatamap, "datamap.xdm"), true, monitor); } // if monitor.worked(3); // Create the contents of the elaborations folder IFile file_all = folderElaborations.getFile("_all.soar"); if (!file_all.exists()) { file_all.create(Utility.getFileTemplate(file_all, "_all.soar"), true, monitor); } // if FileMarker.markResource(file_all, "file"); IFile filetopstate = folderElaborations.getFile("top-state.soar"); if (!filetopstate.exists()) { filetopstate.create(Utility.getFileTemplate(filetopstate, "top-state.soar"), true, monitor); } // if FileMarker.markResource(filetopstate, "file"); SourcingFile.createSourcingFile(newProject, monitor); newProject.close(monitor); newProject.open(monitor); monitor.worked(2); monitor.done(); } // void doFinish(...)
private boolean hasJavaBuilder(IProject project) throws CoreException { ICommand[] buildCommands = project.getDescription().getBuildSpec(); for (int i = 0, l = buildCommands.length; i < l; i++) if (buildCommands[i].getBuilderName().equals(JavaCore.BUILDER_ID)) return true; return false; }