public void handleEvent(Event event) { Object changedObject = event.getProperty(EventTags.ELEMENT); // Only care about MPerspective id changes if (!(changedObject instanceof MPerspective)) return; MPerspective perspective = (MPerspective) changedObject; String newID = (String) event.getProperty(UIEvents.EventTags.NEW_VALUE); String oldID = (String) event.getProperty(UIEvents.EventTags.OLD_VALUE); // pattern is trimStackID(perspectiveID) newID = '(' + newID + ')'; oldID = '(' + oldID + ')'; // Search the trim for the window containing the perspective MWindow perspWin = modelService.getTopLevelWindowFor(perspective); if (perspWin == null) return; List<MToolControl> trimStacks = modelService.findElements(perspWin, null, MToolControl.class, null); for (MToolControl trimStack : trimStacks) { // Only care about MToolControls that are TrimStacks if (TrimStack.CONTRIBUTION_URI.equals(trimStack.getContributionURI())) trimStack.setElementId(trimStack.getElementId().replace(oldID, newID)); } } };
private MToolControl addTrimElement(MTrimBar bottomTrim, IConfigurationElement ice, String id, boolean isBefore, String relTo, String classSpec) { // is it already in the trim ? MUIElement existingTrim = modelService.find(id, bottomTrim); if (existingTrim != null) { iceMap.put((MToolControl) existingTrim, ice); return (MToolControl) existingTrim; } // Ok, create one but only if we can site it correctly int insertIndex = bottomTrim.getChildren().size(); if (relTo != null) { MUIElement foundRel = modelService.find(relTo, bottomTrim); if (foundRel == null) return null; insertIndex = bottomTrim.getChildren().indexOf(foundRel); if (!isBefore) insertIndex++; } MToolControl newTrimElement = modelService.createModelElement(MToolControl.class); newTrimElement.setElementId(id); newTrimElement.setToBeRendered(classSpec != null); if (classSpec != null) { newTrimElement .setContributionURI("bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.LegacyTrim"); //$NON-NLS-1$ } newTrimElement.setContributorURI(URIHelper.constructPlatformURI(ice.getContributor())); iceMap.put(newTrimElement, ice); bottomTrim.getChildren().add(insertIndex, newTrimElement); return newTrimElement; }
if (slElement == null) { slElement = modelService.createModelElement(MToolControl.class); slElement.setElementId(STATUS_LINE_ID); slElement.setContributionURI(TRIM_CONTRIBUTION_URI); bottomTrim.getChildren().add(slElement); if (hsElement == null) { hsElement = modelService.createModelElement(MToolControl.class); hsElement.setElementId("org.eclipse.ui.HeapStatus"); //$NON-NLS-1$ hsElement.setContributionURI(TRIM_CONTRIBUTION_URI); hsElement.getTags().add(IPresentationEngine.DRAGGABLE); if (pbElement == null) { pbElement = modelService.createModelElement(MToolControl.class); pbElement.setElementId("org.eclipse.ui.ProgressBar"); //$NON-NLS-1$ pbElement.getTags().add(IPresentationEngine.DRAGGABLE); pbElement.setContributionURI(TRIM_CONTRIBUTION_URI);
private MToolBarElement createToolControlAddition(IConfigurationElement element) { String id = MenuHelper.getId(element); MToolControl control = MenuFactoryImpl.eINSTANCE.createToolControl(); control.setElementId(id); control.setContributionURI(CompatibilityWorkbenchWindowControlContribution.CONTROL_CONTRIBUTION_URI); ControlContributionRegistry.add(id, element); control.setVisibleWhen(MenuHelper.getVisibleWhen(element)); createIdentifierTracker(control); return control; }
private MToolBarElement createToolDynamicAddition(IConfigurationElement element) { String id = MenuHelper.getId(element); MToolControl control = RenderedElementUtil.createRenderedToolBarElement(); control.setElementId(id); control.setContributionURI(CompatibilityWorkbenchWindowControlContribution.CONTROL_CONTRIBUTION_URI); ControlContributionRegistry.add(id, element); control.setVisibleWhen(MenuHelper.getVisibleWhen(element)); createIdentifierTracker(control); return control; }
trimStack.setElementId(trimStack.getElementId().replace(oldID, newID));
/** * Install the Intro Launch Bar into the provided window. * * @param window * the window to host the launch bar * @param modelRoot * the current intro configuration, with pages * @param element * the launch bar configuration * @return the launch bar instance */ public static IntroLaunchBar create(IWorkbenchWindow window, IntroModelRoot modelRoot, IntroLaunchBarElement element) { EModelService modelService = window.getService(EModelService.class); MTrimmedWindow trimmedWindow = window.getService(MTrimmedWindow.class); MToolControl trimControl = modelService.createModelElement(MToolControl.class); trimControl.setElementId(LAUNCHBAR_ID); trimControl.setContributionURI(BUNDLECLASS_URI); // Must record sufficient information so as to be able to obtain the // launch configuration on workspace restart trimControl.getPersistedState().put(INTRO_CONFIG_ID, modelRoot.getId()); trimControl.getPersistedState().put(LAST_PAGE_ID, modelRoot.getCurrentPageId()); trimControl.getTags().add(IPresentationEngine.DRAGGABLE); MTrimBar bar = modelService.getTrim(trimmedWindow, determineLocation(element)); bar.getChildren().add(trimControl); // should now be rendered return (IntroLaunchBar) trimControl.getObject(); }
if (windowReader.hasStatusLine()) { MToolControl statusLine = modelService.createModelElement(MToolControl.class); statusLine.setElementId(WorkbenchWindow.STATUS_LINE_ID); statusLine.setContributionURI(WorkbenchWindow.TRIM_CONTRIBUTION_URI); statusLine.getTags().add(TrimBarLayout.SPACER);
private void createTrim(MUIElement element, MPerspective perspective) { if (!(window instanceof MTrimmedWindow)) { return; } String trimStr = perspective.getPersistedState().get("trims"); //$NON-NLS-1$ MTrimmedWindow win = (MTrimmedWindow) window; // Is there already a TrimControl there ? String trimId = element.getElementId() + getMinimizedElementSuffix(perspective); MToolControl trimStack = (MToolControl) modelService.find(trimId, window); if (trimStack == null) { trimStack = MenuFactoryImpl.eINSTANCE.createToolControl(); trimStack.setElementId(trimId); trimStack.setContributionURI(TrimStack.CONTRIBUTION_URI); trimStack.getTags().add("TrimStack"); //$NON-NLS-1$ // Check if we have a cached location MTrimBar bar = getBarForElement(element, win, trimStr); int index = getIndex(element, trimStr); if (index == -1 || index >= bar.getChildren().size()) bar.getChildren().add(trimStack); else bar.getChildren().add(index, trimStack); bar.setVisible(true); } else { // get the parent trim bar, see bug 320756 MUIElement parent = trimStack.getParent(); parent.setVisible(true); trimStack.setToBeRendered(true); } }
if (spacerControl == null) { spacerControl = modelService.createModelElement(MToolControl.class); spacerControl.setElementId(PERSPECTIVE_SPACER_ID); spacerControl .setContributionURI("bundleclass://org.eclipse.e4.ui.workbench.renderers.swt/org.eclipse.e4.ui.workbench.renderers.swt.LayoutModifierToolControl"); //$NON-NLS-1$ switcherControl = modelService.createModelElement(MToolControl.class); switcherControl.setToBeRendered(getWindowConfigurer().getShowPerspectiveBar()); switcherControl.setElementId("PerspectiveSwitcher"); //$NON-NLS-1$ switcherControl.getTags().add(IPresentationEngine.DRAGGABLE); switcherControl.getTags().add("HIDEABLE"); //$NON-NLS-1$
trimStack.setElementId(trimId); trimStack.setContributionURI(TrimStack.CONTRIBUTION_URI); trimStack.getTags().add("TrimStack"); //$NON-NLS-1$
trimStack.setElementId(trimId); trimStack.setContributionURI(TrimStack.CONTRIBUTION_URI); trimStack.getTags().add("TrimStack"); //$NON-NLS-1$