How do I hide menus without a layer file in NetBeans Platform?

筅森魡賤 提交于 2019-12-02 06:32:48

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/10282081/how-do-i-hide-menus-without-a-layer-file-in-netbeans-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!