Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ Why should I add my own project nature?"

 
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
 +
Project natures act as tags on a project to indicate that a certain
 +
tool is used to operate on that project
 +
 +
== Why shouldn't add my own project nature? ==
 +
 +
As natures are an Eclipse-specific concept and have some limitations, it's sometimes difficult for users to understand and manipulate them. It's recommended to do as much as possible without using a project nature. In many case, checking for a file content-type or the existence of some specific file in a project can be enough to trigger some features or builders and configure them, without a new nature.
 +
 +
Also, at the moment, [https://bugs.eclipse.org/bugs/show_bug.cgi?id=102527 user cannot add/remove nature] from projects on vanilla Eclipse IDE. If you think user is likely to with to enable/disable your nature, this can be a no-go.
 +
 +
== Adding a project nature ==
 +
 
Project natures act as tags on a project to indicate that a certain  
 
Project natures act as tags on a project to indicate that a certain  
 
tool is used to operate on that project. They can also be used to distinguish
 
tool is used to operate on that project. They can also be used to distinguish
Line 11: Line 23:
 
of an <tt>actionSet</tt> declaration that  operates only on files in projects
 
of an <tt>actionSet</tt> declaration that  operates only on files in projects
 
with the PDE nature:
 
with the PDE nature:
 +
 
<pre>
 
<pre>
 
   &lt;extension point=&quot;org.eclipse.ui.popupMenus&quot;&gt;
 
   &lt;extension point=&quot;org.eclipse.ui.popupMenus&quot;&gt;
Line 22: Line 35:
 
         ...
 
         ...
 
</pre>
 
</pre>
 
  
 
Another reason for using natures is to make use of the nature
 
Another reason for using natures is to make use of the nature
Line 32: Line 44:
 
the project and to associate additional attributes, such as builders,
 
the project and to associate additional attributes, such as builders,
 
with the project.
 
with the project.
 
  
 
== See Also: ==
 
== See Also: ==
 
+
*Go to '''Platform Plug-in Developer Guide &gt; Programmer&#146;s Guide &gt; Advanced Resources concepts &gt; Project natures'''
Go to '''Platform Plug-in Developer Guide &gt; Programmer&#146;s Guide
+
*[http://www.eclipse.org/articles/Article-Builders/builders.html Eclipse online article &#147;Project Natures and Builders&#148;]
&gt; Resources overview &gt; Project natures''',
+
** This article shows how to bind a project nature to a builder. 
Eclipse online article &#147;Project Natures and Builders&#148;
+
*[[FAQ When does my language need its own perspective?]]
  
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
 
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>

Latest revision as of 05:57, 8 November 2016

Project natures act as tags on a project to indicate that a certain tool is used to operate on that project

Why shouldn't add my own project nature?

As natures are an Eclipse-specific concept and have some limitations, it's sometimes difficult for users to understand and manipulate them. It's recommended to do as much as possible without using a project nature. In many case, checking for a file content-type or the existence of some specific file in a project can be enough to trigger some features or builders and configure them, without a new nature.

Also, at the moment, user cannot add/remove nature from projects on vanilla Eclipse IDE. If you think user is likely to with to enable/disable your nature, this can be a no-go.

Adding a project nature

Project natures act as tags on a project to indicate that a certain tool is used to operate on that project. They can also be used to distinguish projects that your plug-in is interested in from the rest of the projects in the workspace. For example, natures can be used to filter declarative extensions that operate only on projects of a particular type. The propertyPages and popupMenus extension points allow you to filter enablement of an extension, based on various properties of the selected resource. One of the properties that this mechanism understands is the nature of a project. Here is an example of an actionSet declaration that operates only on files in projects with the PDE nature:

   <extension point="org.eclipse.ui.popupMenus">
      <objectContribution
         objectClass="org.eclipse.core.resources.IFile"
         id="org.eclipse.pde.ui.featureToolSet">
         <filter
            name="projectNature"
            value="org.eclipse.pde.FeatureNature">
         </filter>
         ...

Another reason for using natures is to make use of the nature lifecycle methods when your plug-in is connected to or disconnected from a project. When a nature is added to a project for the first time, the nature&#146;s configure method is called. When the nature is removed from the project, the deconfigure method is called. This is an opportunity to initialize metadata on the project and to associate additional attributes, such as builders, with the project.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top