View Menu with submenu
I'm working on an EclipsePluginProject. I don't have much(nearly nothing) experience with UIs under java. I added a View Option Menu and some actions following this post.
IMenuManager dropDown开发者_运维百科Menu = getViewSite().getActionBars().getMenuManager();
dropDownMenu.add(new Action("Action1") {
@Override
public void run() {
//do something
}});
dropDownMenu.add(new Action("Action2") {
@Override
public void run() {
//do something
}});
This works great and gives me the following menu:
-Action1
-Action2
How do i build a submenu which looks like this?
-Action > -1
-2
You can add menus to other menus:
IMenuManager rootMenu = getViewSite().getActionBars().getMenuManager();
MenuManager menu = new MenuManager("Menu &2", "2");
menu.add(new Action("Action1") {
@Override
public void run() {
//do something
}});
menu.add(new Action("Action2") {
@Override
public void run() {
//do something
}});
rootMenu.add(menu);
You have to create a new MenuManager...
IMenuManager dropDownMenu = new MenuManager( "Some text", "id" );
... add it to your menu ...
menuManager.appendToGroup( "yourSection", dropDownMenu );
... and add your actions to your new subMenu:
dropDownMenu.add(new Action("Action1") {
@Override
public void run() {
//do something
}});
dropDownMenu.add(new Action("Action2") {
@Override
public void run() {
//do something
}});
精彩评论