Search in sources :

Example 1 with OrionKeyStrokeOverlay

use of org.eclipse.che.ide.editor.orion.client.jso.OrionKeyStrokeOverlay in project che by eclipse.

the class OrionEditorWidget method addKeyBinding.

@Override
public void addKeyBinding(final KeyBinding keyBinding, String actionDescription) {
    OrionKeyStrokeOverlay strokeOverlay;
    JavaScriptObject keyBindingModule = moduleHolder.getModule("OrionKeyBinding").cast();
    String type = keyBinding.getType();
    boolean modifier1 = UserAgent.isMac() ? keyBinding.isCmd() : keyBinding.isControl();
    boolean modifier2 = keyBinding.isShift();
    boolean modifier3 = keyBinding.isAlt();
    boolean modifier4 = UserAgent.isMac() ? keyBinding.isControl() : false;
    if (keyBinding.isCharacterBinding()) {
        strokeOverlay = OrionKeyStrokeOverlay.create(keyBinding.getCharacter(), modifier1, modifier2, modifier3, modifier4, type, keyBindingModule);
    } else {
        strokeOverlay = OrionKeyStrokeOverlay.create(keyBinding.getKeyCodeNumber(), modifier1, modifier2, modifier3, modifier4, type, keyBindingModule);
    }
    String actionId = "che-action-" + keyBinding.getAction().toString();
    editorOverlay.getTextView().setKeyBinding(strokeOverlay, actionId);
    editorOverlay.getTextView().setAction(actionId, new Action() {

        @Override
        public boolean onAction() {
            return keyBinding.getAction().action();
        }
    }, actionDescription);
}
Also used : OrionKeyStrokeOverlay(org.eclipse.che.ide.editor.orion.client.jso.OrionKeyStrokeOverlay) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 OrionKeyStrokeOverlay (org.eclipse.che.ide.editor.orion.client.jso.OrionKeyStrokeOverlay)1