List of usage examples for org.eclipse.jface.action MenuManager setImageDescriptor
public void setImageDescriptor(ImageDescriptor imageDescriptor)
From source file:org.csstudio.display.builder.editor.rcp.MorphWidgetMenuSupport.java
License:Open Source License
private MenuManager createMenuManager() { final MenuManager mm = new MenuManager(Messages.ReplaceWith); mm.setRemoveAllWhenShown(true);/*from w w w .j a va 2 s . c o m*/ mm.addMenuListener((manager) -> { if (editor.getWidgetSelectionHandler().getSelection().isEmpty()) manager.add(new Action(Messages.ReplaceWith_NoWidgets) { }); else { // Create menu that lists all widget types WidgetCategory category = null; for (WidgetDescriptor descr : WidgetFactory.getInstance().getWidgetDescriptions()) { if (Preferences.getHiddenWidgets().contains(descr.getType())) continue; // Header for start of each category if (descr.getCategory() != category) { category = descr.getCategory(); // Use disabled, empty action to show category name final Action info = new Action(category.getDescription()) { }; info.setEnabled(false); manager.add(new Separator()); manager.add(info); } manager.add(new MorphAction(descr)); } } }); mm.setImageDescriptor(Plugin.getIcon("replace.png")); return mm; }
From source file:org.eclipse.linuxtools.internal.tmf.ui.project.handlers.SelectElementTypeContributionItem.java
License:Open Source License
private static MenuManager getCategorySubMenu(List<IContributionItem> list, Map<String, MenuManager> categoriesMap, String categoryName, boolean selected) { for (Entry<String, MenuManager> entry : categoriesMap.entrySet()) { MenuManager subMenu = entry.getValue(); if (subMenu.getMenuText().equals(categoryName)) { if (selected) { subMenu.setImageDescriptor(SELECTED_ICON); }//from w w w . j a va 2s. c o m return subMenu; } } ImageDescriptor icon = selected ? SELECTED_ICON : null; MenuManager subMenu = new MenuManager(categoryName, icon, null); categoriesMap.put(categoryName, subMenu); list.add(subMenu); return subMenu; }
From source file:org.springframework.ide.eclipse.boot.dash.views.sections.BootDashUnifiedTreeSection.java
License:Open Source License
/** * Adds a submenu containing a given list of actions. The menu is only added if * there is at least one visible action in the list. * @param imageDescriptor//from ww w . jav a2 s .c om */ private void addSubmenu(IMenuManager parent, String label, ImageDescriptor imageDescriptor, ImmutableList<IAction> actions) { if (actions != null && !actions.isEmpty()) { boolean notEmpty = false; MenuManager submenu = new MenuManager(label); for (IAction a : actions) { notEmpty |= addVisible(submenu, a); } if (notEmpty) { submenu.setImageDescriptor(imageDescriptor); parent.add(submenu); } } }
From source file:ummisco.gama.ui.views.displays.LayeredDisplayDecorator.java
private MenuManager presentationMenu() { final MenuManager mm = new MenuManager(); mm.setMenuText("Presentation"); mm.setImageDescriptor(GamaIcons.create("display.sidebar2").descriptor()); mm.add(toggleSideControls.toAction()); mm.add(toggleOverlay.toAction());//ww w .java 2 s . co m mm.add(new Action("Toggle toolbar " + GamaKeyBindings.format(GamaKeyBindings.COMMAND, 'T'), GamaIcons.create("display.fullscreen.toolbar2").descriptor()) { @Override public boolean isEnabled() { return true; } @Override public void run() { toggleToolbar(); } }); return mm; }