Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » MenuManager as submenu with ISelectionListener
MenuManager as submenu with ISelectionListener [message #756456] Sun, 13 November 2011 15:20 Go to next message
kenny is currently offline kennyFriend
Messages: 1
Registered: November 2011
Junior Member
I am creating a menubar, this menu bar contains a sub-menu (a menumanager).
I want this sub-menu to be disabled on app start-up.

My program also has jface treeviewer, I want to toggle sub-menu's state based on the selection in tree-view.

final MenuManager subMenu = new MenuManager("Main",null);

MenuManager menubar = new MenuManager(...);

Some issues:
Actions are act as menu items, when I use Action (IAction) I can use setEnabled(false) to disable, I can not do it with MenuManager.

I can extend actions like this:
public class MyNewAction extends Action implements ISelectionListener, IWorkbenchAction {

    private final IWorkbenchWindow window;  	
    public RCNActionNewScriptKsh(IWorkbenchWindow window) {
		this.window = window;				
     public void selectionChanged(IWorkbenchPart part, ISelection selection) {

With that I can listen to selections of tree-view items and act accordingly.
I can't do it with menu manager.

Please advice Smile

Re: MenuManager as submenu with ISelectionListener [message #756611 is a reply to message #756456] Mon, 14 November 2011 14:11 Go to previous messageGo to next message
Michal Sova is currently offline Michal SovaFriend
Messages: 1
Registered: July 2009
Junior Member

the treeviewer implements ISelectionProvider, you can getSelection(), addSelectionChangedListener(ISelectionChangedListener listener) .You can also set the treeviewer as a selection provider on your site in view/editor
getSite().setSelectionProvider(treeviewer ) and then listen to selection changes using an ISelectionListener attached to the selection service.
Re: MenuManager as submenu with ISelectionListener [message #756616 is a reply to message #756611] Mon, 14 November 2011 14:19 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kenny, while you can't set a MenuManager to disabled you can setVisible(false). Does that work?


Previous Topic:How to have Tree View inside a Table
Next Topic:Resizing columns in TreeViewer
Goto Forum:

Current Time: Mon Jun 18 07:28:36 GMT 2018

Powered by FUDForum. Page generated in 0.01702 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top