private static boolean containsMatching(List<MTrimElement> children, MTrimElement me) { for (MTrimElement element : children) { if (Util.equals(me.getElementId(), element.getElementId()) && element.getClass().isInstance(me) && (element instanceof MToolBarSeparator || element instanceof MToolBar)) { return true; } } return false; }
/** * This is a HACK ! Due to compatibility restrictions we have the case where * we <b>must</b> leave 'empty' toolbars in the trim. This code detects this * particular scenario and hides any TB's of this type... * * @param te * The proposed trim element * @return <code>true</code> iff this element represents an empty managed * TB. */ private boolean hideManagedTB(MTrimElement te) { if (!(te instanceof MToolBar) || !(te.getRenderer() instanceof ToolBarManagerRenderer)) return false; if (!(te.getWidget() instanceof Composite)) return false; Composite teComp = (Composite) te.getWidget(); Control[] kids = teComp.getChildren(); if (kids.length != 1 || !(kids[0] instanceof ToolBar)) return false; boolean barVisible = ((ToolBar) kids[0]).getItemCount() > 0; // HACK! The trim dragging code uses the visible attribute as well // this is a local 'lock' to prevent the layout from messing with it if (!te.getTags().contains("LockVisibility")) { //$NON-NLS-1$ te.setVisible(barVisible); } return !barVisible; }
private MTrimBar getTrim(MTrimElement te) { if (te == null) { return null; } MUIElement parentElement = te.getParent(); return (MTrimBar) (parentElement instanceof MTrimBar ? parentElement : null); }
@Override public void handleChildrenRemove(MTrimBar parent, Collection<MTrimElement> elements) { Iterator<MTrimElement> iterator = elements.iterator(); while (iterator.hasNext()) { MTrimElement element = iterator.next(); if (element.isToBeRendered() && element.getWidget() != null) { hideChild(parent, element); } } } }
if (item.getId().equals(toolBar.getElementId()) && toolBar.getTags().contains(TOOLBAR_SEPARATOR)) {
/** * Removes the IPresentationEngine.HIDDEN_EXPLICITLY from the trimbar * entries. Having a separate logic for toolbars and toolcontrols would be * confusing for the user, hence we remove this tag for both these types * * @param toolbarModel */ private void removeHiddenTags(MToolControl toolControl) { MWindow mWindow = modelService.getTopLevelWindowFor(toolControl); List<MTrimElement> trimElements = modelService.findElements(mWindow, null, MTrimElement.class, null); for (MTrimElement trimElement : trimElements) { trimElement.getTags().remove(IPresentationEngine.HIDDEN_EXPLICITLY); } }
@Override public boolean changed(IEclipseContext context) { if (!trimModel.isToBeRendered() || !trimModel.isVisible() || trimModel.getWidget() == null) { return false; } boolean rc = ContributionsAnalyzer.isVisible( contribution, eContext); for (MTrimElement child : toRemove) { child.setToBeRendered(rc); } return true; } });
@Override public void handleChildrenAddition(MTrimBar parent, Collection<MTrimElement> elements) { Iterator<MTrimElement> iterator = elements.iterator(); while (iterator.hasNext()) { MTrimElement element = iterator.next(); if (element.isToBeRendered()) { if (element.getWidget() == null) { engineCreateWidget(element); } else { childRendered(parent, element); } } } }
MTrimElement.class, null); for (MTrimElement mTrimElement : trimElements) { mTrimElement.getTags().remove(IPresentationEngine.HIDDEN_EXPLICITLY);
@Override public boolean changed(IEclipseContext context) { if (!trimModel.isToBeRendered() || !trimModel.isVisible() || trimModel.getWidget() == null) { return false; } boolean rc = ContributionsAnalyzer.isVisible( contribution, eContext); for (MTrimElement child : toRemove) { child.setToBeRendered(rc); } return true; } });
/** * This is a HACK ! Due to compatibility restrictions we have the case where * we <b>must</b> leave 'empty' toolbars in the trim. This code detects this * particular scenario and hides any TB's of this type... * * @param te * The proposed trim element * @return <code>true</code> iff this element represents an empty managed * TB. */ private boolean hideManagedTB(MTrimElement te) { if (!(te instanceof MToolBar) || !(te.getRenderer() instanceof ToolBarManagerRenderer)) return false; if (!(te.getWidget() instanceof Composite)) return false; Composite teComp = (Composite) te.getWidget(); Control[] kids = teComp.getChildren(); if (kids.length != 1 || !(kids[0] instanceof ToolBar)) return false; boolean barVisible = ((ToolBar) kids[0]).getItemCount() > 0; // HACK! The trim dragging code uses the visible attribute as well // this is a local 'lock' to prevent the layout from messing with it if (!te.getTags().contains("LockVisibility")) { //$NON-NLS-1$ te.setVisible(barVisible); } return !barVisible; }
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; }
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; }
for (MTrimBar bar : topWin.getTrimBars()) { for (MTrimElement item : bar.getChildren()) { String id = item.getElementId(); if (id != null) { existingToolbarIds.add(id);
for (MTrimBar bar : topWin.getTrimBars()) { for (MTrimElement item : bar.getChildren()) { String id = item.getElementId(); if (id != null) { existingToolbarIds.add(id);