List of usage examples for org.eclipse.jface.action MenuManager indexOf
public int indexOf(String id)
From source file:de.loskutov.anyedit.actions.internal.StartupHelper.java
License:Open Source License
private static void insert(IDirtyWorkaround myAction, MenuManager menu) { IContributionItem item;//from ww w .j ava 2 s .c om 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:org.eclipse.ui.tests.menus.MenuPopulationTest.java
License:Open Source License
private void assertPrivatePopups(final MenuManager manager) { boolean cmd1Found = false; boolean cmd2Found = false; boolean cmd3Found = false; IContributionItem[] items = manager.getItems(); for (int i = 0; i < items.length; i++) { if ("org.eclipse.ui.tests.anypopup.command1".equals(items[i].getId())) { cmd1Found = true;/*from ww w. ja v a 2 s . c o m*/ } else if ("org.eclipse.ui.tests.anypopup.command2".equals(items[i].getId())) { cmd2Found = true; } else if ("org.eclipse.ui.tests.anypopup.command3".equals(items[i].getId())) { cmd3Found = true; } } boolean hasAdditions = manager.indexOf(IWorkbenchActionConstants.MB_ADDITIONS) != -1; assertTrue("no allPopups attribute for cmd1. Should show always", cmd1Found); assertTrue("allPopups = true for cmd2. Should always show", cmd2Found); assertTrue("allPopups = false for cmd3. Should show only if additions present", hasAdditions == cmd3Found); // allPopups = false. Should show only if additions is available }