2 package eu
.etaxonomy
.taxeditor
.workbench
;
4 import javax
.inject
.Named
;
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
;
12 import eu
.etaxonomy
.taxeditor
.workbench
.part
.ISelectionElementEditingPart
;
14 public class SaveHandler
{
17 public boolean canExecute(EPartService partService
) {
18 MPart activePart
= partService
.getActivePart();
22 boolean isSavable
= activePart
.isDirty();
24 if(activePart
.getObject() instanceof ISelectionElementEditingPart
){
25 MPart savablePart
= WorkbenchUtility
.findSavablePart((ISelectionElementEditingPart
) activePart
.getObject());
26 isSavable
= savablePart
.isDirty();
34 void execute(EPartService partService
, @Named(IServiceConstants
.ACTIVE_PART
) MPart part
) {
36 partService
.savePart(part
, false);
38 else if(part
.getObject() instanceof ISelectionElementEditingPart
){
39 MPart savablePart
= WorkbenchUtility
.findSavablePart((ISelectionElementEditingPart
) part
.getObject());
40 partService
.savePart(savablePart
, false);