--- /dev/null
+package org.simantics.workbench.internal.contributions.e4;\r
+\r
+import org.eclipse.e4.core.di.annotations.CanExecute;\r
+import org.eclipse.e4.core.di.annotations.Execute;\r
+import org.eclipse.e4.ui.model.application.MApplication;\r
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;\r
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;\r
+import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;\r
+import org.eclipse.e4.ui.workbench.modeling.EModelService;\r
+import org.eclipse.e4.ui.workbench.modeling.EPartService;\r
+import org.simantics.ui.workbench.e4.E4WorkbenchUtils;\r
+\r
+public class ActivatePartHandler {\r
+\r
+ @CanExecute\r
+ public boolean canExecute(MApplication app, EModelService modelService) {\r
+ MPartStack partStack = E4WorkbenchUtils.getEditorPartStack(modelService, app);\r
+ if (partStack.getChildren().size() > 0)\r
+ return true;\r
+ return false;\r
+ }\r
+\r
+ @Execute\r
+ public void activatePart(MApplication app, EModelService modelService, EPartService partService) {\r
+ MPartStack partStack = E4WorkbenchUtils.getEditorPartStack(modelService, app);\r
+ MStackElement elem = partStack.getSelectedElement();\r
+ MPart part = (MPart) elem;\r
+ partService.activate(part);\r
+ }\r
+\r
+}\r