TaT HackingNetBeansXMLLayerPartOne

Hacking Module's XML Layer In NetBeans (Part 1)

Contributed By; Varun Nischal


I am back with another cool trick and some tips to remember as well. I have been involved in Plug-in Module Development for a few weeks, and it is really cool! This is based on the NetBeans Platform, in particular, on the XML layer file, which is a plugin's optional configuration file.

Contents


Pre-requisites


This trick makes use of an existing tutorial, which is the basis on which I have carried out the trick. So, you must give that a read, 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 Menu Item and Toolbar Button. I named the Action Type (Java file) as SayCheez, and display Name as Say Cheez…

Continuing from that, right-click Project & click on Install/Reload in Target Platform in the context-sensitive popup menu (context-menu). Its running successfully!

File:Nb-say-cheez-action TaT HackingNetBeansXMLLayerPartOne.png

Following, is 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>

  • Replace "
    org-nvarun-tat
    " with your package name, in which {SayCheez} resides.

Solution


Now, its time to present the tricks, that would enable you to Add/Remove a registry from XML Layer, and see instant results, and enhanced productivity.

Tricks


Tips To Remember


Note, all the above tricks would work for
CallableSystemAction 
only, I have not tested for {CookieAction}, though it should work for CookieAction as well, if you are working with only Menu Item, Toolbar Button ! For Editor and File Type Context Menu Item, there are some more tricks to be covered in next part of this series.

Version Compatability


Works with NetBeans 6.0, 6.1 as said above. Try this out on your version, and make sure to notify us if anything goes wrong!

Thank you!

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo