1 package net.mograsim.plugin.nature;
3 import org.eclipse.core.resources.ICommand;
4 import org.eclipse.core.resources.IProject;
5 import org.eclipse.core.resources.IProjectDescription;
6 import org.eclipse.core.resources.IProjectNature;
7 import org.eclipse.core.runtime.CoreException;
9 public class MograsimNature implements IProjectNature
13 * ID of this project nature
15 public static final String NATURE_ID = "net.mograsim";
17 private IProject project;
20 public void configure() throws CoreException
22 IProjectDescription desc = project.getDescription();
23 ICommand[] commands = desc.getBuildSpec();
25 for (int i = 0; i < commands.length; ++i)
27 if (commands[i].getBuilderName().equals(MograsimBuilder.BUILDER_ID))
33 ICommand[] newCommands = new ICommand[commands.length + 1];
34 System.arraycopy(commands, 0, newCommands, 0, commands.length);
35 ICommand command = desc.newCommand();
36 command.setBuilderName(MograsimBuilder.BUILDER_ID);
37 newCommands[newCommands.length - 1] = command;
38 desc.setBuildSpec(newCommands);
39 project.setDescription(desc, null);
43 public void deconfigure() throws CoreException
45 IProjectDescription description = getProject().getDescription();
46 ICommand[] commands = description.getBuildSpec();
47 for (int i = 0; i < commands.length; ++i)
49 if (commands[i].getBuilderName().equals(MograsimBuilder.BUILDER_ID))
51 ICommand[] newCommands = new ICommand[commands.length - 1];
52 System.arraycopy(commands, 0, newCommands, 0, i);
53 System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
54 description.setBuildSpec(newCommands);
55 project.setDescription(description, null);
62 public IProject getProject()
68 public void setProject(IProject project)
70 this.project = project;