Hide/Show Menu of NetBeans RCP when Login/Logout

Leave a comment

December 26, 2012 by huionn

There are a few ways to dynamically control (show, hide, add, remove) NetBeans platform application. For my simple use case: to show or hide menu when user login or logout, I find that Repository.LayerProvider is the simplest to implement.

 public final class LoginProvider extends LayerProvider {
     private boolean showMenu;
     public void registerLayers(Collection context) {
         if (!showMenu) {
     public static void showMenu() {
         LoginProvider lp = Lookup.getDefault().lookup(LoginProvider.class);
         lp.showMenu = true;
     public static void hideMenu() {
         LoginProvider lp = Lookup.getDefault().lookup(LoginProvider.class);
         lp.showMenu = false;

hiddenMenu.xml  file

<?xml version="1.0" encoding="UTF-8"?>

    <file name="Menu_hidden" />

As a side note, it may requires clean & build for this to take effect.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: