public static void addMavenNature(IProjectDescription projectDescription) { List<String> list = new ArrayList<String>(); list.addAll(Arrays.asList(projectDescription.getNatureIds())); list.add("org.eclipse.m2e.core.maven2Nature"); projectDescription.setNatureIds((String[]) list.toArray(new String[list.size()])); }
public static void addJavaNature(IProjectDescription projectDescription) { List<String> list = new ArrayList<String>(); list.addAll(Arrays.asList(projectDescription.getNatureIds())); list.add("org.eclipse.jdt.core.javanature"); projectDescription.setNatureIds((String[]) list.toArray(new String[list.size()])); }
public static void addBPMN2Nature(IProjectDescription projectDescription) { List<String> list = new ArrayList<String>(); list.addAll(Arrays.asList(projectDescription.getNatureIds())); list.add("org.eclipse.bpmn2.modeler.core.bpmn2Nature"); projectDescription.setNatureIds((String[]) list.toArray(new String[list.size()])); }
public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = project.getDescription(); Set<String> set = new LinkedHashSet<String>(Arrays.asList(description.getNatureIds())); set.add(natureId); description.setNatureIds(set.toArray(new String[0])); project.setDescription(description, monitor); }
public static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = project.getDescription(); Set<String> set = new LinkedHashSet<String>(Arrays.asList(description.getNatureIds())); set.remove(natureId); description.setNatureIds(set.toArray(new String[0])); project.setDescription(description, monitor); }
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; } } }
/** * Adds a nature to a project, LAST */ public static void addNatureToProjectLast(IProject proj, String natureId) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, null); }
public static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, monitor); }
public boolean removeProjectNature(String natureId) throws CoreException { if (!project.hasNature(natureId)) { return true; } IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); Collection<String> newNatures = new ArrayList<String>(); for (String nature : natures) { if (!nature.equals(natureId)) { newNatures.add(nature); } } description.setNatureIds(newNatures.toArray(new String[newNatures.size()])); project.setDescription(description, IResource.FORCE, null); return true; }
private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, monitor); }
private void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, monitor); }
/** * Adds a nauture to a project, FIRST */ public static void addNatureToProject(IProject proj, String natureId) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 1, prevNatures.length); newNatures[0] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, null); }
public static void addNature(IProject project, String nature) throws CoreException { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); // Add the nature String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = nature; description.setNatureIds(newNatures); project.setDescription(description, null); }
public static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); newNatures[prevNatures.length] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, monitor); }
public static void addNature(IProject project, String nature) throws CoreException { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); // Add the nature String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = nature; description.setNatureIds(newNatures); project.setDescription(description, null); }
public static void addNaturesToProject(IProject proj, String[] natureIds, IProgressMonitor monitor) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + natureIds.length]; System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); for (int i = prevNatures.length; i < newNatures.length; i++) { newNatures[i] = natureIds[i - prevNatures.length]; } description.setNatureIds(newNatures); proj.setDescription(description, monitor); }
private void setProjectNatures(IProject project, IFeatureModel model, SubMonitor subMonitor) throws CoreException { IProjectDescription desc = project.getDescription(); if (needsJavaNature(model)) { desc.setNatureIds(new String[] {JavaCore.NATURE_ID, PDE.FEATURE_NATURE}); } else { desc.setNatureIds(new String[] {PDE.FEATURE_NATURE}); } subMonitor.setWorkRemaining(1); project.setDescription(desc, subMonitor.split(1)); }
protected IProjectDescription createProjectDescription() { final IProjectDescription projectDescription = workspace.newProjectDescription(projectName); if (location != null && !Platform.getLocation().equals(location.removeLastSegments(1))) { projectDescription.setLocation(location); } if (referencedProjects != null && referencedProjects.size() != 0) { projectDescription .setReferencedProjects(referencedProjects.toArray(new IProject[referencedProjects.size()])); } if (projectNatures != null) projectDescription.setNatureIds(projectNatures.toArray(new String[projectNatures.size()])); if (builderIds != null) setBuilder(projectDescription, builderIds.toArray(new String[builderIds.size()])); return projectDescription; }
/** * Add the nature id to the project ahead of all other nature ids. * * @param proj * @param natureId * @throws CoreException * * @since 1.0.0 */ public static void addNatureToProject(IProject proj, String natureId) throws CoreException { IProjectDescription description = proj.getDescription(); String[] prevNatures = description.getNatureIds(); String[] newNatures = new String[prevNatures.length + 1]; System.arraycopy(prevNatures, 0, newNatures, 1, prevNatures.length); newNatures[0] = natureId; description.setNatureIds(newNatures); proj.setDescription(description, null); }
public static void update(IProject project, List<EclipseProjectNature> projectNatures, PersistentModelBuilder persistentModel, IProgressMonitor monitor) throws CoreException { PersistentModel previousPersistentModel = persistentModel.getPrevious(); Set<String> managedNatures = previousPersistentModel.isPresent() ? Sets.newLinkedHashSet(previousPersistentModel.getManagedNatures()) : Sets.<String>newLinkedHashSet(); Set<String> modelNatures = toNatures(projectNatures); IProjectDescription description = project.getDescription(); Set<String> existingNatures = Sets.newLinkedHashSet(Arrays.asList(description.getNatureIds())); Result<String> result = ManagedModelMergingStrategy.calculate(existingNatures, modelNatures, managedNatures); description.setNatureIds(result.getNextElements().toArray(new String[0])); project.setDescription(description, monitor); persistentModel.managedNatures(result.getNextManaged()); }