Playing with NetBeans XML Layer Files (Part 1)
Solution
Note, all the following 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 MenuItem, Toolbar Button OR Shortcut Keys! For Editor and File Type Context MenuItem, there would be some other way round, I will see if its comfortable playing with them as well
By Code Deduction
Trick #1- If you want to remove either one of the separators, OR even both of them, then see the following code, the code present in that remove it from the XML Layer, as per your need.
<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>
Trick #2 - If you want to remove the Action, from Toolbar, then remove the following code;
<folder name="Toolbars">Trick #3 - If you want to remove the Action from Tools Menu, and retain it only on the Toolbar, then remove the following code;
<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>
<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>
By Code Replacement
Trick #4 - If you want to make a Shortcut key for this action, add the following code,
<folder name="Shortcuts">
<file name="O-F3.shadow">
<attr name="originalFile" stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
</file>
</folder>
Trick #5 - Sometimes, it might happen, that your action is not suitable for any existing Menu, and you are looking to create your own Menu. By the time, you get ready with your Menu, you can just have this Shortcut Keys alone, i.e. no Menu Item, no Toolbar Button.
<?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>
</folder>
</folder-->
<folder name="Shortcuts">
<file name="O-F3.shadow">
<attr name="originalFile" stringvalue="Actions/Tools/org-nvarun-tat-SayCheez.instance"/>
</file>
</folder>
</filesystem>
- Login or register to post comments
- 3951 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 :-)