2 package eu
.etaxonomy
.taxeditor
.workbench
;
4 import java
.util
.Collections
;
6 import org
.eclipse
.core
.commands
.Command
;
7 import org
.eclipse
.core
.commands
.ParameterizedCommand
;
8 import org
.eclipse
.e4
.core
.commands
.ECommandService
;
9 import org
.eclipse
.e4
.core
.commands
.EHandlerService
;
10 import org
.eclipse
.e4
.core
.di
.annotations
.CanExecute
;
11 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
12 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
13 import org
.eclipse
.ui
.internal
.e4
.compatibility
.CompatibilityPart
;
15 public class SaveHandler
{
18 public void execute(EPartService partService
, ECommandService commandService
, EHandlerService handlerService
) {
19 partService
.getDirtyParts().forEach(mPart
->
21 if(mPart
.getObject() instanceof CompatibilityPart
){
22 //FIXME E4 remove when fully migrated
23 Command command
= commandService
.getCommand("org.eclipse.ui.file.save");
24 ParameterizedCommand parameterizedCommand
= ParameterizedCommand
.generateCommand(command
, Collections
.EMPTY_MAP
);
25 handlerService
.executeHandler(parameterizedCommand
);
28 partService
.savePart(mPart
, false);
35 public boolean canExecute(EPartService partService
) {
36 return !partService
.getDirtyParts().isEmpty();