Project natures allow a plug-in to tag a project as a specific kind of project. For example, the Java development tools (JDT) use a Java nature to add Java-specific behavior to projects. Project natures are defined by plug-ins, and are typically added or removed per-project when the user performs some action defined by the plug-in.
理解:就是区分各种不同的project,在它的实现方法里可以添加和删除具体的描述信息。
它的2个实现方法:
// Override
public void configure() throws CoreException {
Set natureSet = new TreeSet();
CollectionUtil.addAllQuietly(natureSet, description.getNatureIds());
if (!natureSet.contains(ThisProject.NATURE_ID)) {
natureSet.add(ThisProject.NATURE_ID);
}
String[] natures = new String[natureSet.size()];
natureSet.toArray(natures);
description.setNatureIds(natures);
this.project.setDescription(description, 1, null);
}
// Override
public void deconfigure() throws CoreException {
IProjectDescription description = this.project.getDescription();
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; i++)
if (commands[i].getBuilderName().equals(builderID)) {
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);
this.project.setDescription(description, null);
return;
}
}