Declaring a nature in Java

Generator QR Code 2d barcode in Java Declaring a nature
1431 Declaring a nature
QR Code Generation In Java
Using Barcode creator for Java Control to generate, create QR Code JIS X 0510 image in Java applications.
For the Favorites product, you want a new propertiesAuditor nature to associate the property file audit builder with a project Begin by creating a new orgeclipsecoreresourcesnatures extension in the Favorites plug-in manifest Switch to the Extensions page, click the Add button, select orgeclipsecoreresourcesnatures, and then click Finish (see Figure 14 11)
Bar Code Creation In Java
Using Barcode generator for Java Control to generate, create bar code image in Java applications.
(FOLSVH 3OXJLQV 7KLUG (GLWLRQ
Barcode Reader In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
3DJH 
QR Generation In Visual C#
Using Barcode encoder for .NET Control to generate, create QR Code image in .NET framework applications.
5HWXUQ WR 7DEOH RI &RQWHQWV
QR Code ISO/IEC18004 Maker In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
143 Natures
Print Quick Response Code In VS .NET
Using Barcode encoder for VS .NET Control to generate, create QR Code JIS X 0510 image in Visual Studio .NET applications.
Figure 14 11
QR Code JIS X 0510 Drawer In Visual Basic .NET
Using Barcode generator for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications.
The New Extension wizard showing the natures extension point selected
DataMatrix Maker In Java
Using Barcode generation for Java Control to generate, create Data Matrix ECC200 image in Java applications.
Click on the new extension to edit the properties, change the id to propertiesAuditor , and change the name to Favorites Properties Auditor (see Figure 14 12) The nature declaration should look like this:
Draw Barcode In Java
Using Barcode generation for Java Control to generate, create bar code image in Java applications.
<extension id="propertiesAuditor" name="Favorites Properties Auditor" point="orgeclipsecoreresourcesnatures"> </extension>
USS-128 Generation In Java
Using Barcode printer for Java Control to generate, create UCC - 12 image in Java applications.
Figure 14 12
Printing UPC - 13 In Java
Using Barcode generator for Java Control to generate, create EAN-13 image in Java applications.
The extension details showing the nature s attributes
Drawing Code 39 Full ASCII In Java
Using Barcode creation for Java Control to generate, create Code 39 image in Java applications.
(FOLSVH 3OXJLQV 7KLUG (GLWLRQ
Create OneCode In Java
Using Barcode creator for Java Control to generate, create USPS Intelligent Mail image in Java applications.
3DJH 
Code 39 Extended Maker In Visual Basic .NET
Using Barcode creation for Visual Studio .NET Control to generate, create Code-39 image in VS .NET applications.
5HWXUQ WR 7DEOH RI &RQWHQWV
ECC200 Printer In C#
Using Barcode generation for .NET framework Control to generate, create Data Matrix ECC200 image in .NET framework applications.
CHAPTER 14
USS Code 39 Generator In VS .NET
Using Barcode drawer for .NET Control to generate, create Code 39 Full ASCII image in .NET applications.
Builders, Markers, and Natures
Draw UPC - 13 In .NET Framework
Using Barcode printer for Visual Studio .NET Control to generate, create EAN 13 image in .NET applications.
Similar to build declarations, the nature declaration contains the nature s local identifier The nature s full identifier is the plug-in identifier containing the nature concatenated with the nature s local identifier, or in this case, comqualityeclipsefavoritespropertiesAuditor
Generate Bar Code In VS .NET
Using Barcode generator for ASP.NET Control to generate, create barcode image in ASP.NET applications.
1432 Associating builders and natures
Generating Data Matrix In .NET Framework
Using Barcode creation for VS .NET Control to generate, create Data Matrix ECC200 image in Visual Studio .NET applications.
Now you want to associate your builder with your nature Click on the orgeclipsecoreresourcesnatures extension point and select New > builder Enter the builder id, which in this case is comqualityeclipse favoritespropertiesFileAuditor (see Figure 14 13)
Making Code 128A In C#.NET
Using Barcode creator for Visual Studio .NET Control to generate, create USS Code 128 image in Visual Studio .NET applications.
Figure 14 13
The extension element details showing the builder s attributes
In addition, return to the builder declaration (see Section 1411, Declaring a builder, on page 535) and modify the hasNature attribute to be true After this has been accomplished, the nature declaration should look like this:
<extension id="propertiesAuditor" name="Favorites Properties Auditor" point="orgeclipsecoreresourcesnatures"> <builder id="comqualityeclipsefavorites propertiesFileAuditor"/> </extension>
These changes ensure that the builder will be omitted from a project s build process if the nature is not associated with the project If you want your builder to work regardless of whether your nature is present, then omit this from your nature s declaration
(FOLSVH 3OXJLQV 7KLUG (GLWLRQ
3DJH 
5HWXUQ WR 7DEOH RI &RQWHQWV
143 Natures
1433 IProjectNature
Natures can have behavior to configure and deconfigure a project Similar to the Java nature, you want the nature to add your builder to the project s build spec You can right-click on the orgeclipsecoreresourcesnatures extension point and select New > runtime, then right-click on the (runtime) nested element and select New > run In the plug-in manifest editor, click on the class label at the left of the class field, then use the New Java Class wizard to generate a new class named PropertiesAuditorNature in the comqualityeclipsefavoritesbuilder package When this is complete, the nature declaration should look like this:
<extension id="propertiesAuditor" name="Favorites Properties Auditor" point="orgeclipsecoreresourcesnatures"> <builder id="comqualityeclipsefavorites propertiesFileAuditor"/> <runtime> <run class="comqualityeclipsefavoritesbuilder PropertiesAuditorNature"/> </runtime> </extension>
The class specified in the nature declaration must implement the interface When the nature is added to a project, this class is instantiated and the setProject() method is called, followed by the configure() method; the deconfigure() method is called when the nature is removed from a project Similar to the Java nature, you want the nature to add your builder to the project s build spec via the addBuilderToProject() method (see Section 1414, Associating a builder with a project, on page 545) and trigger a build in the background (see Section 218, Background Tasks Jobs API, on page 808) when the project is configured When the nature is removed from the project, the build spec is modified and all audit markers are removed
orgeclipsecoreresourcesIProjectNature
package comqualityeclipsefavoritesbuilder; import public class PropertiesAuditorNature implements IProjectNature { private IProject project; public IProject getProject() { return project; }
(FOLSVH 3OXJLQV 7KLUG (GLWLRQ
3DJH 
5HWXUQ WR 7DEOH RI &RQWHQWV
CHAPTER 14
public void setProject(IProject project) { thisproject = project; }
Builders, Markers, and Natures
public void configure() throws CoreException { PropertiesFileAuditoraddBuilderToProject(project); new Job("Properties File Audit") { protected IStatus run(IProgressMonitor monitor) { try { projectbuild( PropertiesFileAuditorFULL_BUILD, PropertiesFileAuditorBUILDER_ID, null, monitor); } catch (CoreException e) { FavoritesLoglogError(e); } return StatusOK_STATUS; } }schedule(); } public void deconfigure() throws CoreException { PropertiesFileAuditorremoveBuilderFromProject(project); PropertiesFileAuditordeleteAuditMarkers(project); } }
1434 Required natures
A dependency of one nature on another nature can be expressed in the nature s declaration (see Section 1431, Declaring a nature, on page 562) When the required nature is not present or not enabled, Eclipse disables the nature having the requirement For example, the propertiesAuditor nature depends on the Java nature and PDE nature If you were to express this in your nature s declaration, it would look like this:
<extension id="propertiesAuditor" name="Favorites Properties Auditor" point="orgeclipsecoreresourcesnatures"> <builder id="comqualityeclipsefavorites propertiesFileAuditor"> </builder> <runtime> <run class="comqualityeclipsefavoritesbuilder PropertiesAuditorNature"/> </runtime> <requires-nature id="orgeclipsejdtcorejavanature"/> <requires-nature id="orgeclipsepdePluginNature"/> </extension>