Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Menu Contributions/Populating a dynamic submenu"
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
= Add a dynamic submenu to the ProblemView menu = | = Add a dynamic submenu to the ProblemView menu = | ||
− | In [[Menu Contributions/Problems View Example]] we added 2 dynamic menus. You then have to | + | In [[Menu Contributions/Problems View Example]] we added 2 dynamic menus. You then have to extend the abstract [http://help.eclipse.org/helios/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/actions/CompoundContributionItem.html CompoundContributionItem] class in your provided class. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | <source lang="xml"> | ||
+ | <menu id="org.eclipse.ui.views.problems.groupBy.menu" | ||
+ | label="%ProblemView.GroupBy.label" | ||
+ | mnemonic="%ProblemView.GroupBy.mnemonic"> | ||
+ | <dynamic class="org.eclipse.ui.views.markers.internal.GroupByItems" | ||
+ | id="org.eclipse.ui.views.problems.groupBy.items"/> | ||
+ | </menu> | ||
+ | </source> | ||
When your menu is populated, you'll have your getContributionItems() method called: | When your menu is populated, you'll have your getContributionItems() method called: | ||
− | + | <source lang="java"> | |
− | + | protected IContributionItem[] getContributionItems() { | |
− | + | IContributionItem[] list = new IContributionItem[2]; | |
− | + | Map parms = new HashMap(); | |
− | + | parms.put("groupBy", "Severity"); | |
− | + | list[0] = new CommandContributionItem(null, | |
− | + | "org.eclipse.ui.views.problems.grouping", | |
− | + | parms, null, null, null, "Severity", null, | |
− | + | null, CommandContributionItem.STYLE_PUSH); | |
− | + | parms = new HashMap(); | |
− | + | parms.put("groupBy", "None"); | |
− | + | list[1] = new CommandContributionItem(null, | |
− | + | "org.eclipse.ui.views.problems.grouping", | |
− | + | parms, null, null, null, "None", null, null, | |
− | + | CommandContributionItem.STYLE_PUSH); | |
− | + | return list; | |
− | + | } | |
+ | </source> |
Latest revision as of 19:49, 3 January 2011
In Menu Contributions/Problems View Example we added 2 dynamic menus. You then have to extend the abstract CompoundContributionItem class in your provided class.
<menu id="org.eclipse.ui.views.problems.groupBy.menu" label="%ProblemView.GroupBy.label" mnemonic="%ProblemView.GroupBy.mnemonic"> <dynamic class="org.eclipse.ui.views.markers.internal.GroupByItems" id="org.eclipse.ui.views.problems.groupBy.items"/> </menu>
When your menu is populated, you'll have your getContributionItems() method called:
protected IContributionItem[] getContributionItems() { IContributionItem[] list = new IContributionItem[2]; Map parms = new HashMap(); parms.put("groupBy", "Severity"); list[0] = new CommandContributionItem(null, "org.eclipse.ui.views.problems.grouping", parms, null, null, null, "Severity", null, null, CommandContributionItem.STYLE_PUSH); parms = new HashMap(); parms.put("groupBy", "None"); list[1] = new CommandContributionItem(null, "org.eclipse.ui.views.problems.grouping", parms, null, null, null, "None", null, null, CommandContributionItem.STYLE_PUSH); return list; }