Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Dynamic popup menu only shows up when I add a static item first
Dynamic popup menu only shows up when I add a static item first [message #324185] Fri, 18 January 2008 11:08 Go to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hello,

In the code snippet below if I remove the menuDynamic.add(new Action("fake"){}) then the dynamic menu will not show up. Does this make any sense? in all other examples I´ve seen about dynamic menus like http://wiki.eclipse.org/FAQ_How_do_I_make_menus_with_dynamic _contents%3F they never put static fake items to make it work.

	public void addPopupMenuContribution() {
		IMenuService menuService = (IMenuService) PlatformUI.getWorkbench()
				.getService(IMenuService.class);

		AbstractContributionFactory viewMenuAddition = new AbstractContributionFactory(
				"popup:org.eclipse.ui.popup.any?after=additions", null) {
			public void createContributionItems(
					final IServiceLocator serviceLocator,
					IContributionRoot additions) {
				IContributionItem item = new CompoundContributionItem(
						"org.eclipse.compare.rubenmenu.container") {
					protected IContributionItem[] getContributionItems() {
						List toReturn = new ArrayList();
						final MenuManager menuDynamic = new MenuManager("Menu Dynamic",null);
						menuDynamic.add(new Action("fake"){}); //if I remove this the popup menu will not show
						menuDynamic.setRemoveAllWhenShown(true);
						IMenuListener menuDynamicListener = new IMenuListener() {

							public void menuAboutToShow(IMenuManager manager) {
								menuDynamic.add(new Action("Dynamic action 1"){});
								menuDynamic.add(new Action("Dynamic action 2"){});
							}
						};
						menuDynamic.addMenuListener(menuDynamicListener);
						toReturn.add(menuDynamic);
						

						return (IContributionItem[]) toReturn
								.toArray(new IContributionItem[toReturn.size()]);
					}
				};
				additions.addContributionItem(item, null);
			}
		};
		menuService.addContributionFactory(viewMenuAddition);
	}
	}
Re: Dynamic popup menu only shows up when I add a static item first [message #324186 is a reply to message #324185] Fri, 18 January 2008 11:23 Go to previous message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

It seems that there is <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=149890">bug report</a> already about this issue. Opened in 2006-07-06!!! How can this be?
Previous Topic:BasicNewProjectResourceWizard - disabling Finish Button
Next Topic:[TableViewer] How to block FocusCellHighlighter and/or FocusCellManager
Goto Forum:
  


Current Time: Sun Jul 13 00:07:50 EDT 2025

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

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

Back to the top