]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/e4/ClosePartHandler.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.workbench / src / org / simantics / workbench / internal / contributions / e4 / ClosePartHandler.java
diff --git a/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/e4/ClosePartHandler.java b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/e4/ClosePartHandler.java
new file mode 100644 (file)
index 0000000..96c4c71
--- /dev/null
@@ -0,0 +1,28 @@
+package org.simantics.workbench.internal.contributions.e4;\r
+\r
+import javax.inject.Inject;\r
+import javax.inject.Named;\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.ui.basic.MPart;\r
+import org.eclipse.e4.ui.services.IServiceConstants;\r
+import org.eclipse.e4.ui.workbench.modeling.EPartService;\r
+\r
+public class ClosePartHandler {\r
+\r
+    @Inject\r
+    EPartService partService;\r
+\r
+    @CanExecute\r
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {\r
+        if (activePart == null)\r
+            return false;\r
+        return activePart.isCloseable();\r
+    }\r
+\r
+    @Execute\r
+    public void closePart(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {\r
+        partService.hidePart(activePart);\r
+    }\r
+}\r