TaT HackingNetBeansXMLLayerPartTwo

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

Contributed By; Varun Nischal


Here's, the Part Two of this series! So, another cool trick and some tips to remember as well. This is based on the NetBeans Platform, in particular, on the XML layer file, which is a plugin's optional configuration file.

[[{TableOfContentsTitle=TableOfContents} | {TableOfContents title='Table of 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 (
CookieAction
), 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 HackingNetBeansXMLLayerPartTwo.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


Same as that for class that extends
CallableSystemAction
.
You can't assign a Shortcut Key for classes that extend
CookieAction
using Action Wizard, as this works only for {CallableSystemAction}. However you may do that manually!
  • For Editor and File Type Context Menu Item, there are some more tricks-
Refer http://nbguru.wordpress.com/2008/07/07/tat-play-with-xml-layer-part-three-5/

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