]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/e4/ClosePartHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.workbench / src / org / simantics / workbench / internal / contributions / e4 / ClosePartHandler.java
1 package org.simantics.workbench.internal.contributions.e4;
2
3 import javax.inject.Inject;
4 import javax.inject.Named;
5
6 import org.eclipse.e4.core.di.annotations.CanExecute;
7 import org.eclipse.e4.core.di.annotations.Execute;
8 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
9 import org.eclipse.e4.ui.services.IServiceConstants;
10 import org.eclipse.e4.ui.workbench.modeling.EPartService;
11
12 public class ClosePartHandler {
13
14     @Inject
15     EPartService partService;
16
17     @CanExecute
18     public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {
19         if (activePart == null)
20             return false;
21         return activePart.isCloseable();
22     }
23
24     @Execute
25     public void closePart(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {
26         partService.hidePart(activePart);
27     }
28 }