[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Radio Context Menu in View

I am trying to dynamically create a pop-up menu in a view which has a radio sub-menu, but do not how to do this (this is trivial in SWT).

I have the following code:

public void createContextMenu () {
 final MenuManager contextMenu = new MenuManager();
 Menu menu = contextMenu.createContextMenu( listViewer.getControl());
 listViewer.getControl().setMenu( menu );
 getSite().registerContextMenu( contextMenu, listViewer );

 contextMenu.setRemoveAllWhenShown( true );
 contextMenu.addMenuListener( new IMenuListener(){
    public void menuAboutToShow (IMenuManager manager)
    {
      IStructuredSelection selection = ( IStructuredSelection )
      listViewer.getSelection();
      if ( selection.size() == 1 )
      {
       contextMenu.add( new CloseAction() );
       // I want to a radio sub-menu here, something like...
       // [] Choice 1
       // [] Choice 2
       // [] Choice 3
      }
    }
 } );
}

Please note the embedded comments where I want to add the radio sub-menu. I understand how to add actions to context menus, etc. In essence, what I really want is for the user to be to select a mode using the radio menu (I am aware of a similar thread which didn't really answer my question).

Any help much appreciated.