private static void changeIcon(final IMenuManager menu, final IContributionItem item, final ImageDescriptor image) { if (item instanceof ActionContributionItem) { ((ActionContributionItem) item).getAction().setImageDescriptor(image); } else if (item instanceof CommandContributionItem) { final CommandContributionItemParameter data = ((CommandContributionItem) item).getData(); data.commandId = ((CommandContributionItem) item).getCommand().getId(); data.icon = image; final CommandContributionItem newItem = new CommandContributionItem(data); newItem.setId(item.getId()); menu.insertAfter(item.getId(), newItem); menu.remove(item); item.dispose(); } else if (item instanceof ActionSetContributionItem) { changeIcon(menu, ((ActionSetContributionItem) item).getInnerItem(), image); } else if (item instanceof MenuManager) { ((MenuManager) item).setImageDescriptor(image); } }
@Override public void tearDown() throws Exception { super.tearDown(); broker.resetState(); waitForIdleState(); final TreeItem[] treeItems = commonViewer.getTree().getItems(); assertTrue("Expected empty Project Explorer. Input was: " + Arrays.toString(treeItems), Arrays2.isEmpty(treeItems)); assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel()); assertNull( "Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution()); IContributionItem showHiddenWorkingSetsItem = from( Arrays.asList(projectExplorer.getViewSite().getActionBars().getToolBarManager().getItems())) .firstMatch(i -> ShowHiddenWorkingSetsDropDownAction.class.getName().equals(i.getId())) .orNull(); assertNull( "Show hidden working set drop down contribution was visible when projects are configured as top level elements.", showHiddenWorkingSetsItem); }
/** * Tests that the Top Level Elements */ @Test public void testTopLevelElementsEntryNoDuplicates() { IActionBars actionBars = projectExplorer.getViewSite().getActionBars(); IMenuManager menuManager = actionBars.getMenuManager(); int topLevelElementsEntriesFound = 0; for (IContributionItem item : menuManager.getItems()) { if (item instanceof MenuManager) { String escapedMenuText = LegacyActionTools.removeMnemonics(((MenuManager) item).getMenuText()); if (escapedMenuText.equals("Top Level Elements")) { topLevelElementsEntriesFound++; } } } assertEquals("There was more than one 'Top Level Elements' entry in the navigator action bar.", topLevelElementsEntriesFound, 1); }
/** * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { if (actions != null) { IContributionItem[] items = manager.getItems(); for (int i = 0; i < items.length; i++) { // Look into SubContributionItems // IContributionItem contributionItem = items[i]; while (contributionItem instanceof SubContributionItem) { contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); } // Delete the ActionContributionItems with matching action. // if (contributionItem instanceof ActionContributionItem) { IAction action = ((ActionContributionItem)contributionItem).getAction(); if (actions.contains(action)) { manager.remove(contributionItem); } } } } }
/** * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { if (actions != null) { IContributionItem[] items = manager.getItems(); for (int i = 0; i < items.length; i++) { // Look into SubContributionItems // IContributionItem contributionItem = items[i]; while (contributionItem instanceof SubContributionItem) { contributionItem = ((SubContributionItem) contributionItem) .getInnerItem(); } // Delete the ActionContributionItems with matching action. // if (contributionItem instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) contributionItem) .getAction(); if (actions.contains(action)) { manager.remove(contributionItem); } } } } }
/** * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.MenuManager}s and their * {@link org.eclipse.jface.action.ActionContributionItem}s based on the {@link org.eclipse.jface.action.IAction}s * contained in the <code>submenuActions</code> map. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected void depopulateManager ( IContributionManager manager, Map<String, Collection<IAction>> submenuActions ) { if ( submenuActions != null ) { IContributionItem[] items = manager.getItems (); for ( int i = 0; i < items.length; i++ ) { IContributionItem contributionItem = items[i]; if ( contributionItem instanceof MenuManager ) { MenuManager submenuManager = (MenuManager)contributionItem; if ( submenuActions.containsKey ( submenuManager.getMenuText () ) ) { depopulateManager ( submenuManager, submenuActions.get ( contributionItem ) ); manager.remove ( contributionItem ); } } } } }
@Override protected IContributionItem[] getContributionItems () { final ISelectionService ss = this.serviceLocator.getService ( ISelectionService.class ); if ( ss == null ) { return new IContributionItem[0]; } final ISelection sel = ss.getSelection (); final List<IContributionItem> items = new LinkedList<> (); addFromFileResource ( items, sel ); return items.toArray ( new IContributionItem[items.size ()] ); }
@Override protected void doItemFill(IContributionItem ci, int index) { StructuredSelection s=(StructuredSelection)SubJobUtility.getCurrentEditor().getViewer().getSelection(); if (s.getFirstElement() instanceof ComponentEditPart && (StringUtils.equalsIgnoreCase(ci.getId(),team)|| StringUtils.equalsIgnoreCase(ci.getId(),replaceWith)|| StringUtils.equalsIgnoreCase(ci.getId(),separator))){ return; } if((StringUtils.equalsIgnoreCase(ci.getId(),runAs)|| StringUtils.equalsIgnoreCase(ci.getId(),debugAs)|| StringUtils.equalsIgnoreCase(ci.getId(),compareWith)|| StringUtils.equalsIgnoreCase(ci.getId(),validate))){ return ; } super.doItemFill(ci, index); }