1
|
package eu.etaxonomy.taxeditor.workbench;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import javax.inject.Inject;
|
6
|
import javax.inject.Named;
|
7
|
|
8
|
import org.eclipse.e4.core.di.annotations.Execute;
|
9
|
import org.eclipse.e4.ui.model.application.commands.MBindingTable;
|
10
|
import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
|
11
|
|
12
|
public class WorkbenchProcessor {
|
13
|
|
14
|
@Inject
|
15
|
@Named("org.eclipse.ui.contexts.window")
|
16
|
private MBindingTable bindingTable;
|
17
|
|
18
|
@Inject
|
19
|
@Named("eu.etaxonomy.taxeditor.workbench.keybinding.save")
|
20
|
private MKeyBinding saveBinding;
|
21
|
|
22
|
|
23
|
@Execute
|
24
|
public void execute() {
|
25
|
//swap legacy CTRL+S with the one defined in our model fragment
|
26
|
//to allow using our SaveHandler for all save actions
|
27
|
List<MKeyBinding> bindings = bindingTable.getBindings();
|
28
|
MKeyBinding legacySaveBinding = null;
|
29
|
for (MKeyBinding mKeyBinding : bindings) {
|
30
|
String keySequence = mKeyBinding.getKeySequence();
|
31
|
if(keySequence.equals("CTRL+S")){
|
32
|
legacySaveBinding = mKeyBinding;
|
33
|
break;
|
34
|
}
|
35
|
}
|
36
|
if(legacySaveBinding!=null){
|
37
|
bindings.remove(legacySaveBinding);
|
38
|
}
|
39
|
bindings.add(saveBinding);
|
40
|
}
|
41
|
}
|