Description: The workspace supports the notion of project natures (or "natures" for short"). A nature associates lifecycle behaviour with a project. Natures are installed on a per-project basis using the setDescription method defined on org.eclipes.core.resources.IProject. They are configured automatically when a project is opened and deconfigured when a project is closed. For example, the Java nature might install a Java builder and do other project configuration when added to a project
The natures extension-point allows nature writers to register their nature implementation under a symbolic name that is then used from within the workspace to find and configure natures. The symbolic name is id of the nature extension. When defining a nature extension, users are encouraged to include a human-readable value fo rth e"name" attribute which identifies their meaning and potentially may be presented to users.
Natures can specify relationship constraints with other natures. The "one-of-nature" constraint specifies that at most one nature belong to a given set can exist on a project at any given time. This enforces mutual exclusion between natures that are not compatible with each other. The "requires-nature" constraint specifies a dependency on another nature. When a nature is added to a project, all required natures must also be added. The natures are guaranteed to be configured and deconfigured in such a way that their required natures will always be configured before them and deconfigured after them. For this reason, cyclic dependencies between natures are not permitted.
Natures cannot be added to or removed from a project if that change would violate any constraints that were previously satisfied. If a nature is configured on a project, but later finds that its constraints are not satisfied, that nature and all natures that require it are marked as disabled, but remain on the project. This can happen, for example, when a required nature goes missing from the install. Natures that are missing from the install, and natures involved in dependency cycles are also marked as disabled.
Natures can also specify which incremental project builders, if any, are configured by them. With this information, the workspace will ensure that builders will only run when their corresponding nature is present and enabled on the project being built. If a nature is removed from a project, but the nature's deconfigure method fails to remove its corresponding builders, the workspace will remove those builders from the spec automatically. It is not permitted for two natures to specify the same incremental project builder in their markup.
Natures also have the ability to disallow the creation of linked resources on projects they are associated with. By setting the allowLinking
attribute to "false", a nature can declare that linked resources should never be created. This feature is new in release 2.1.
Configuration Markup:
<!ELEMENT extension (runtime , (one-of-nature | requires-nature | builder)* , options?)>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED
>
<!ELEMENT run (parameter*)>
<!ATTLIST run
class CDATA #REQUIRED
>
<!ELEMENT parameter EMPTY>
<!ATTLIST parameter
name CDATA #REQUIRED
value CDATA #REQUIRED
>
<!ELEMENT one-of-nature EMPTY>
<!ATTLIST one-of-nature
id CDATA #REQUIRED
>
<!ELEMENT requires-nature EMPTY>
<!ATTLIST requires-nature
id CDATA #REQUIRED
>
<!ELEMENT builder EMPTY>
<!ATTLIST builder
id CDATA #REQUIRED
>
<!ELEMENT options EMPTY>
<!ATTLIST options
allowLinking (true | false)
>
<extension id="fireNature" name="Fire Nature" point="org.eclipse.core.resources.natures"> <runtime> <run class="com.xyz.natures.Fire"/> </runtime> <one-of-nature id="com.xyz.stateSet"/> <options allowLinking="false"/> </extension> <extension id="waterNature" name="Water Nature" point="org.eclipse.core.resources.natures"> <runtime> <run class="com.xyz.natures.Water"/> </runtime> <one-of-nature id="com.xyz.stateSet"/> </extension> <extension id="snowNature" name="Snow Nature" point="org.eclipse.core.resources.natures"> <runtime> <run class="com.xyz.natures.Snow"> <parameter name="installBuilder" value="true"/> </run> </runtime> <requires-nature id="com.xyz.coolplugin.waterNature"/> <builder id="com.xyz.snowMaker"/> </extension>If these extensions were defined in a plug-in with id "com.xyz.coolplugin", the fully qualified name of these natures would be "com.xyz.coolplugin.fireNature", "com.xyz.coolplugin.waterNature" and "com.xyz.coolplugin.snowNature".
API Information: The value of the class attribute must represent an implementor of org.eclipse.core.resources.IProjectNature. Nature definitions can be examined using the org.eclipse.core.resources.IProjectNatureDescriptor interface. The descriptor objects can be obtained using the methods getNatureDescriptor(String) and getNatureDescriptors() on org.eclipse.core.resources.IWorkspace.
Supplied Implementation: The platform itself does not have any predefined natures. Particular product installs may include natures as required.
Copyright (c) 2003 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html