Search code examples
javaxmlnetbeansnetbeans-8netbeans-platform

Where to find the main layer.xml file in Netbeans RCP maven project?


I am trying to dev an application based on Netbeans RCP, so far so good, but I would like to change some default menu (hide some menu that I don't want / need).

I found that I have to edit the layer.xml, but I don't know where to find the default one.

I can create a new layer.xml, but only for a module.

Any help ? Thanks.


Solution

  • Short answer: There isn't one, you need to create it manually and modify to your liking.

    Longer answer: There is no 'default' layer.xml for the 'app'. Keep in mind, an NBP app is platform + bunch o' modules. There is no 'main' module.

    Each module can have a (single) layer.xml file (rather, each module almost certainly does have a layer.xml file, albeit generated). At run-time, the platform (module system?) merges the layer.xml files from the modules bundled with the app.

    Layer XML was no longer necessary with the introduction of annotations (I think thats the reason, could be mistaken). The NBP build generates a layer.xml from the annotations in the module's source files. After building a module, you can see it in the output directory as 'generated-layer.xml'.

    ooh! look at the generated-layer.xml

    Creating an XML Layer file:
    Right click on the module in the project tree and select New -> XML Layer (if its not in the menu, select Other then choose the Module Development Category, XML Layer file type from the New File dialog -- see below)

    enter image description here

    Once created, you should see an XML Layer node under the Important Files tree, as well as a layer.xml file the source tree.

    To hide items, add _hidden entries to your layer.xml file, or you can just delete them from the layer tree:

    enter image description here

    Find the element you want to remove under and press Delete. This will add a _hidden element to your layer file.