Search in sources :

Example 1 with KeyCommandSet

use of com.google.gwtexpui.globalkey.client.KeyCommandSet in project gerrit by GerritCodeReview.

the class JumpKeys method register.

static void register(final Widget body) {
    final KeyCommandSet jumps = new KeyCommandSet();
    jumps.add(new KeyCommand(0, 'o', Gerrit.C.jumpAllOpen()) {

        @Override
        public void onKeyPress(final KeyPressEvent event) {
            Gerrit.display(PageLinks.toChangeQuery("status:open"));
        }
    });
    jumps.add(new KeyCommand(0, 'm', Gerrit.C.jumpAllMerged()) {

        @Override
        public void onKeyPress(final KeyPressEvent event) {
            Gerrit.display(PageLinks.toChangeQuery("status:merged"));
        }
    });
    jumps.add(new KeyCommand(0, 'a', Gerrit.C.jumpAllAbandoned()) {

        @Override
        public void onKeyPress(final KeyPressEvent event) {
            Gerrit.display(PageLinks.toChangeQuery("status:abandoned"));
        }
    });
    if (Gerrit.isSignedIn()) {
        jumps.add(new KeyCommand(0, 'i', Gerrit.C.jumpMine()) {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                Gerrit.display(PageLinks.MINE);
            }
        });
        jumps.add(new KeyCommand(0, 'd', Gerrit.C.jumpMineDrafts()) {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                Gerrit.display(PageLinks.toChangeQuery("owner:self is:draft"));
            }
        });
        jumps.add(new KeyCommand(0, 'c', Gerrit.C.jumpMineDraftComments()) {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                Gerrit.display(PageLinks.toChangeQuery("has:draft"));
            }
        });
        jumps.add(new KeyCommand(0, 'w', Gerrit.C.jumpMineWatched()) {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                Gerrit.display(PageLinks.toChangeQuery("is:watched status:open"));
            }
        });
        jumps.add(new KeyCommand(0, 's', Gerrit.C.jumpMineStarred()) {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                Gerrit.display(PageLinks.toChangeQuery("is:starred"));
            }
        });
    }
    keys = new KeyCommandSet(Gerrit.C.sectionJumping());
    keys.add(new CompoundKeyCommand(0, 'g', "", jumps));
    bodyWidget = body;
    activeHandler = GlobalKey.add(body, keys);
}
Also used : CompoundKeyCommand(com.google.gwtexpui.globalkey.client.CompoundKeyCommand) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyCommandSet(com.google.gwtexpui.globalkey.client.KeyCommandSet) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand) CompoundKeyCommand(com.google.gwtexpui.globalkey.client.CompoundKeyCommand)

Example 2 with KeyCommandSet

use of com.google.gwtexpui.globalkey.client.KeyCommandSet 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 3 with KeyCommandSet

use of com.google.gwtexpui.globalkey.client.KeyCommandSet 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)

Aggregations

KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)3 KeyCommand (com.google.gwtexpui.globalkey.client.KeyCommand)3 KeyCommandSet (com.google.gwtexpui.globalkey.client.KeyCommandSet)3 CompoundKeyCommand (com.google.gwtexpui.globalkey.client.CompoundKeyCommand)1