public void addPerspective(MPerspective perspective) { application.getSnippets().add(perspective); createDescriptor(perspective); }
@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); }
public void restoreDefaultModel() { application.getTags().clear(); application.getPersistedState().clear(); application.getSnippets().clear(); application.getDescriptors().clear(); application.getChildren().clear(); application.getChildren().addAll(defaultWindows); }
private void copyPerspsToPreferences() { for (MUIElement snippet : application.getSnippets()) { if (snippet instanceof MPerspective) { MPerspective persp = (MPerspective) snippet; exportedPersps.add(persp); } } ignoreEvents = true; for (MPerspective persp : exportedPersps) { try { copyPerspToPreferences(persp); } catch (IOException e) { logger.error(e, String.format("Cannot save perspective \"%s\" to preferences", persp.getElementId())); //$NON-NLS-1$ } } ignoreEvents = false; }
private void addClosedPerspectives() { String perspProp = preferences.get(IWorkbenchConstants.TAG_PERSPECTIVES, null); if (perspProp == null) { return; } List<MUIElement> snippets = application.getSnippets(); for (String perspName : perspProp.split(" ")) { //$NON-NLS-1$ IMemento memento = null; try { memento = XMLMemento.createReadRoot(new StringReader(preferences.get(perspName + "_persp", ""))); //$NON-NLS-1$ //$NON-NLS-2$ } catch (WorkbenchException e) { WorkbenchPlugin.log("Loading custom perspective failed: " + perspName, e); //$NON-NLS-1$ } snippets.add(builderFactory.createPerspectiveBuilder(new PerspectiveReader(memento)).createPerspective()); } }
@PostConstruct void postConstruct(MApplication application) { IExtensionPoint point = extensionRegistry.getExtensionPoint("org.eclipse.ui.perspectives"); //$NON-NLS-1$ for (IConfigurationElement element : point.getConfigurationElements()) { String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); descriptors.put(id, new PerspectiveDescriptor(id, element)); } List<MUIElement> snippets = application.getSnippets(); for (MUIElement snippet : snippets) { if (snippet instanceof MPerspective) { MPerspective perspective = (MPerspective) snippet; String id = perspective.getElementId(); // See if the clone is customizing an a predefined perspective without changing its name PerspectiveDescriptor existingDescriptor = descriptors.get(id); if (existingDescriptor == null) { // A custom perspective with its own name. createDescriptor(perspective); } else { // A custom perspecitve with a name of a pre-defined perspective existingDescriptor.setHasCustomDefinition(true); } } } impExpHandlerContext = context.createChild(); impExpHandlerContext.set(PerspectiveRegistry.class, this); ContextInjectionFactory.make(ImportExportPespectiveHandler.class, impExpHandlerContext); }
for (MUIElement snippet : application.getSnippets()) { if (snippet instanceof MPerspective) { setPerspectiveIcon(perspectiveRegistry, (MPerspective) snippet);