use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class RPMProjectNature method addNature.
/**
* Utility method for adding a nature to a project.
*
* @param proj
* the project to add the nature
* @param natureId
* the id of the nature to assign to the project
* @param monitor
* a progress monitor to indicate the duration of the operation,
* or <code>null</code> if progress reporting is not required.
*/
private static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
if (project.hasNature(natureId)) {
return;
}
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] = natureId;
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class ToggleRpmlintNatureAction method toggleNature.
/**
* Toggles rpmlint nature on a project.
*
* @param project
* The project on which to toggle the nature.
*/
private static void toggleNature(IProject project) {
String rpmlintPath = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID).getString(PreferenceConstants.P_RPMLINT_PATH);
if (!Files.exists(Paths.get(rpmlintPath))) {
IStatus warning = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 1, Messages.RunRpmlintAction_1, null);
ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.RunRpmlintAction_2, null, warning);
return;
}
try {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; ++i) {
if (RpmlintNature.NATURE_ID.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;
}
}
// Add the nature
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = RpmlintNature.NATURE_ID;
description.setNatureIds(newNatures);
project.setDescription(description, null);
} catch (CoreException e) {
// TODO log exception
}
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class RpmlintNature method deconfigure.
@Override
public void deconfigure() throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(RpmlintBuilder.BUILDER_ID)) {
ICommand[] newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
description.setBuildSpec(newCommands);
// Remove rpmlint marks on all specfiles into the project.
project.accept(new RpmlintMarkerRemoveVisitor());
return;
}
}
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class ChangeLogTestProject method addJavaNature.
/**
* Add the Java nature to this project. I.e. make it a Java project.
*/
public IJavaProject addJavaNature() throws CoreException {
IProjectDescription description = this.testProject.getDescription();
String[] natures = description.getNatureIds();
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = JavaCore.NATURE_ID;
description.setNatureIds(newNatures);
this.testProject.setDescription(description, null);
return JavaCore.create(this.testProject);
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class ChangeLogTestProject method addJavaNature.
/**
* Add the Java nature to this project. I.e. make it a Java project.
*/
public IJavaProject addJavaNature() throws CoreException {
IProjectDescription description = this.testProject.getDescription();
String[] natures = description.getNatureIds();
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = JavaCore.NATURE_ID;
description.setNatureIds(newNatures);
this.testProject.setDescription(description, null);
return JavaCore.create(this.testProject);
}
Aggregations