]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/e4/ActivatePartHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.workbench / src / org / simantics / workbench / internal / contributions / e4 / ActivatePartHandler.java
1 package org.simantics.workbench.internal.contributions.e4;
2
3 import org.eclipse.e4.core.di.annotations.CanExecute;
4 import org.eclipse.e4.core.di.annotations.Execute;
5 import org.eclipse.e4.ui.model.application.MApplication;
6 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7 import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
8 import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
9 import org.eclipse.e4.ui.workbench.modeling.EModelService;
10 import org.eclipse.e4.ui.workbench.modeling.EPartService;
11 import org.simantics.ui.workbench.e4.E4WorkbenchUtils;
12
13 public class ActivatePartHandler {
14
15     @CanExecute
16     public boolean canExecute(MApplication app, EModelService modelService) {
17         MPartStack partStack = E4WorkbenchUtils.getEditorPartStack(modelService, app);
18         if (partStack.getChildren().size() > 0)
19             return true;
20         return false;
21     }
22
23     @Execute
24     public void activatePart(MApplication app, EModelService modelService, EPartService partService) {
25         MPartStack partStack = E4WorkbenchUtils.getEditorPartStack(modelService, app);
26         MStackElement elem = partStack.getSelectedElement();
27         MPart part = (MPart) elem;
28         partService.activate(part);
29     }
30
31 }