In my plugin, a pop-up menu that I have the menu item 'x' and I want to add a submenu in the menu item
And change the number of items and labels in the submenu.
I think I can do this; .xml from plugin, then how to do this programmatically?
In your plugin.xml , Eclipse ui.menus , your "refers to the ID of the route" menu menu content Add, ie the menu that you want to attach your Sbmens (in this case, Menu: myDynamicMenuRoot ): Note that allPopups = "true" This ensures that your submenu will be added to any menu finally, ExtensionContributionFactory class is expanding, whose job it will be to create a dynamic submenu items I add items based on the commands I defined My plugin.xml :
& lt; MenuContribution allPopups = "true" class = "com.myCode.menus.MyDynamicMenuContributions" locationURI = "menu: myDynamicMenuRoot" & gt; & Lt; / MenuContribution & gt;
Public category MyDynamicMenuContribution S ExtensionContributionFactory {Personal Static Final ImageDescriptor GREEN_STAR = Plugin.getImageDescriptor ("mouse / green_star.png"); @Override public void createContributionItems (IServiceLocator serviceLocator, IContributionRoot extra) {a couple // order based contributions CommandContributionItemParameter paa = new CommandContributionItemParameter construction standards (serviceLocator, "Submenu_CommandAA", "my.package.command.myCommandAA", SWT.PUSH); PAA.icon = GREEN_STAR; PAA.label = "Command AA"; Kmmandsnpadnitmparamitr Pibibi = new Kmmandsnpadnitmpametr (Sewasuck, "Sbmenu_commondbibi", "Aipikejkcomkmandkman Command Bibi", SWT.PUSH); PBB.icon = GREEN_STAR; PBB.label = "CommandBB"; // Create original contribution item and add to the given additional context CommandContributionItem itemAA = New CommandContributionItem (pAA); ItemAA.setVisible (true); Additions.addContributionItem (itemAA, void); CommandEdivid item itemBB = new commandEdit element (PBB); ItemBB.setVisible (true); Additions.addContributionItem (Item BB, blank); }}
Comments
Post a Comment