Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Menumanager setVisible doesn't work as expected
Menumanager setVisible doesn't work as expected [message #741662] Wed, 19 October 2011 19:22
davids  is currently offline davids Friend
Messages: 2
Registered: October 2011
Junior Member
I want to show a popup menu on a tree, with following conditions:
When the node "Item1" is selected, show the menu items via setVisible(true), when any other node is selected hide items setVisible(false).

In my code there is a problem, if on application start, I right click on node "Item1" I see the menu items. Then if I try to click on any other nodes THE MENU ITEMS STILL VISIBLE.

Why??


Action a1 = new Action("XXX") {};
Action a2 = new Action("YYY") {};
Action a3 = new Action("ZZZ") {};

final MenuManager mgr = new MenuManager();


mgr.add(a1);
mgr.add(a2);
mgr.add(a3);

mgr.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) tree
                    .getSelection();
            if (!selection.isEmpty()) {
                String str = ((MyModel) selection.getFirstElement())
                        .toString();
                if (str.equals("Item1")) {
                    for (int i = 0; i < 3; i++) {
                        manager.getItems()[i].setVisible(true);
                    }
                } else {
                    for (int i = 0; i < 3; i++) {
                        manager.getItems()[i].setVisible(false);
                    }
                }
            }
        }
    });
Previous Topic:Smooth updating treeviewer with DeferredTreeContentManager
Next Topic:selection in CheckboxTableViewer doesnt work in win7/64
Goto Forum:
  


Current Time: Fri Apr 26 14:27:26 GMT 2024

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

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

Back to the top