Question

I am having a hard time customizing my menus in the NetBeans Platform. The examples I've seen require you to have a Layer file which I don't believe I have in my NetBeans Platform Project.

To hide a menu via layers you are supposed to do this:

<folder name="Menu">
  <folder name="View_hidden"/>
  <folder name="Edit">
    <file name="org-openide-actions-FindAction.shadow_hidden"/>
  </folder>
</folder>

I would like to know the annotation way of hiding menus. However, if this is the only way to do it, where would I put the layer file and what would i name it?

Was it helpful?

Solution

The only way to hide menu items is to add the entries to your layer file. To add a layer file to your module you'll need to

  1. Create a new xml file called layer.xml in any package in your module
  2. Register the new layer file in your Module Manifest file (under the Important Files node) using the following pattern OpenIDE-Module-Layer: com/example/layer.xml where com/example is the package that you created the layer file in

In the layer.xml file you'll need to start with the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
</filesystem>

Shortcut for adding the _hidden nodes

Once you've added a layer file to your module you can get NetBeans to add the necessary _hidden nodes by:

  1. Expand the Important Files node in your module (any module will do but if/when this module is uninstalled then the layer file is also uninstalled)
  2. Expand the XML Layer node (this is added once you've manually added the layer.xml file as above)
  3. Expand the this layer in context node
  4. Expand the Menu Bar node
  5. Right click the menu item you want to hide and select Delete
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top