List of usage examples for org.eclipse.jface.action MenuManager insert
public void insert(int index, IContributionItem item)
From source file:com.aptana.ruby.internal.rake.actions.RakeTasksContributionItem.java
License:Open Source License
@Override public void fill(Menu menu, int index) { IProject project = getProject();/*from w w w . j a v a 2s. c o m*/ if (project == null) { return; } Map<String, String> tasks = getRakeHelper().getTasks(project, new NullProgressMonitor()); fNamespaces = new HashMap<String, MenuManager>(); // Please note that tehre's a lot of code mixed up in here to ensure that the menus, items and sub-menus all // appear alphabetically List<String> values = new ArrayList<String>(tasks.keySet()); Collections.sort(values); for (String task : values) { String[] paths = task.split(RAKE_NAMESPACE_DELIMETER); if (paths.length == 1) { IAction action = new RunRakeAction(project, task, tasks.get(task)); ActionContributionItem item = new ActionContributionItem(action); item.fill(menu, -1); } else { MenuManager manager = getOrCreate(paths); manager.add(new RunRakeAction(project, task, tasks.get(task))); } } values = new ArrayList<String>(fNamespaces.keySet()); Collections.sort(values); Collections.reverse(values); for (String path : values) { MenuManager manager = fNamespaces.get(path); String[] parts = path.split(RAKE_NAMESPACE_DELIMETER); if (parts.length == 1) { int index2 = getInsertIndex(menu, manager); manager.fill(menu, index2); } else { MenuManager parent = getParent(parts); if (parent != null) { int index2 = getInsertIndex(parent, manager); parent.insert(index2, manager); } else { int index2 = getInsertIndex(menu, manager); manager.fill(menu, index2); } } } }
From source file:de.loskutov.anyedit.actions.internal.StartupHelper.java
License:Open Source License
private static void insert(IDirtyWorkaround myAction, MenuManager menu) { IContributionItem item;/*w w w . j ava 2 s . com*/ String id = myAction.getId(); // get "file->save" action item = menu.find(id); if (item != null) { // copy references to opened editor/part myAction.copyStateAndDispose(item); // remember position int controlIdx = menu.indexOf(id); // clean old one menu.remove(item); item = new ActionContributionItem(myAction); menu.insert(controlIdx, item); // refresh menu gui menu.update(true); } }
From source file:net.yatomiya.e4.ui.workbench.renderers.swt.MenuManagerRenderer.java
License:Open Source License
private void addToManager(MenuManager parentManager, MMenuElement model, IContributionItem menuManager) { MElementContainer<MUIElement> parent = model.getParent(); // technically this shouldn't happen if (parent == null) { parentManager.add(menuManager);// ww w . j a v a 2s .c o m } else { int index = parent.getChildren().indexOf(model); // shouldn't be -1, but better safe than sorry if (index > parentManager.getSize() || index == -1) { parentManager.add(menuManager); } else { parentManager.insert(index, menuManager); } } }
From source file:org.eclipse.tcf.te.tcf.launch.ui.internal.listeners.MenuListener.java
License:Open Source License
@Override public void menuAboutToShow(IMenuManager manager) { if (!(manager instanceof MenuManager)) return;/*from w w w. j ava2s.c o m*/ MenuManager m = (MenuManager) manager; IContributionItem editLaunchItem = getEditLaunchContributionItem(); if (editLaunchItem != null) { int index = -1; IContributionItem[] items = m.getItems(); for (int i = 0; i < items.length; i++) { IContributionItem item = items[i]; if (item instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) item).getAction(); if (action.getClass().getSimpleName().equals("EditLaunchConfigurationAction")) { //$NON-NLS-1$ index = i; m.remove(item); break; } } } if (index != -1) m.insert(index, editLaunchItem); } }
From source file:org.openmaji.implementation.tool.eclipse.plugin.MajiPlugin.java
License:Open Source License
/** * Start the bundle/* w w w . jav a2 s . c o m*/ */ public void start(BundleContext context) throws Exception { // if (this != getDefault()) { // getDefault().start(context); // return; // } inst = this; logger.log(Level.INFO, "starting intermajik: " + context.getBundle().getSymbolicName()); super.start(context); logger.log(Level.INFO, "get prefstore"); getPreferenceStore(); // force loading of awt in main thread toolkit to workaround mac OSX hang issue with SWT and AWT java.awt.Toolkit.getDefaultToolkit(); // Check if this is the first time the plugin has been run checkFirstRun(); SecurityManager.getInstance().addSecurityListener(listener); SecurityManager.getInstance().addSecurityListener(new MeemkitManagerListener()); // create intermajik menu WorkbenchWindow window = (WorkbenchWindow) getWorkbench().getActiveWorkbenchWindow(); MenuManager menubar = (MenuManager) window.getMenuBarManager(); menubar.insert(0, createInterMajikMenu()); startMajiJob.schedule(); }