public static String[] getNatures(IProject[] projects) throws CoreException { Set<String> result= new HashSet<>(); for (int i= 0; i < projects.length; i++) { String[] pns= projects[i].getDescription().getNatureIds(); for (int p = 0; p < pns.length; p++) { result.add(pns[p]); } } return result.toArray(new String[result.size()]); } }
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; }
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); }
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; }
public void run(IProgressMonitor monitor) throws CoreException { IProjectDescription description = projectResource.getDescription(); description.setDynamicReferences(requiredProjectArray); projectResource.setDescription(description, IResource.AVOID_NATURE_CONFIG, null); } };
public void run(IProgressMonitor monitor) throws CoreException { IProjectDescription description = projectResource.getDescription(); description.setDynamicReferences(requiredProjectArray); projectResource.setDescription(description, IResource.AVOID_NATURE_CONFIG, null); } };
public void run(IProgressMonitor monitor) throws CoreException { IProjectDescription description = projectResource.getDescription(); description.setDynamicReferences(requiredProjectArray); projectResource.setDescription(description, IResource.AVOID_NATURE_CONFIG, null); } };
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); }
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); }
/** * 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 addBuilders(IProject project, String[] id, IProgressMonitor monitor) throws CoreException { IProjectDescription desc = project.getDescription(); List<ICommand> newCommands = getCommands(desc, id); for (int i = 0; i < id.length; i++) { ICommand command = desc.newCommand(); command.setBuilderName(id[i]); newCommands.add(command); } setCommands(desc, newCommands); project.setDescription(desc, monitor); }
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()); }
public static void update(IProject project, List<EclipseBuildCommand> buildCommands, PersistentModelBuilder persistentModel, IProgressMonitor monitor) throws CoreException { IProjectDescription description = project.getDescription(); Set<ICommand> current = ImmutableSet.copyOf(description.getBuildSpec()); Set<ICommand> model = toCommands(buildCommands, description); PersistentModel previousModel = persistentModel.getPrevious(); Set<ICommand> managed = previousModel.isPresent() ? Sets.newLinkedHashSet(previousModel.getManagedBuilders()) : Sets.<ICommand>newLinkedHashSet(); Result<ICommand> result = ManagedModelMergingStrategy.calculate(current, model, managed); description.setBuildSpec(result.getNextElements().toArray(new ICommand[0])); project.setDescription(description, monitor); persistentModel.managedBuilders(result.getNextManaged()); }
protected void addToBuildSpec(String builderID) throws CoreException { IProjectDescription description = getProject().getDescription(); ICommand builderCommand = getBuilderCommand(description, builderID); if (builderCommand == null) { // Add a new build spec ICommand command = description.newCommand(); command.setBuilderName(builderID); setBuilderCommand(description, command); } }
/** * Remove the old AspectJ Builder from the given project */ public static void removeOldBuilder(IProject project) throws CoreException { IProjectDescription description = project.getDescription(); ICommand[] buildCommands = description.getBuildSpec(); if (contains(buildCommands, OLD_BUILDER)) { ICommand[] newBuildCommands = remove(buildCommands, OLD_BUILDER); description.setBuildSpec(newBuildCommands); project.setDescription(description, null); } }
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)); }
public static String[] computeAffectedNatures(IJavaElement element) throws CoreException { if (element instanceof IMember) { IMember member= (IMember)element; if (JdtFlags.isPrivate(member)) { return element.getJavaProject().getProject().getDescription().getNatureIds(); } } IJavaProject project= element.getJavaProject(); return ResourceProcessors.computeAffectedNatures(project.getProject()); }
public static String[] computeAffectedNatures(IJavaElement element) throws CoreException { if (element instanceof IMember) { IMember member= (IMember)element; if (JdtFlags.isPrivate(member)) { return element.getJavaProject().getProject().getDescription().getNatureIds(); } } IJavaProject project= element.getJavaProject(); return ResourceProcessors.computeAffectedNatures(project.getProject()); }
private boolean projectFolderAlreadyExists(String newName) throws CoreException { boolean isNotInWorkpace= fProject.getProject().getDescription().getLocationURI() != null; if (isNotInWorkpace) return false; // projects outside of the workspace are not renamed URI locationURI= fProject.getProject().getLocationURI(); IFileStore projectStore= EFS.getStore(locationURI); IFileStore newProjectStore= projectStore.getParent().getChild(newName); return newProjectStore.fetchInfo().exists(); }