Java Code Examples for org.eclipse.e4.ui.model.application.ui.advanced.MPerspective#getElementId()
The following examples show how to use
org.eclipse.e4.ui.model.application.ui.advanced.MPerspective#getElementId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElexisFastViewUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * Transfer persisted state (incl. size) of fastview defined in perspective, to fastview * {@link MToolControl} defined in window. * * @param fromPerspective * @param toWindow */ public static void transferFastViewPersistedState(MPerspective fromPerspective, MTrimmedWindow toWindow){ EModelService modelService = getService(EModelService.class); String perspectiveId = fromPerspective.getElementId(); Optional<MToolControl> mToolControl = getFastViewToolControl(modelService, toWindow, perspectiveId, SideValue.BOTTOM); mToolControl.ifPresent(toolControl -> { Optional<MPartStack> mStack = getFastViewPartStack(fromPerspective); mStack.ifPresent(stack -> { if (stack.getPersistedState() != null && !stack.getPersistedState().isEmpty()) { for (String key : stack.getPersistedState().keySet()) { toolControl.getPersistedState().put(key, stack.getPersistedState().get(key)); } } }); }); }
Example 2
Source File: AutomaticSwitchPerspectivePartListener.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String getActivePerspectiveId(final MPart part) { if (part != null && part.getContext() != null) { final EModelService service = part.getContext().get(EModelService.class); final MWindow window = service.getTopLevelWindowFor(part); String activePerspective = null; final MPerspective selectedElement = service.getActivePerspective(window); if (selectedElement != null) { activePerspective = selectedElement.getElementId(); } return activePerspective; } return null; }
Example 3
Source File: PerspektiveImportHandler.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void switchToPerspectiveLegacy(MPerspective loadedPerspective, List<String> preLoadedFastViewIds){ EModelService modelService = getService(EModelService.class); EPartService partService = getService(EPartService.class); MApplication mApplication = getService(MApplication.class); MTrimmedWindow mWindow = (MTrimmedWindow) modelService.find("IDEWindow", mApplication); if (mWindow == null) { List<MWindow> windows = mApplication.getChildren(); if (!windows.isEmpty() && windows.get(0) instanceof MTrimmedWindow) { mWindow = (MTrimmedWindow) windows.get(0); } } MPerspective activePerspective = modelService.getActivePerspective(mWindow); MElementContainer<MUIElement> perspectiveParent = activePerspective.getParent(); List<String> fastViewIds = preLoadedFastViewIds; // add the loaded perspective and switch to it String id = loadedPerspective.getElementId(); Iterator<MUIElement> it = perspectiveParent.getChildren().iterator(); while (it.hasNext()) { MUIElement element = it.next(); if (id.equals(element.getElementId()) || element.getElementId().startsWith(id + ".<")) { it.remove(); } } perspectiveParent.getChildren().add(loadedPerspective); // add fast view for (String fastViewId : fastViewIds) { ElexisFastViewUtil.addToFastView(loadedPerspective.getElementId(), fastViewId); } // the workbench window must be on top - otherwise the exception 'Application does not have an active window' occurs PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().open(); partService.switchPerspective(loadedPerspective); }
Example 4
Source File: PerspectiveImportService.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private String getActivePerspectiveId(){ MPerspective mPerspective = getActivePerspective(); if (mPerspective != null) { return mPerspective.getElementId(); } return null; }
Example 5
Source File: ElexisFastViewUtil.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
/** * Changes the fastviews position from left trimbar to bottom trimbar */ private static void changeFastViewBarFromLeftToBottom(){ EModelService eModelService = getService(EModelService.class); MApplication mApplication = getService(MApplication.class); MTrimmedWindow mWindow = getCurrentWindow(eModelService, mApplication); if (mWindow != null) { MPerspective mPerspective = eModelService.getActivePerspective(mWindow); if (mPerspective != null) { String perspectiveId = mPerspective.getElementId(); Optional<MToolControl> mToolControl = getFastViewToolControl(eModelService, mWindow, perspectiveId, SideValue.BOTTOM); if (!mToolControl.isPresent()) { mToolControl = getFastViewToolControl(eModelService, mWindow, perspectiveId, SideValue.LEFT); mToolControl.ifPresent(toolControl -> { MTrimBar trimBarBottom = findTrimBar(eModelService, mWindow, SideValue.BOTTOM); if (trimBarBottom != null) { MToolControl copyToolcontrol = eModelService.createModelElement(MToolControl.class); copyToolcontrol.setElementId(toolControl.getElementId()); copyToolcontrol.setContributionURI( "bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.TrimStack"); copyToolcontrol.setToBeRendered(true); copyToolcontrol.setVisible(true); copyToolcontrol.getTags().add("TrimStack"); if (!hasFastViewPersistedState(mPerspective)) { copyToolcontrol.getPersistedState().put("YSize", "600"); } trimBarBottom.getChildren().add(0, copyToolcontrol); toolControl.setToBeRendered(false); toolControl.setVisible(false); toolControl.getParent().getChildren().remove(toolControl); toolControl.setParent(null); trimBarBottom.setVisible(true); trimBarBottom.setToBeRendered(true); } }); } else { mToolControl.get().setToBeRendered(true); } } } }
Example 6
Source File: PerspectiveImportService.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@SuppressWarnings("restriction") private IPerspectiveDescriptor importPerspectiveFromStream(InputStream in, IStateCallback iStateHandle, boolean openPerspectiveIfAdded) throws IOException{ MPerspective mPerspective = loadPerspectiveFromStream(in); if (mPerspective != null) { IPerspectiveRegistry iPerspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry(); // the perspective id to import String id = mPerspective.getElementId(); IPerspectiveDescriptor existingPerspectiveDescriptor = iPerspectiveRegistry.findPerspectiveWithId(id); // the active perspective id String activePerspectiveId = getActivePerspectiveId(); // check if the import should be done if (existingPerspectiveDescriptor == null || iStateHandle == null || iStateHandle.state(State.OVERRIDE)) { IPerspectiveDescriptor activePd = iPerspectiveRegistry.findPerspectiveWithId(activePerspectiveId); // delete if a perspective with the id already exists int idx = deletePerspective(id); // add the new perspective to the registry ((PerspectiveRegistry) iPerspectiveRegistry).addPerspective(mPerspective); IPerspectiveDescriptor createdPd = iPerspectiveRegistry.findPerspectiveWithId(id); if (createdPd != null) { ((PerspectiveDescriptor) createdPd).setHasCustomDefinition(false); //no original descriptor should exists } // check if the new perspective should be opened if (idx > -1 || openPerspectiveIfAdded) { openPerspective(createdPd); // there was already an opened active perspective switch back to it openPerspective(activePd); } return createdPd; } } return null; }