}
protected void registerEditorActionKeys(
final TargetContentsPresenter targetContentsPresenter) {
// Register shortcut CTRL+S to save as fuzzy
KeyShortcut saveFuzzyShortcut =
KeyShortcut.Builder.builder()
.addKey(new Keys(Keys.CTRL_KEY, 'S'))
.setContext(ShortcutContext.Edit)
.setDescription(messages.saveAsFuzzy())
.setPreventDefault(true).setStopPropagation(true)
.setHandler(new KeyShortcutEventHandler() {
@Override
public void onKeyShortcut(KeyShortcutEvent event) {
targetContentsPresenter
.saveAsFuzzy(targetContentsPresenter
.getCurrentTransUnitIdOrNull());
}
}).build();
keyShortcutPresenter.register(saveFuzzyShortcut);
KeyShortcutEventHandler saveAsApprovedKeyShortcutHandler =
new KeyShortcutEventHandler() {
@Override
public void onKeyShortcut(KeyShortcutEvent event) {
targetContentsPresenter.checkConfirmationBeforeSave();
}
};
KeyShortcut ctrlEnterShortcut =
KeyShortcut.Builder.builder()
.addKey(new Keys(Keys.CTRL_KEY, KeyCodes.KEY_ENTER))
.setContext(ShortcutContext.Edit)
.setDescription(messages.saveAsTranslated())
.setPreventDefault(true).setStopPropagation(true)
.setHandler(saveAsApprovedKeyShortcutHandler).build();
keyShortcutPresenter.register(ctrlEnterShortcut);
enterSavesApprovedShortcut =
KeyShortcut.Builder.builder()
.addKey(new Keys(Keys.NO_MODIFIER, KeyCodes.KEY_ENTER))
.setContext(ShortcutContext.Edit)
.setDescription(messages.saveAsTranslated())
.setPreventDefault(true).setStopPropagation(true)
.setHandler(saveAsApprovedKeyShortcutHandler).build();
if (configHolder.getState().isEnterSavesApproved()) {
enterSavesApprovedHandlerRegistration =
keyShortcutPresenter.register(enterSavesApprovedShortcut);
}
KeyShortcut copySourceShortcut =
KeyShortcut.Builder.builder()
.addKey(new Keys(Keys.ALT_KEY, 'G'))
.addAttentionKey(new Keys('G'))
.setContext(ShortcutContext.Edit)
.setDescription(messages.copyFromSource())
.setStopPropagation(true).setPreventDefault(true)
.setHandler(new KeyShortcutEventHandler() {
@Override
public void onKeyShortcut(KeyShortcutEvent event) {
targetContentsPresenter
.copySourceForActiveRow();
}
}).build();
keyShortcutPresenter.register(copySourceShortcut);
KeyShortcut switchEditorShortcut =
KeyShortcut.Builder.builder()
.addKey(new Keys(Keys.CTRL_ALT_KEYS, 'H'))
.addAttentionKey(new Keys('H'))
.setContext(ShortcutContext.Edit)
.setDescription(messages.switchBetweenEditor())