Search code examples
eclipseeclipse-plugineclipse-rcprcp

Checking the state of menu items inside handlers


How to check pro-grammatically whether command contributed as menu item(s) is/are checked/unchecked(If of CHECK BOX type), selected or unselected(if of type RADIO button) inside handlers "execute" method. See snap shot here https://docs.google.com/file/d/0B3pxBGD-v-ycWVFaeElnSGdyTE0/edit .


Solution

  • I got solution, Added this code in handler execute method method

    public Object execute(ExecutionEvent event) throws ExecutionException {
    
       Event selEvent = (Event) event.getTrigger();
       MenuItem item = (MenuItem) selEvent.widget;
    
       System.Out.Println(item.getSelection());     
       return null;
    }