Skip to main content
Jump to: navigation, search

Talk:Menu Contributions

Revision as of 12:48, 14 August 2007 by (Talk | contribs)

Text editor popup action

How does one targetall registered context menus? One of the significant problems with the 3.2 eclipse is creeping IDE inconsistency, esp for popup menus. This inconsistency is a consequence of plugin dependent function. Having file-type dependent popups is a nice optional feature, but more critical for users is to have core function always available. There does not seem to be a mechanism to add menu items to all popups or to remove items on user preference. (I think these abilities are available for the menu bar and tool bars but I never use them, they are too slow). An example of the consequences is the AnyEdit plugin, which has pages of XML attempting to enumerate all editors in all versions of eclipse! One approach would allow regular expressions in the targetID (in the current scheme) for actions and urge editor plugin writers to adopt a uniform naming scheme. A better solution would allow users to configure global settings on popups for editors. comments moved from document (Oct 20th, 2006)

Part of this exercise will split up menu item placement from menu item visibility. You would be able to place an item in all context menus, and then specify its visibility. 21:01, 23 October 2006 (EDT)


The article references IMenuService, which seems to be an undocumented internal API. It even took me a while to realize this. 23:46, 6 November 2006 (EST)

Note: this is proposed design

Warning: This page describes design ideas, not how eclipse works. (At least I think so) 23:49, 6 November 2006 (EST)

Any chance to update these examples for the final 3.3 API?

Also, I wasn't been able to figure out how to initialize trim contribution programmatically. I've tried both plugin startup and IStartup extension point, but they both initialize after trim manager load extension points.

What I need is to do the following from the Java code (actually I only need to be able to change icon for the org.eclipse.mylyn.tasks.ui.trim command, but I wasn't been able retrieve corresponding contribution item contributed by the extension point):

 <extension point="org.eclipse.ui.menus">
   <menuContribution locationURI="menu:org.eclipse.mylyn.tasks.ui.trim">
   <menuContribution locationURI="toolbar:org.eclipse.ui.trim.command2?after">
     <toolbar id="org.eclipse.mylyn.tasks.ui.trim.container">
           label="Previous Task"

Here is what I've tried to write in Java, but strangely createContributionItems() is never being invoked:

 IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
 AbstractContributionFactory contributionFactory = new AbstractContributionFactory(
 		"toolbar:org.eclipse.ui.trim.command2?after", null) {
   public void createContributionItems(final IServiceLocator serviceLocator, IContributionRoot additions) {
     IContributionItem item = new CompoundContributionItem("org.eclipse.mylyn.tasks.ui.trim.container") {
       protected IContributionItem[] getContributionItems() {
         IContributionItem[] items = new IContributionItem[2];
         items[0] = new CommandContributionItem(serviceLocator,  // service locator 
           Collections.EMPTY_MAP,  // parameter map
           null,  // disabled icon
           null,  // hover icon
           "Previous Task",
           null,  // menmonic
           null,  // tooltip
         items[1] = new TaskTrimWidget();
         return items;
     additions.addContributionItem(item, null);				

Back to the top