X

Geertjan's Blog

  • June 2, 2005

Adding Items to Existing Popup Menus and Editors in NetBeans IDE 4.1

Geertjan Wielenga
Product Manager
There's a great mailing list for anyone interested in learning about and contributing to NetBeans Modules. Its address is dev@openide.netbeans.org. Yesterday I found out two new cool things -- how to add a menu item to an existing popup menu or editor. Previously, I only knew how to create a data loader that recognizes a file object and assigns menu items to it. But what about if your file object is already recognized and you just want to add some menu items to its existing popup menu? Or what if you want to add a menu item to an editor's popup menu? Everything you need to do, apart from actually creating the Action class (subclassing CallableSystemAction) that defines the menu item, is done in the layer.xml file:

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

By the way, even though the documentation always refers to something called the 'Source Editor', there are in fact several editors. The above entry in the layer.xml would only affect the Java editor. For other editors, replace the x-java above with one of the following values:

  • plain
  • html
  • xml
  • x-properties
  • x-jsp

There are also others, the above is just a random subset.

And, to add a menu item to the Java file object's popup menu, add the following to the layer.xml file:

<folder name="Loaders">
<folder name="text">
<folder name="x-java">
<folder name="Actions">
<file name="org-netbeans-modules-mymodule-MyAction.instance"/>
</folder>
</folder>
</folder>
</folder>

Join the discussion

Comments ( 1 )
  • Kelvin Nkinyili Monday, July 4, 2011

    Hey Geertjan,awesome article!

    I wish to understand more because I am developing an application that will

    need to use a Popup menu that is generated by a mouse hover action.

    Could you get in touch via email?

    Thanks


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.