private List<MPartStack> getPartStacks(MPerspective perspective) { if (perspective == null) { return Collections.emptyList(); } return modelService.findElements(perspective, null, MPartStack.class); }
/** * Return a parent context for this part. * * @param element * the part to start searching from * @return the parent's closest context, or global context if none in the * hierarchy */ protected IEclipseContext getContextForParent(MUIElement element) { return modelService.getContainingContext(element); }
private MPerspectiveStack createPerspectiveStack() { MPerspectiveStack perspStack = modelService .createModelElement(MPerspectiveStack.class); perspStack.setElementId("PerspectiveStack"); //$NON-NLS-1$ return perspStack; }
MUIElement findElement(MUIElement toSearch, String id) { List<Object> found = modelService.findElements(toSearch, id, null, null, EModelService.IN_ANY_PERSPECTIVE); if (found.size() > 0) return (MUIElement) found.get(0); MUIElement foundElement = modelService.find(id, toSearch); return foundElement; }
/** * 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); } }
MPlaceholder createPlaceHolder(String str, String label) { MPlaceholder placeholder = null; placeholder = modelService.createModelElement(MPlaceholder.class); placeholder.setElementId(str); if (modelService.getPartDescriptor(str) == null) { placeholder.getTransientData().put(IWorkbenchConstants.TAG_LABEL, label); } return placeholder; }
MPerspective persp = modelService.getActivePerspective(win); boolean outsidePerspectives = (modelService.getElementLocation(element) & EModelService.OUTSIDE_PERSPECTIVE) != 0; List<MPartStack> stacks = modelService.findElements(win, null, MPartStack.class, minTag, EModelService.PRESENTATION); for (MPartStack theStack : stacks) { int stackLoc = modelService.getElementLocation(theStack); if ((stackLoc & EModelService.OUTSIDE_PERSPECTIVE) == 0) { continue; List<MPlaceholder> views = modelService.findElements(win, null, MPlaceholder.class, minTag, EModelService.PRESENTATION); for (MPlaceholder ph : views) { MPlaceholder eaPlaceholder = (MPlaceholder) modelService.find(ID_EDITOR_AREA, persp == null ? win : persp); if (element != eaPlaceholder && eaPlaceholder != null int loc = modelService.getElementLocation(element); if ((loc & EModelService.OUTSIDE_PERSPECTIVE) != 0) { List<MPerspectiveStack> psList = modelService.findElements(win, null, MPerspectiveStack.class); if (psList.size() == 1) { MPerspectiveStack perspStack = psList.get(0);
MPerspective persp = modelService.getActivePerspective(win); int loc = modelService.getElementLocation(element); if ((loc & EModelService.OUTSIDE_PERSPECTIVE) != 0) { List<MPerspectiveStack> pStacks = modelService.findElements(win, null, MPerspectiveStack.class); perspStack = (pStacks.size() > 0) ? pStacks.get(0) : null; } else { List<MPlaceholder> standaloneViews = modelService.findElements(persp == null ? win : persp, null, MPlaceholder.class, standaloneTag, EModelService.PRESENTATION); for (MPlaceholder part : standaloneViews) {
modelService.getTrim(model, SideValue.LEFT); modelService.getTrim(model, SideValue.RIGHT); mainMenu = modelService.createModelElement(MMenu.class); mainMenu.setElementId(ActionSet.MAIN_MENU); List<MPerspective> persps = modelService.findElements(model, null, MPerspective.class, null); if (persps.size() > 1) {
List<MPartStack> stacks = ms.findElements(ms.getTopLevelWindowFor(dragElement), MPartStack.class, EModelService.PRESENTATION, element -> { MPartStack stack = (MPartStack) element; && ms.countRenderableChildren(deParent) == 1) { return false;
public CoolBarToTrimManager(MApplication app, MTrimmedWindow window, List<MTrimElement> workbenchTrimElements, IRendererFactory rf) { application = app; this.window = window; rendererFactory = rf; this.workbenchTrimElements = workbenchTrimElements; toolbarExtensions = new ArrayList<>(); modelService = window.getContext().get(EModelService.class); topTrim = (MTrimBar) modelService.find(MAIN_TOOLBAR_ID, window); if (topTrim == null) { topTrim = modelService.getTrim(window, SideValue.TOP); topTrim.setElementId(MAIN_TOOLBAR_ID); } topTrim.setToBeRendered(false); MToolBar mToolBar = modelService.createModelElement(MToolBar.class); renderer = (ToolBarManagerRenderer) rendererFactory.getRenderer(mToolBar, null); }
private String getStackTrimLoc(MPartStack stack, String perspIdStr) { MWindow stackWin = modelService.getTopLevelWindowFor(stack);// getContainingWindow(stack); MUIElement tcElement = modelService.find(stack.getElementId() + perspIdStr, stackWin); if (tcElement == null) return ""; //$NON-NLS-1$ MTrimBar bar = (MTrimBar) ((MUIElement) tcElement.getParent()); int sideVal = bar.getSide().getValue(); int index = bar.getChildren().indexOf(tcElement); return stack.getElementId() + ' ' + sideVal + ' ' + index + "#"; //$NON-NLS-1$ } };
Class<T> clazz, int searchFlag, boolean allowSharedArea) { List<T> elementsToMinimize = new ArrayList<>(); List<T> elements = modelService.findElements(searchRoot, id, clazz, null, searchFlag); for (T element : elements) { if (element == elementToMaximize || !element.isToBeRendered()) { int loc = modelService.getElementLocation(element); boolean inSharedArea = loc == EModelService.IN_SHARED_AREA; boolean validLocation = allowSharedArea || !inSharedArea;
public MUIElement getActiveElement(IWorkbenchPartReference ref) { MUIElement element = null; MPerspective curPersp = modelService.getActivePerspective(window); if (curPersp == null) return null; MPlaceholder eaPH = (MPlaceholder) modelService.find(IPageLayout.ID_EDITOR_AREA, curPersp); MPart model = ((WorkbenchPartReference) ref).getModel(); MPlaceholder placeholder = model.getCurSharedRef(); switch (modelService.getElementLocation(placeholder == null ? model : placeholder)) { case EModelService.IN_ACTIVE_PERSPECTIVE: case EModelService.OUTSIDE_PERSPECTIVE: MUIElement parent = placeholder == null ? model.getParent() : placeholder.getParent(); if (parent instanceof MPartStack) { element = parent; } break; case EModelService.IN_SHARED_AREA: element = eaPH; break; } return element; }
if (window != null && isInContainer(window, perspective)) { perspective.getParent().setSelectedElement(perspective); List<MPart> newPerspectiveParts = modelService.findElements(perspective, null, MPart.class, null); modelService.bringToTop(target); activate(target, true, false); return; modelService.bringToTop(candidate); activate(candidate, true, false); return; modelService.bringToTop(perspective); perspective.getContext().activate(); } else { if ((modelService.getElementLocation(newActivePart) & EModelService.IN_SHARED_AREA) != 0) { if (newActivePart.getParent().getSelectedElement() != newActivePart) { newActivePart = (MPart) newActivePart.getParent().getSelectedElement();
/** * @param parent * @param toolControl */ private void createStatusLine(Composite parent, MToolControl toolControl) { IEclipseContext context = modelService.getContainingContext(toolControl); WorkbenchWindow wbw = (WorkbenchWindow) context.get(IWorkbenchWindow.class); // wbw may be null if workspace is started with no open perspectives. if (wbw == null) { // Create one assuming there's no defined perspective Workbench wb = (Workbench) PlatformUI.getWorkbench(); wb.createWorkbenchWindow(wb.getDefaultPageInput(), null, modelService.getTopLevelWindowFor(toolControl), false); wbw = (WorkbenchWindow) context.get(IWorkbenchWindow.class); } if (wbw != null) { Workbench wb = (Workbench) PlatformUI.getWorkbench(); wb.createWorkbenchWindow(wb.getDefaultPageInput(), null, modelService.getTopLevelWindowFor(toolControl), false); wbw = (WorkbenchWindow) context.get(IWorkbenchWindow.class); manager = wbw.getStatusLineManager(); manager.createControl(parent); } } }
private void updateNonFocusState(int event, MWindow win) { MPerspective perspective = modelService.getActivePerspective(win); if (perspective == null) { return; } List<MPartStack> stacks = modelService.findElements(perspective, null, MPartStack.class, Arrays.asList(CSSConstants.CSS_ACTIVE_CLASS)); if (stacks.isEmpty()) { return; } MPartStack stack = stacks.get(0); int tagsCount = stack.getTags().size(); boolean hasNonFocusTag = stack.getTags().contains( CSSConstants.CSS_NO_FOCUS_CLASS); if (event == SWT.Activate && hasNonFocusTag) { stack.getTags().remove(CSSConstants.CSS_NO_FOCUS_CLASS); } else if (event == SWT.Deactivate && !hasNonFocusTag) { stack.getTags().add(CSSConstants.CSS_NO_FOCUS_CLASS); } if (tagsCount != stack.getTags().size()) { setCSSInfo(stack, stack.getWidget()); } }
/** * @param dragElement * @param dropStack2 * @return */ private boolean crossSharedAreaBoundary(MUIElement dragElement, MPartStack dropStack) { EModelService ms = dndManager.getModelService(); boolean deNotInSA = (ms.getElementLocation(dragElement) & EModelService.IN_SHARED_AREA) == 0; boolean dsInSA = (ms.getElementLocation(dropStack) & EModelService.IN_SHARED_AREA) != 0; return deNotInSA && dsInSA; } }
private void create() { window = modelService.createModelElement(MTrimmedWindow.class); MTrimBar statusBar = modelService.getTrim((MTrimmedWindow) window, SideValue.BOTTOM); if (windowReader.hasStatusLine()) { MToolControl statusLine = modelService.createModelElement(MToolControl.class); statusLine.setElementId(WorkbenchWindow.STATUS_LINE_ID); statusLine.setContributionURI(WorkbenchWindow.TRIM_CONTRIBUTION_URI);
private void hideNonRestorableViews() { List<MPart> sharedPartsToRemove = new ArrayList<>(); List<MPlaceholder> phList = modelService .findElements(model, null, MPlaceholder.class, null); for (MPlaceholder ph : phList) { if (!(ph.getRef() instanceof MPart)) int vc = modelService.countRenderableChildren(phParent); if (vc == 0) { if (!isLastEditorStack(phParent))