List of usage examples for org.eclipse.jface.action IContributionManager insertBefore
void insertBefore(String id, IContributionItem item);
From source file:org.eclipse.oomph.setup.presentation.SetupActionBarContributor.java
License:Open Source License
private void populateManagerEnablements(IContributionManager manager, String subMenuText, String insertBeforeID, final List<EnablementAction> additionalTasks) { int id = ++lastSubMenuID; String subMenuID = ENABLEMENT_ITEM_PREFIX + id; final MenuManager submenuManager = new MenuManager(subMenuText, subMenuID); submenuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { // Execute later in event loop to make sure the menu is visible when the first image is loaded. UIUtil.asyncExec(new Runnable() { public void run() { final Queue<EnablementAction> queue = new ConcurrentLinkedQueue<EnablementAction>( additionalTasks); int jobs = Math.max(queue.size(), 10); for (int i = 0; i < jobs; i++) { Job iconLoader = new Job("IconLoader-" + i) { @Override protected IStatus run(IProgressMonitor monitor) { EnablementAction action; while ((action = queue.poll()) != null && submenuManager.isVisible() && !monitor.isCanceled()) { action.loadImage(); }/*from w w w.j a v a 2s. c o m*/ return Status.OK_STATUS; } }; iconLoader.setSystem(true); iconLoader.schedule(); } } }); } }); Collections.sort(additionalTasks, ACTION_COMPARATOR); populateManagerGen(submenuManager, additionalTasks, null); manager.insertBefore(insertBeforeID, submenuManager); }
From source file:org.eclipse.sirius.editor.editorPlugin.ContributionActionBarContributor.java
License:Open Source License
/** * This populates the specified <code>manager</code> with * {@link org.eclipse.jface.action.ActionContributionItem}s based on the * {@link org.eclipse.jface.action.IAction}s contained in the * <code>actions</code> collection, by inserting them before the specified * contribution item <code>contributionID</code>. If <code>ID</code> is * <code>null</code>, they are simply added. */// w w w .ja v a 2 s . com protected void populateManager(IContributionManager manager, Collection<IAction> actions, String contributionID) { if (actions != null) { for (Iterator<IAction> i = actions.iterator(); i.hasNext();) { IAction action = i.next(); if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } } }
From source file:org.eclipse.sirius.editor.tools.api.menu.AbstractMenuBuilder.java
License:Open Source License
/** * Populate the menumanager with the given actions. * //from ww w . ja v a2 s . c o m * @param manager * manager to populate. * @param actions * actions to populate. * @param contributionID * the Id for the contribution. */ protected void populateManager(final IContributionManager manager, final Collection actions, final String contributionID) { if (actions != null) { List<IAction> sortedActions = Lists.newArrayList(Iterables.filter(actions, IAction.class)); Comparator<IAction> comparator = new Comparator<IAction>() { @Override public int compare(IAction a1, IAction a2) { int diff = getPriority(a1) - getPriority(a2); if (diff == 0) { // if both actions have no priority associated, or if // they have the same priority, we compare the text diff = Collator.getInstance().compare(a1.getText(), a2.getText()); } return diff; } }; Collections.sort(sortedActions, comparator); for (final IAction action : sortedActions) { if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } } manager.update(true); }
From source file:org.modelversioning.emfprofile.application.registry.ui.observer.NestingCommonModelElementsInStereotypeApplications.java
License:Open Source License
/** * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, * by inserting them before the specified contribution item <code>contributionID</code>. * If <code>contributionID</code> is <code>null</code>, they are simply added. */// w ww .ja v a 2s . c o m public void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { if (actions != null) { for (IAction action : actions) { if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } } }
From source file:org.obeonetwork.dsl.uml2.editor.internal.UmlCommonActionProvider.java
License:Open Source License
/** * This populates the specified <code>manager</code> with * {@link org.eclipse.jface.action.MenuManager}s containing * {@link org.eclipse.jface.action.ActionContributionItem}s based on the * {@link org.eclipse.jface.action.IAction}s contained in the * <code>submenuActions</code> collection, by inserting them before the * specified contribution item <code>contributionID</code>. If * <code>contributionID</code> is <code>null</code>, they are simply added. * /*from www.jav a 2s . c o m*/ * Code duplicated from UMLActionBarContributor * * @see UMLActionBarContributor#populateManager */ private void populateManager(IContributionManager manager, Map<String, Collection<IAction>> submenuActions, String contributionID) { if (submenuActions != null) { for (Map.Entry<String, Collection<IAction>> entry : submenuActions.entrySet()) { MenuManager submenuManager = new MenuManager(entry.getKey()); if (contributionID != null) { manager.insertBefore(contributionID, submenuManager); } else { manager.add(submenuManager); } populateManager(submenuManager, entry.getValue(), null); } } }
From source file:org.obeonetwork.dsl.uml2.editor.internal.UmlCommonActionProvider.java
License:Open Source License
/** * This populates the specified <code>manager</code> with * {@link org.eclipse.jface.action.ActionContributionItem}s based on the * {@link org.eclipse.jface.action.IAction}s contained in the * <code>actions</code> collection, by inserting them before the specified * contribution item <code>contributionID</code>. If * <code>contributionID</code> is <code>null</code>, they are simply added. * // w w w. j a v a2 s.c om * Code duplicated from UMLActionBarContributor * * @see UMLActionBarContributor#populateManager */ private void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { if (actions != null) { for (IAction action : actions) { if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } } }
From source file:tudresden.ocl20.pivot.essentialocl.expressions.presentation.ExpressionsActionBarContributor.java
License:Open Source License
/** * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection, * by inserting them before the specified contribution item <code>contributionID</code>. * If <code>contributionID</code> is <code>null</code>, they are simply added. * <!-- begin-user-doc -->//from w ww . ja va 2 s .c om * <!-- end-user-doc --> * @generated */ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { if (actions != null) { for (IAction action : actions) { if (contributionID != null) { manager.insertBefore(contributionID, action); } else { manager.add(action); } } } }