Search in sources :

Example 16 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.

the class ChangeScreen method registerKeys.

@Override
public void registerKeys() {
    super.registerKeys();
    KeyCommandSet keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
    keysNavigation.add(new KeyCommand(0, 'u', Util.C.upToChangeList()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            Gerrit.displayLastChangeList();
        }
    });
    keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadChange()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            Gerrit.display(PageLinks.toChange(changeId));
        }
    });
    keysNavigation.add(new KeyCommand(0, 'n', Util.C.keyNextPatchSet()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            gotoSibling(1);
        }
    }, new KeyCommand(0, 'p', Util.C.keyPreviousPatchSet()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            gotoSibling(-1);
        }
    });
    handlers.add(GlobalKey.add(this, keysNavigation));
    KeyCommandSet keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
    keysAction.add(new KeyCommand(0, 'a', Util.C.keyPublishComments()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (Gerrit.isSignedIn()) {
                onReply(null);
            } else {
                Gerrit.doSignIn(getToken());
            }
        }
    });
    keysAction.add(new KeyCommand(0, 'x', Util.C.keyExpandAllMessages()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            onExpandAll(null);
        }
    });
    keysAction.add(new KeyCommand(0, 'z', Util.C.keyCollapseAllMessages()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            onCollapseAll(null);
        }
    });
    keysAction.add(new KeyCommand(0, 's', Util.C.changeTableStar()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (Gerrit.isSignedIn()) {
                star.setValue(!star.getValue(), true);
            } else {
                Gerrit.doSignIn(getToken());
            }
        }
    });
    keysAction.add(new KeyCommand(0, 'c', Util.C.keyAddReviewers()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (Gerrit.isSignedIn()) {
                reviewers.onOpenForm();
            } else {
                Gerrit.doSignIn(getToken());
            }
        }
    });
    keysAction.add(new KeyCommand(0, 't', Util.C.keyEditTopic()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (Gerrit.isSignedIn()) {
                // differentiate F5 from 't' by checking the charCode(F5=0, t=116).
                if (event.getNativeEvent().getCharCode() == 0) {
                    Window.Location.reload();
                    return;
                }
                if (topic.canEdit()) {
                    topic.onEdit();
                }
            } else {
                Gerrit.doSignIn(getToken());
            }
        }
    });
    handlers.add(GlobalKey.add(this, keysAction));
    files.registerKeys();
}
Also used : KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyCommandSet(com.google.gwtexpui.globalkey.client.KeyCommandSet) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand)

Example 17 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.

the class Header method setupNav.

private KeyCommand setupNav(InlineHyperlink link, char key, String help, FileInfo info) {
    if (info != null) {
        final String url = url(info);
        link.setTargetHistoryToken(url);
        link.setTitle(PatchUtil.M.fileNameWithShortcutKey(FileInfo.getFileName(info.path()), Character.toString(key)));
        KeyCommand k = new KeyCommand(0, key, help) {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                Gerrit.display(url);
            }
        };
        keys.add(k);
        if (link == prev) {
            hasPrev = true;
        } else {
            hasNext = true;
        }
        return k;
    }
    link.getElement().getStyle().setVisibility(Visibility.HIDDEN);
    keys.add(new UpToChangeCommand(patchSetId, 0, key));
    return null;
}
Also used : KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand)

Example 18 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.

the class DiffScreen method registerKeys.

@Override
public void registerKeys() {
    super.registerKeys();
    keysNavigation.add(new UpToChangeCommand(revision, 0, 'u'));
    keysNavigation.add(new NoOpKeyCommand(0, 'j', PatchUtil.C.lineNext()), new NoOpKeyCommand(0, 'k', PatchUtil.C.linePrev()));
    keysNavigation.add(new NoOpKeyCommand(0, 'n', PatchUtil.C.chunkNext()), new NoOpKeyCommand(0, 'p', PatchUtil.C.chunkPrev()));
    keysNavigation.add(new NoOpKeyCommand(KeyCommand.M_SHIFT, 'n', PatchUtil.C.commentNext()), new NoOpKeyCommand(KeyCommand.M_SHIFT, 'p', PatchUtil.C.commentPrev()));
    keysNavigation.add(new NoOpKeyCommand(KeyCommand.M_CTRL, 'f', Gerrit.C.keySearch()));
    keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
    keysAction.add(new NoOpKeyCommand(0, KeyCodes.KEY_ENTER, PatchUtil.C.expandComment()));
    keysAction.add(new NoOpKeyCommand(0, 'o', PatchUtil.C.expandComment()));
    keysAction.add(new NoOpKeyCommand(KeyCommand.M_SHIFT, 'o', PatchUtil.C.expandAllCommentsOnCurrentLine()));
    if (Gerrit.isSignedIn()) {
        keysAction.add(new KeyCommand(0, 'r', PatchUtil.C.toggleReviewed()) {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                header.toggleReviewed().run();
            }
        });
        keysAction.add(new NoOpKeyCommand(KeyCommand.M_CTRL | KeyCommand.M_ALT, 'e', Gerrit.C.keyEditor()));
    }
    keysAction.add(new KeyCommand(KeyCommand.M_SHIFT, 'm', PatchUtil.C.markAsReviewedAndGoToNext()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            header.reviewedAndNext().run();
        }
    });
    keysAction.add(new KeyCommand(0, 'a', PatchUtil.C.openReply()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            upToChange(true).run();
        }
    });
    keysAction.add(new KeyCommand(0, ',', PatchUtil.C.showPreferences()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            prefsAction.show();
        }
    });
    if (getIntraLineStatus() == DiffInfo.IntraLineStatus.OFF || getIntraLineStatus() == DiffInfo.IntraLineStatus.OK) {
        keysAction.add(new KeyCommand(0, 'i', PatchUtil.C.toggleIntraline()) {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                toggleShowIntraline();
            }
        });
    }
    if (Gerrit.isSignedIn()) {
        keysAction.add(new NoOpKeyCommand(0, 'c', PatchUtil.C.commentInsert()));
        keysComment = new KeyCommandSet(PatchUtil.C.commentEditorSet());
        keysComment.add(new NoOpKeyCommand(KeyCommand.M_CTRL, 's', PatchUtil.C.commentSaveDraft()));
        keysComment.add(new NoOpKeyCommand(0, KeyCodes.KEY_ESCAPE, PatchUtil.C.commentCancelEdit()));
    } else {
        keysComment = null;
    }
}
Also used : KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyCommandSet(com.google.gwtexpui.globalkey.client.KeyCommandSet) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand)

Example 19 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.

the class SideBySide method registerKeys.

@Override
public void registerKeys() {
    super.registerKeys();
    getKeysNavigation().add(new NoOpKeyCommand(KeyCommand.M_SHIFT, KeyCodes.KEY_LEFT, PatchUtil.C.focusSideA()), new NoOpKeyCommand(KeyCommand.M_SHIFT, KeyCodes.KEY_RIGHT, PatchUtil.C.focusSideB()));
    getKeysAction().add(new KeyCommand(KeyCommand.M_SHIFT, 'a', PatchUtil.C.toggleSideA()) {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            diffTable.toggleA().run();
        }
    });
    registerHandlers();
}
Also used : KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand)

Aggregations

KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)19 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)11 KeyCommand (com.google.gwtexpui.globalkey.client.KeyCommand)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 Button (com.google.gwt.user.client.ui.Button)4 HintTextBox (com.google.gerrit.client.ui.HintTextBox)3 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)3 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 KeyCommandSet (com.google.gwtexpui.globalkey.client.KeyCommandSet)3 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 Event (com.google.gwt.user.client.Event)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 Grid (com.google.gwt.user.client.ui.Grid)2 TextBox (com.google.gwt.user.client.ui.TextBox)2 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)2