@Override public MPopupMenu getContextMenu(EModelService modelService, MApplication application, MPart part) { Optional<MUIElement> menu = application.getSnippets().stream().filter( e -> e instanceof MPopupMenu && ("editor.part.contextmenu").equals(e.getElementId()) ).findFirst(); return (MPopupMenu) menu.map( e -> modelService.cloneElement(e, null)).orElse(null); }
@Override public MPopupMenu getContextMenu(EModelService modelService, MApplication application, MPart part, Type type) { Optional<MUIElement> menu = application.getSnippets().stream().filter( e -> e instanceof MPopupMenu && ("editor.contextmenu."+type).equals(e.getElementId()) ).findFirst(); return (MPopupMenu) menu.map( e -> modelService.cloneElement(e, null)).orElse(null); }
private void copyPerspToPreferences(MPerspective persp) throws IOException { MPerspective perspClone = (MPerspective) modelService.cloneElement(persp, null); exportToolbarsLocation(perspClone); String perspAsString = perspToString(perspClone); preferences.put(perspClone.getLabel() + PERSPECTIVE_SUFFIX_4X, perspAsString); }
void splitPart(MPart partToSplit, boolean horizontal) { MElementContainer<MUIElement> parent = partToSplit.getParent(); int index = parent.getChildren().indexOf(partToSplit); MPart editorClone = (MPart) ms.cloneElement(partToSplit, null); MCompositePart compPart = createCompositePart(partToSplit); // Add the new composite part to the model compPart.getChildren().add(editorClone); compPart.setSelectedElement(editorClone); parent.getChildren().add(index, compPart); parent.setSelectedElement(compPart); // Now, add the original part into the composite int orientation = horizontal ? EModelService.ABOVE : EModelService.LEFT_OF; ms.insert(partToSplit, editorClone, orientation, 0.5f); ps.activate(partToSplit); } }
mperspective.setLabel(newDesc.getLabel()); sortedPerspectives.add(newDesc); modelService.cloneElement(mperspective, application); newDesc.setHasCustomDefinition(true); return newDesc;
@Override public void savePerspectiveAs(IPerspectiveDescriptor perspective) { MPerspective visiblePerspective = getPerspectiveStack().getSelectedElement(); // get the original perspective String originalPerspectiveId = visiblePerspective.getElementId(); IPerspectiveDescriptor originalPerspective = getWorkbenchWindow().getWorkbench() .getPerspectiveRegistry().findPerspectiveWithId(originalPerspectiveId); // remove it from our collection of previously opened perspectives sortedPerspectives.remove(originalPerspective); // append the saved perspective sortedPerspectives.add(perspective); visiblePerspective.setLabel(perspective.getLabel()); visiblePerspective.setTooltip(perspective.getLabel()); visiblePerspective.setElementId(perspective.getId()); MPerspective copy = (MPerspective) EcoreUtil.copy((EObject) visiblePerspective); List<MPlaceholder> elementsToHide = modelService.findElements(copy, null, MPlaceholder.class, null); for (MPlaceholder elementToHide : elementsToHide) { if (elementToHide.isToBeRendered() && elementToHide.getRef().getTags().contains(IPresentationEngine.NO_RESTORE)) { elementToHide.setToBeRendered(false); updateSelectionAndParentVisibility(elementToHide); } } // remove placeholder refs and save as snippet modelService.cloneElement(copy, application); if (perspective instanceof PerspectiveDescriptor) { ((PerspectiveDescriptor) perspective).setHasCustomDefinition(true); } UIEvents.publishEvent(UIEvents.UILifeCycle.PERSPECTIVE_SAVED, visiblePerspective); }