Search in sources :

Example 1 with KeyCommand

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

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

the class AccountDashboardScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    table = new ChangeTable() {

        {
            keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadSearch()) {

                @Override
                public void onKeyPress(final KeyPressEvent event) {
                    Gerrit.display(getToken());
                }
            });
        }
    };
    table.addStyleName(Gerrit.RESOURCES.css().accountDashboard());
    outgoing = new ChangeTable.Section();
    incoming = new ChangeTable.Section();
    closed = new ChangeTable.Section();
    String who = mine ? "self" : ownerId.toString();
    outgoing.setTitleWidget(new InlineHyperlink(Util.C.outgoingReviews(), PageLinks.toChangeQuery(queryOutgoing(who))));
    incoming.setTitleWidget(new InlineHyperlink(Util.C.incomingReviews(), PageLinks.toChangeQuery(queryIncoming(who))));
    incoming.setHighlightUnreviewed(mine);
    closed.setTitleWidget(new InlineHyperlink(Util.C.recentlyClosed(), PageLinks.toChangeQuery(queryClosed(who))));
    table.addSection(outgoing);
    table.addSection(incoming);
    table.addSection(closed);
    add(table);
    table.setSavePointerId("owner:" + ownerId);
}
Also used : KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) InlineHyperlink(com.google.gerrit.client.ui.InlineHyperlink) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand)

Example 3 with KeyCommand

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

the class PagedSingleListScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    prev = new Hyperlink(Util.C.pagedChangeListPrev(), true, "");
    prev.setVisible(false);
    next = new Hyperlink(Util.C.pagedChangeListNext(), true, "");
    next.setVisible(false);
    table = new ChangeTable() {

        {
            keysNavigation.add(new DoLinkCommand(0, 'p', Util.C.changeTablePagePrev(), prev), new DoLinkCommand(0, 'n', Util.C.changeTablePageNext(), next));
            keysNavigation.add(new DoLinkCommand(0, '[', Util.C.changeTablePagePrev(), prev), new DoLinkCommand(0, ']', Util.C.changeTablePageNext(), next));
            keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadSearch()) {

                @Override
                public void onKeyPress(final KeyPressEvent event) {
                    Gerrit.display(getToken());
                }
            });
        }
    };
    section = new ChangeTable.Section();
    table.addSection(section);
    table.setSavePointerId(anchorPrefix);
    add(table);
    final HorizontalPanel buttons = new HorizontalPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().changeTablePrevNextLinks());
    buttons.add(prev);
    buttons.add(next);
    add(buttons);
}
Also used : KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand) Hyperlink(com.google.gerrit.client.ui.Hyperlink)

Example 4 with KeyCommand

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

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

the class Header method setupPrevNextFiles.

void setupPrevNextFiles(CommentsCollections comments) {
    FileInfo prevInfo = null;
    FileInfo nextInfo = null;
    int currIndex = findCurrentFileIndex(files);
    for (int i = currIndex - 1; i >= 0; i--) {
        FileInfo curr = files.get(i);
        if (shouldSkipFile(curr, comments)) {
            continue;
        }
        prevInfo = curr;
        break;
    }
    for (int i = currIndex + 1; i < files.length(); i++) {
        FileInfo curr = files.get(i);
        if (shouldSkipFile(curr, comments)) {
            continue;
        }
        nextInfo = curr;
        break;
    }
    KeyCommand p = setupNav(prev, '[', PatchUtil.C.previousFileHelp(), prevInfo);
    KeyCommand n = setupNav(next, ']', PatchUtil.C.nextFileHelp(), nextInfo);
    if (p != null && n != null) {
        keys.pair(p, n);
    }
    nextPath = nextInfo != null ? nextInfo.path() : null;
}
Also used : FileInfo(com.google.gerrit.client.info.FileInfo) KeyCommand(com.google.gwtexpui.globalkey.client.KeyCommand)

Aggregations

KeyCommand (com.google.gwtexpui.globalkey.client.KeyCommand)8 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)7 KeyCommandSet (com.google.gwtexpui.globalkey.client.KeyCommandSet)3 FileInfo (com.google.gerrit.client.info.FileInfo)1 Hyperlink (com.google.gerrit.client.ui.Hyperlink)1 InlineHyperlink (com.google.gerrit.client.ui.InlineHyperlink)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 CompoundKeyCommand (com.google.gwtexpui.globalkey.client.CompoundKeyCommand)1