Java Code Examples for org.eclipse.core.resources.IProject#getDescription()
The following examples show how to use
org.eclipse.core.resources.IProject#getDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuilderUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Adds a builder with the specified ID to the project if the project does not * already have the builder. * * @param project project to add the builder to * @param builderId id of the builder to add * @throws CoreException */ public static void addBuilderToProject(IProject project, String builderId) throws CoreException { if (hasBuilder(project, builderId)) { return; } IProjectDescription description = project.getDescription(); List<ICommand> builders = new ArrayList<ICommand>( Arrays.asList(description.getBuildSpec())); ICommand newBuilder = description.newCommand(); newBuilder.setBuilderName(builderId); builders.add(newBuilder); description.setBuildSpec(builders.toArray(new ICommand[builders.size()])); project.setDescription(description, null); }
Example 2
Source File: NewDepanProjectWizard.java From depan with Apache License 2.0 | 6 votes |
@Override public boolean performFinish() { if (false == super.performFinish()) { return false; } try { IProject project = getNewProject(); IProjectDescription description = project.getDescription(); description.setNatureIds(DEPAN_NATURES); project.setDescription(description, null); buildAnalysisResources(); buildWorkResources(); } catch (CoreException errCore) { ApplicationLogger.LOG.error("Failed to create new project", errCore); } return true; }
Example 3
Source File: ProjectUtils.java From developer-studio with Apache License 2.0 | 6 votes |
public static void addBuildSpecificationsToProject(IProject project, String...buildCommandList) throws CoreException{ IProjectDescription description = project.getDescription(); ICommand[] buildSpecifications = new BuildCommand[buildCommandList.length]; int i = 0; for (ICommand buildCommand : buildSpecifications) { buildCommand = new BuildCommand(); buildCommand.setBuilderName(buildCommandList[i]); buildSpecifications[i] = buildCommand; i++; } // int i = 0; // for (String buildCommand : buildCommandList) { // new bui // buildSpecifications[i].setBuilderName(buildCommand); // i++; // } description.setBuildSpec(buildSpecifications); project.setDescription(description, null); }
Example 4
Source File: GamlUtils.java From gama with GNU General Public License v3.0 | 6 votes |
public static void removeBuilder(final IProject project, final String builderId) throws CoreException { final IProjectDescription description = project.getDescription(); final ICommand[] builderSpecs = description.getBuildSpec(); for (int i = 0; i < builderSpecs.length; ++i) { if (builderId.equals(builderSpecs[i].getBuilderName())) { // Remove the builder final ICommand[] modifiedSpecs = new ICommand[builderSpecs.length - 1]; System.arraycopy(builderSpecs, 0, modifiedSpecs, 0, i); System.arraycopy(builderSpecs, i + 1, modifiedSpecs, i, builderSpecs.length - i - 1); description.setBuildSpec(modifiedSpecs); project.setDescription(description, null); return; } } }
Example 5
Source File: ProjectUtilities.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Adds a FindBugs nature to a project. * * @param project * The project the nature will be applied to. * @param monitor * A progress monitor. Must not be null. * @throws CoreException */ public static void addFindBugsNature(IProject project, IProgressMonitor monitor) throws CoreException { if (hasFindBugsNature(project)) { return; } IProjectDescription description = project.getDescription(); String[] prevNatures = description.getNatureIds(); for (int i = 0; i < prevNatures.length; i++) { if (FindbugsPlugin.NATURE_ID.equals(prevNatures[i])) { // nothing to do return; } } String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = FindbugsPlugin.NATURE_ID; if (DEBUG) { for (int i = 0; i < newNatures.length; i++) { System.out.println(newNatures[i]); } } description.setNatureIds(newNatures); project.setDescription(description, monitor); }
Example 6
Source File: RenameJavaProjectChange.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void doRename(IProgressMonitor pm) throws CoreException { try { pm.beginTask(getName(), 2); if (fUpdateReferences) modifyClassPaths(new SubProgressMonitor(pm, 1)); IProject project= getProject(); if (project != null) { IProjectDescription description= project.getDescription(); description.setName(getNewName()); project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1)); } } finally { pm.done(); } }
Example 7
Source File: AppEngineStandardFacetChangeListener.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * Add our {@code appengine-web.xml} builder that monitors for changes to the {@code <runtime>} * element. */ private static void addAppEngineWebBuilder(IProject project) { try { IProjectDescription projectDescription = project.getDescription(); ICommand[] commands = projectDescription.getBuildSpec(); for (int i = 0; i < commands.length; i++) { if (AppEngineWebBuilder.BUILDER_ID.equals(commands[i].getBuilderName())) { return; } } ICommand[] newCommands = new ICommand[commands.length + 1]; // Add it after other builders. System.arraycopy(commands, 0, newCommands, 0, commands.length); // add builder to project ICommand command = projectDescription.newCommand(); command.setBuilderName(AppEngineWebBuilder.BUILDER_ID); newCommands[commands.length] = command; projectDescription.setBuildSpec(newCommands); project.setDescription(projectDescription, null); logger.finer(project + ": added AppEngineWebBuilder"); } catch (CoreException ex) { logger.log(Level.SEVERE, "Unable to add builder for " + project, ex); } }
Example 8
Source File: IResourcesSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public static void removeNature(IProject project, String nature) throws CoreException { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); for (int i = 0; i < natures.length; ++i) { if (nature.equals(natures[i])) { // Remove the nature String[] newNatures = new String[natures.length - 1]; System.arraycopy(natures, 0, newNatures, 0, i); System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1); description.setNatureIds(newNatures); project.setDescription(description, null); return; } } }
Example 9
Source File: Importer.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
private void addHybrisNature(IProject project, IProgressMonitor monitor) throws CoreException { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); for (int i = 0; i < natures.length; ++i) { if (HYBRIS_NATURE_ID.equals(natures[i])) { return; } } // Add the nature String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = HYBRIS_NATURE_ID; description.setNatureIds(newNatures); project.setDescription(description, monitor); }
Example 10
Source File: ProjectTestUtil.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Returns the {@link ICommand} for the specified builder, or {@code null} if the builder does not * exist. */ public static ICommand getBuilder(IProject project, String builderId) throws CoreException { IProjectDescription description = project.getDescription(); for (ICommand command : description.getBuildSpec()) { if (command.getBuilderName().equals(builderId)) { return command; } } return null; }
Example 11
Source File: ProjectTestUtil.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Adds the nature defined by {@code natureId} to {@code project}. */ public static void addNature(IProject project, String natureId) throws CoreException { Preconditions.checkArgument(project.exists()); IProjectDescription description = project.getDescription(); Set<String> natures = Sets.newHashSet(description.getNatureIds()); natures.add(natureId); description.setNatureIds(natures.toArray(new String[natures.size()])); project.setDescription(description, null); }
Example 12
Source File: SlrProjectSupport.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
public static void addNature(IProject project) throws CoreException { String xtextNatureId = "org.eclipse.xtext.ui.shared.xtextNature"; if (!project.hasNature(xtextNatureId)) { IProjectDescription description = project.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = xtextNatureId; description.setNatureIds(newNatures); project.setDescription(description, null); } }
Example 13
Source File: BazelProjectSupport.java From eclipse with Apache License 2.0 | 5 votes |
private static void addNature(IProject project, String nature) throws CoreException { if (!project.hasNature(nature)) { IProjectDescription description = project.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = nature; description.setNatureIds(newNatures); project.setDescription(description, null); } }
Example 14
Source File: FixProjectsUtils.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
public static void removeBuildersFromProject(IProgressMonitor monitor, IProject project) throws CoreException { final IProjectDescription description = project.getDescription(); // remove hybris builder for (ICommand build : project.getDescription().getBuildSpec()) { if (build.getBuilderName().equals("org.eclipse.jdt.core.javabuilder")) { description.setBuildSpec(new ICommand[] { build }); project.setDescription(description, monitor); break; } } }
Example 15
Source File: ResourceUtil.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Add a nature to the given project. Return boolean indicating if it was added (if already exists on the project * we'll return a false. if there's an error, we'll throw a CoreException). * * @param project * @param id * @throws CoreException */ public static boolean addNature(IProject project, String id) throws CoreException { IProjectDescription desc = project.getDescription(); if (addNature(desc, id)) { project.setDescription(desc, null); return true; } return false; }
Example 16
Source File: IResourcesSetupUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public static void addBuilder(IProject project, String builderId) throws CoreException { IProjectDescription description = project.getDescription(); ICommand[] specs = description.getBuildSpec(); ICommand command = description.newCommand(); command.setBuilderName(builderId); // Add the nature ICommand[] specsModified = new ICommand[specs.length + 1]; System.arraycopy(specs, 0, specsModified, 0, specs.length); specsModified[specs.length] = command; description.setBuildSpec(specsModified); project.setDescription(description, monitor()); }
Example 17
Source File: LangNature.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public static void disableAutoBuildMode(IProject project, String builderId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = project.getDescription(); ICommand[] buildSpec = description.getBuildSpec(); for(ICommand command : buildSpec) { if(command.getBuilderName().equals(builderId)) { command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false); } } description.setBuildSpec(buildSpec); project.setDescription(description, IResource.AVOID_NATURE_CONFIG, monitor); }
Example 18
Source File: AddDotnetBuilder.java From aCute with Eclipse Public License 2.0 | 5 votes |
@Override public Object execute(final ExecutionEvent event) { final IProject project = getProject(event); if (project != null) { try { if (hasBuilder(project)) { return null; } IProjectDescription description = project.getDescription(); final ICommand buildCommand = description.newCommand(); buildCommand.setBuilderName(IncrementalDotnetBuilder.BUILDER_ID); final List<ICommand> commands = new ArrayList<>(); commands.addAll(Arrays.asList(description.getBuildSpec())); commands.add(buildCommand); description.setBuildSpec(commands.toArray(new ICommand[commands.size()])); project.setDescription(description, null); } catch (final CoreException e) { } } return null; }
Example 19
Source File: NatureUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void addNature(IProject project, String nature) { try { IProjectDescription description = project.getDescription(); String[] currentNatures = description.getNatureIds(); String[] newNatures = new String[currentNatures.length + 1]; System.arraycopy(currentNatures, 0, newNatures, 0, currentNatures.length); newNatures[currentNatures.length] = nature; description.setNatureIds(newNatures); project.setDescription(description, null); } catch (CoreException e) { LogHelper.logError(e); } }
Example 20
Source File: TestUtils.java From CogniCrypt with Eclipse Public License 2.0 | 4 votes |
/** * This method creates a empty JavaProject in the current workspace * * @param projectName for the JavaProject * @return new created JavaProject * @throws CoreException */ public static IJavaProject createJavaProject(final String projectName) throws CoreException { final IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot(); deleteProject(workSpaceRoot.getProject(projectName)); final IProject project = workSpaceRoot.getProject(projectName); project.create(null); project.open(null); final IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] {JavaCore.NATURE_ID}); project.setDescription(description, null); final IJavaProject javaProject = JavaCore.create(project); final IFolder binFolder = project.getFolder("bin"); binFolder.create(false, true, null); javaProject.setOutputLocation(binFolder.getFullPath(), null); final List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); final IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); final LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); for (final LibraryLocation element : locations) { entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null)); } // add libs to project class path javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); final IFolder sourceFolder = project.getFolder("src"); sourceFolder.create(false, true, null); final IPackageFragmentRoot packageRoot = javaProject.getPackageFragmentRoot(sourceFolder); final IClasspathEntry[] oldEntries = javaProject.getRawClasspath(); final IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1]; System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length); newEntries[oldEntries.length] = JavaCore.newSourceEntry(packageRoot.getPath()); javaProject.setRawClasspath(newEntries, null); return javaProject; }