private static String getToolbarLabel(MApplication application, String elementId) { String name; if (IWorkbenchActionConstants.TOOLBAR_FILE.equalsIgnoreCase(elementId)) { return WorkbenchMessages.WorkbenchWindow_FileToolbar; } if (IWorkbenchActionConstants.TOOLBAR_EDIT.equalsIgnoreCase(elementId)) { return WorkbenchMessages.WorkbenchWindow_EditToolbar; } if (IWorkbenchActionConstants.TOOLBAR_NAVIGATE.equalsIgnoreCase(elementId)) { return WorkbenchMessages.WorkbenchWindow_NavigateToolbar; } if (IWorkbenchActionConstants.TOOLBAR_HELP.equalsIgnoreCase(elementId)) { return WorkbenchMessages.WorkbenchWindow_HelpToolbar; } List<MTrimContribution> trimContributions = application.getTrimContributions(); for (MTrimContribution mtb : trimContributions) { for (MTrimElement e : mtb.getChildren()) { if (e.getElementId().equals(elementId)) { name = getTransientName(e); if (name != null) { return name; } } } } return null; }
continue; Object[] array = item.getChildren().toArray(); for (int c = 0; c < array.length; c++) { MTrimElement me = (MTrimElement) array[c]; if (!containsMatching(toContribute.getChildren(), me)) { toContribute.getChildren().add(me);
public static boolean processAddition(final MTrimBar trimBar, MTrimContribution contribution, List<MTrimElement> contributions, HashSet<String> existingToolbarIds) { int idx = getIndex(trimBar, contribution.getPositionInParent()); if (idx == -1) { return false; } for (MTrimElement item : contribution.getChildren()) { if (item instanceof MToolBar && existingToolbarIds.contains(item.getElementId())) { // skip this, it's already there continue; } MTrimElement copy = (MTrimElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addTrimContribution " + copy, trimBar.getWidget(), trimBar); //$NON-NLS-1$ } trimBar.getChildren().add(idx++, copy); contributions.add(copy); if (copy instanceof MToolBar && copy.getElementId() != null) { existingToolbarIds.add(copy.getElementId()); } } return true; }
private void addTrimContribution(String idContrib, ArrayList<MToolBarContribution> contributions, ArrayList<MTrimContribution> trimContributions, IConfigurationElement element, String parentId, String tpath, String tgroup) { final String elementId = MenuHelper.getId(element); MTrimContribution trimContribution = MenuFactoryImpl.eINSTANCE.createTrimContribution(); trimContribution.getTags().add(ContributionsAnalyzer.MC_TOOLBAR); trimContribution.getTags().add("scheme:toolbar"); //$NON-NLS-1$ if (idContrib != null && idContrib.length() > 0) { trimContribution.setElementId(idContrib + "/" + elementId); //$NON-NLS-1$ } else { trimContribution.setElementId(elementId); } trimContribution.setParentId(parentId); trimContribution.setPositionInParent("after=additions"); //$NON-NLS-1$ trimContribution.setVisibleWhen(createVisibleWhen()); MToolBar tb = MenuFactoryImpl.eINSTANCE.createToolBar(); tb.setElementId(tpath); tb.getTransientData().put("Name", MenuHelper.getLabel(this.configElement)); //$NON-NLS-1$ tb.getTransientData().put("ActionSet", id); //$NON-NLS-1$ trimContribution.getChildren().add(tb); trimContributions.add(trimContribution); }
private void processTrimChildren(ArrayList<MTrimContribution> trimContributions, ArrayList<MToolBarContribution> toolBarContributions, IConfigurationElement element) { IConfigurationElement[] toolbars = element .getChildren(IWorkbenchRegistryConstants.TAG_TOOLBAR); if (toolbars.length == 0) { return; } MTrimContribution trimContribution = MenuFactoryImpl.eINSTANCE.createTrimContribution(); String idContrib = MenuHelper.getId(configElement); if (idContrib != null && idContrib.length() > 0) { trimContribution.setElementId(idContrib); } String query = location.getQuery(); boolean hasAdditions = AFTER_ADDITIONS.equals(query); processTrimLocation(trimContribution); trimContribution.getTags().add("scheme:" + location.getScheme()); //$NON-NLS-1$ for (IConfigurationElement toolbar : toolbars) { MToolBar item = MenuFactoryImpl.eINSTANCE.createToolBar(); item.setElementId(MenuHelper.getId(toolbar)); item.getTransientData().put("Name", MenuHelper.getLabel(toolbar)); //$NON-NLS-1$ processToolbarChildren(toolBarContributions, toolbar, item.getElementId(), AFTER_ADDITIONS, false); trimContribution.getChildren().add(item); } if (hasAdditions) { trimContributions.add(0, trimContribution); } else { trimContributions.add(trimContribution); } }