commit a998e6a09635debf24e868706e181766bc34a941
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Tue Jun 27 14:32:37 2017 +0200

    ref #6596 Replace CTRL+S keybinding with our own binding
    
     - this is done via model processors
     - this allows to use our SaveHandler to handle all save events

diff --git a/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi b/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
index f9f298216..eed7cb39c 100644
--- a/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
+++ b/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
@@ -87,7 +87,6 @@
     <elements xsi:type="commands:Command" xmi:id="_CYHrgB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.export" commandName="%command.label.4"/>
     <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"/>
@@ -125,4 +124,12 @@
     <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>
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_Z4f0kFsaEeebk7BsM35KOg" featurename="children" parentElementId="org.eclipse.ui.contexts.dialogAndWindow">
+    <elements xsi:type="commands:BindingContext" xmi:id="_5pEDMFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.bindingcontext" name="Taxonomic Editor Keybinding Context"/>
+  </fragments>
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_9BSjQFsaEeebk7BsM35KOg" featurename="bindingTables" parentElementId="org.eclipse.e4.legacy.ide.application">
+    <elements xsi:type="commands:BindingTable" xmi:id="_-q2iEFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.bindingtable" bindingContext="_5pEDMFsaEeebk7BsM35KOg">
+      <bindings xmi:id="__6bTkFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.keybinding.save" keySequence="M1+S" command="_X-56IFp0Eee4PsIXei-TMg"/>
+    </elements>
+  </fragments>
 </fragment:ModelFragments>
diff --git a/eu.etaxonomy.taxeditor.workbench/plugin.xml b/eu.etaxonomy.taxeditor.workbench/plugin.xml
index 45b80bdf0..7600f4a5b 100644
--- a/eu.etaxonomy.taxeditor.workbench/plugin.xml
+++ b/eu.etaxonomy.taxeditor.workbench/plugin.xml
@@ -9,6 +9,17 @@
             apply="always"
             uri="fragment.e4xmi">
       </fragment>
+      <processor
+            apply="always"
+            beforefragment="false"
+            class="eu.etaxonomy.taxeditor.workbench.WorkbenchProcessor">
+         <element
+               id="org.eclipse.ui.contexts.window">
+         </element>
+         <element
+               id="eu.etaxonomy.taxeditor.workbench.keybinding.save">
+         </element>
+      </processor>
    </extension>
 
 </plugin>
diff --git a/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchProcessor.java b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchProcessor.java
new file mode 100644
index 000000000..b52408bae
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchProcessor.java
@@ -0,0 +1,41 @@
+package eu.etaxonomy.taxeditor.workbench;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.commands.MBindingTable;
+import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
+
+public class WorkbenchProcessor {
+
+    @Inject
+    @Named("org.eclipse.ui.contexts.window")
+    private MBindingTable bindingTable;
+
+    @Inject
+    @Named("eu.etaxonomy.taxeditor.workbench.keybinding.save")
+    private MKeyBinding saveBinding;
+
+
+    @Execute
+    public void execute() {
+        //swap legacy CTRL+S with the one defined in our model fragment
+        //to allow using our SaveHandler for all save actions
+        List<MKeyBinding> bindings = bindingTable.getBindings();
+        MKeyBinding legacySaveBinding = null;
+        for (MKeyBinding mKeyBinding : bindings) {
+            String keySequence = mKeyBinding.getKeySequence();
+            if(keySequence.equals("CTRL+S")){
+                legacySaveBinding = mKeyBinding;
+                break;
+            }
+        }
+        if(legacySaveBinding!=null){
+            bindings.remove(legacySaveBinding);
+        }
+        bindings.add(saveBinding);
+    }
+}
