Playing with NetBeans XML Layer Files (Part 1)
I am back with another cool trick and some tips to remember as well. Let me share with you another trick, which I have been making use of for a few weeks, and it is really cool! It is based on the NetBeans Platform, in particular, on the XML layer file, which is a plugin's optional configuration file. This is my first full-fledged post on the NetBeans Platform, as I’m dealing with it almost daily for over a week, for some cool plugin developments.
Prerequisites
This trick makes use of an existing tutorial, which is the basis on which I have carried out the trick. Also, you must read this tutorial, if you don’t have any prior experience with NetBeans Platform.
Problem Description
As mentioned in the tutorial, I created an Action Type (CallableSystemAction), made it a Global MenuItem and Toolbar Button. I named the Action Type (Java file) as SayCheez, and display Name as Say Cheez…
Now, I have made this action, as expected in the tutorial. Now, right-click Project & click on Install/Reload in Target Platform in the context-sensitive popup menu (context-menu). Its running successfully!
Now, let me show you the structure of XML Layer (layer.xml), its similar to the one shown in the tutorial, i.e. how it registers the action into the NetBeans IDE.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
<filesystem>
<folder name="Actions">
<folder name="Tools">
<file name="org-nvarun-tat-SayCheez.instance"/>
</folder>
</folder>
<folder name="Menu">
<folder name="Tools">
<file name="org-nvarun-tat-SayCheez.shadow">
<attr name="originalFile" stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
<attr name="position" intvalue="150"/>
</file>
<file name="org-nvarun-tat-separatorAfter.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="175"/>
</file>
<file name="org-nvarun-tat-separatorBefore.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="125"/>
</file>
</folder>
</folder>
<folder name="Toolbars">
<folder name="Build">
<file name="org-nvarun-tat-SayCheez.shadow">
<attr name="originalFile" stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
<attr name="position" intvalue="325"/>
</file>
</folder>
</folder>
</filesystem>
So, the trick is how to manipulate the XML Layer and don’t waste time, placing actions anywhere else in the IDE, by recreating them.
- Login or register to post comments
- 2653 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
Varun Nischal replied on Thu, 2008/06/26 - 7:56am
in response to: Larry Wales
Update-
I have added these tricks in Community Docs wiki. You can check it out here-
http://wiki.netbeans.org/TaT_HackingNetBeansXMLLayerPartOne
@Larry
Glad to help :-)