public TrimKey(MTrimContribution mc) { super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc .getVisibleWhen(), null); this.contribution = mc; mc.setWidget(this); }
private static void setSearchContribution(MApplication app, boolean enabled) { for (MTrimContribution contribution : app.getTrimContributions()) { if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$ .getElementId())) { // allows us to handle the case where someone opens a workspace // with Luna and then with Kepler contribution.setToBeRendered(enabled); } } }
public static void gatherTrimContributions(MTrimBar trimModel, List<MTrimContribution> trimContributions, String elementId, ArrayList<MTrimContribution> toContribute, ExpressionContext eContext) { if (elementId == null || elementId.length() == 0) { return; } for (MTrimContribution contribution : trimContributions) { String parentId = contribution.getParentId(); boolean filtered = isFiltered(trimModel, contribution); if (filtered || !elementId.equals(parentId) || !contribution.isToBeRendered()) { continue; } toContribute.add(contribution); } }
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); } }
public static boolean isVisible(MTrimContribution contribution, ExpressionContext eContext) { if (contribution.getVisibleWhen() == null) { return true; } return isVisible((MCoreExpression) contribution.getVisibleWhen(), eContext); }
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); toContribute.setWidget(null); result.add(toContribute);
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 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; }
toContribute.add(contribution); } else { if (contribution.getVisibleWhen() != null) { ctx.runAndTrack(new RunAndTrack() { @Override
toContribute.add(contribution); } else { if (contribution.getVisibleWhen() != null) { ctx.runAndTrack(new RunAndTrack() { @Override