Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » To create a context sub menu for which user enters the input value(How can we make sub menu of the contextmenu to give user input values in the sub menu of a treeviewer)
To create a context sub menu for which user enters the input value [message #1505954] Wed, 10 December 2014 12:53
vinod raj is currently offline vinod rajFriend
Messages: 2
Registered: June 2014
Junior Member
I have created a menu and sub menu of Contextmenu for a treeviewer but i need to set user input values to the submenu for ex setting the no of iterations required .The code to create a menu and sub menu is as follows.

protected void createContextMenu(Viewer viewer) {

MenuManager contextMenu = new MenuManager("#ViewerMenu"); //$NON-NLS-1$
contextMenu.setRemoveAllWhenShown(true);

contextMenu.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {

fillContextMenu(mgr);
}
});



Menu menu = contextMenu.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
}
so how can we make the submenu to have user input values .Please help me to resolve this.

protected void fillContextMenu(final IMenuManager contextMenu) {

contextMenu.add(new Action("Delete") {
@Override
public void run() {
// implement this
}


});

IMenuManager submenu1 = new MenuManager("Set Iterations");

submenu1.add(new Action("Sub menu item 1") {
@Override
public void run() {
// implement this
}
});

contextMenu.add(submenu1);





// ... add actions to `submenu`

IMenuManager submenu2 = new MenuManager("Set Timeout");

submenu2.add(new Action("Sub menu item 1") {
@Override
public void run() {
// implement this
}
});

contextMenu.add(submenu2);



}
Previous Topic:EventAdmin is null in EventBroker if run Junit test using maven in Luna
Next Topic:org.eclipse.ui error
Goto Forum:
  


Current Time: Fri Apr 26 05:25:39 GMT 2024

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

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

Back to the top