Download NetBeans!

20050709 Saturday July 09, 2005

A NetBeans Popup Menu for All Seasons

By now, most NetBeans plug-in developers seem to know how to add an item to an editor's popup menu. (See Adding Items to Existing Popup Menus and Editors in NetBeans IDE 4.1 for details.) However, what do you do when you have a menu item that is applicable to all editors? Would you create a separate entry in the layer.xml file for the Java editor, a separate entry for the XML editor, a separate entry for the JSP editor, and so on? You could do that, but you could save yourself some time by creating just one entry in the layer.xml file, like this:

<folder name="Editors">
    <folder name="text">
      <folder name="base">
         <folder name="Popup">
             <file name="org-netbeans-modules-mymodule-MyAction.instance"/>
         </folder>
      </folder>
    </folder>
</folder>

Note that I emboldened base above to show you that instead of specifying plain, html, xml, x-java, x-tag, x-properties, x-jsp (or one of the others), you can specify base to cover everything at once. Note, though, that you should only do this (obviously, I guess) when you have an action that is really relevant for all editors. It is for this reason that only actions such as "Cut", "Copy", and "Paste" are found in the default base popup menu.

Jul 09 2005, 01:15:49 AM PDT Permalink