javaxmlnetbeansrcpnetbeans-platform

NetBeans Rich Client Platform: How to disable specific options dialog categories at runtime?


This is a follow-up question for this question. Is there a way to enable or disable specific options dialog categories at runtime? For instance, there are custom options panels of A, B, C, X and Y. An admin user should be able to see A, B, C, X and Y: What admin sees

whereas a standard user should only see A, B, C: What user sees

In other words, can "layer.xml" be edited depending on authorization of the selected user?

Editing "layer.xml" works fine when I add the lines below:

<filesystem>
    <folder name="OptionsDialog">
        <folder name="X.hidden">
            <file name="X.instance_hidden"/>
        </folder>
        <folder name="Y.hidden">
            <file name="Y.instance_hidden"/>
        </folder>
    </folder>
</filesystem>

but I don't want to re-build and run the program to disable X & Y options specific to non-admin user.


Solution

  • You can edit the Netbeans System FileSystem at runtime: use FileUtil.getConfigRoot() to access its root FileObject, then you can navigate through the file system and edit files.

    Another option is to write a subclass of MultiFileSystem.

    More information here: https://netbeans.apache.org/wiki/DevFaqDynamicSystemFilesystem.html