org.eclipse.equinox.p2.metadata;bundle-version="2.3.100",
org.eclipse.equinox.p2.operations;bundle-version="2.4.200",
org.eclipse.e4.core.di,
- org.eclipse.e4.ui.services
+ org.eclipse.e4.ui.services,
+ org.eclipse.e4.core.commands
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.inject;version="1.0.0"
Bundle-ActivationPolicy: lazy
<elements xsi:type="menu:TrimContribution" xmi:id="_FIbzwB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.trimcontribution.mainToolbar" parentId="org.eclipse.ui.main.toolbar" positionInParent="after=additions">
<children xsi:type="menu:ToolBar" xmi:id="_KDVngB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.0">
<children xsi:type="menu:HandledToolItem" xmi:id="_KvxPsB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.new" label="%command.label.21" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/new_wiz.png" command="_hooiQB7QEeeC-JvycL9ysA"/>
- <children xsi:type="menu:HandledToolItem" xmi:id="_ARn5AB96EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.save" label="%command.label.22" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/save_edit.gif" command="_PkWcQB62EeePLJ5to5QrXQ"/>
+ <children xsi:type="menu:HandledToolItem" xmi:id="_hnQUcFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.save" label="%command.label.22" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/save_edit.gif" command="_X-56IFp0Eee4PsIXei-TMg"/>
</children>
</elements>
</fragments>
<elements xsi:type="commands:Command" xmi:id="_LVTo8B62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.close" commandName="%command.label"/>
<elements xsi:type="commands:Command" xmi:id="_MrLPsB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.closeAll" commandName="%command.label.0"/>
<elements xsi:type="commands:Command" xmi:id="_PkWcQB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.save" commandName="%command.label.1"/>
+ <elements xsi:type="commands:Command" xmi:id="_X-56IFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.save" commandName="%command.label.1"/>
<elements xsi:type="commands:Command" xmi:id="_RWLmQB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.saveAll" commandName="%command.label.2"/>
<elements xsi:type="commands:Command" xmi:id="_TvLd8B62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.exit" commandName="%command.label.5"/>
<elements xsi:type="commands:Command" xmi:id="_5pfmIB7DEeeRW_RHu3JLqQ" elementId="org.eclipse.ui.edit.undo" commandName="%command.label.6"/>
<elements xsi:type="commands:Handler" xmi:id="_uzAhUCRAEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.update.UpdateHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.update.UpdateHandler" command="_rSmScCQ8EeeKsvEah5BAoQ"/>
<elements xsi:type="commands:Handler" xmi:id="_nSIiECUKEeeHw5lTgGMs1Q" elementId="eu.etaxonomy.taxeditor.handler.OpenImportPreferenceHandler" command="_fdEqUCUKEeeHw5lTgGMs1Q"/>
<elements xsi:type="commands:Handler" xmi:id="_2fnUYCZ0EeeQLpuomSmVoQ" elementId="eu.etaxonomy.taxeditor.workbench.OpenPartHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenPartHandler" command="_hMjgECZsEeer_rabtodzWA"/>
+ <elements xsi:type="commands:Handler" xmi:id="_dBGosFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.SaveHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.SaveHandler" command="_X-56IFp0Eee4PsIXei-TMg"/>
</fragments>
</fragment:ModelFragments>
package eu.etaxonomy.taxeditor.workbench;
-import javax.inject.Named;
+import java.util.Collections;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.e4.core.commands.ECommandService;
+import org.eclipse.e4.core.commands.EHandlerService;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
-import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.ui.internal.e4.compatibility.CompatibilityPart;
public class SaveHandler {
@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, EPartService partService) {
- partService.savePart(activePart, false);
+ public void execute(EPartService partService, ECommandService commandService, EHandlerService handlerService) {
+ partService.getDirtyParts().forEach(mPart ->
+ {
+ if(mPart.getObject() instanceof CompatibilityPart){
+ //FIXME E4 remove when fully migrated
+ Command command = commandService.getCommand("org.eclipse.ui.file.save");
+ ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, Collections.EMPTY_MAP);
+ handlerService.executeHandler(parameterizedCommand);
+ }
+ else{
+ partService.savePart(mPart, false);
+ }
+ });
}
@CanExecute
- public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
- return activePart.isDirty();
+ public boolean canExecute(EPartService partService) {
+ return !partService.getDirtyParts().isEmpty();
}
}
\ No newline at end of file