Search in sources :

Example 11 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent in project perun by CESNET.

the class SuggestBox method addEventsToTextBox.

private void addEventsToTextBox() {
    class TextBoxEvents extends HandlesAllKeyEvents implements ValueChangeHandler<String> {

        public void onKeyDown(KeyDownEvent event) {
            switch(event.getNativeKeyCode()) {
                case KeyCodes.KEY_DOWN:
                    display.moveSelectionDown();
                    break;
                case KeyCodes.KEY_UP:
                    display.moveSelectionUp();
                    break;
                case KeyCodes.KEY_ENTER:
                case KeyCodes.KEY_TAB:
                    Suggestion suggestion = display.getCurrentSelection();
                    if (suggestion == null) {
                        display.hideSuggestions();
                    } else {
                        setNewSelection(suggestion);
                    }
                    break;
            }
            delegateEvent(SuggestBox.this, event);
        }

        public void onKeyPress(KeyPressEvent event) {
            delegateEvent(SuggestBox.this, event);
        }

        public void onKeyUp(KeyUpEvent event) {
            // After every user key input, refresh the popup's suggestions.
            refreshSuggestions();
            delegateEvent(SuggestBox.this, event);
        }

        public void onValueChange(ValueChangeEvent<String> event) {
            delegateEvent(SuggestBox.this, event);
        }
    }
    TextBoxEvents events = new TextBoxEvents();
    events.addKeyHandlersTo(box);
    box.addValueChangeHandler(events);
}
Also used : Suggestion(com.google.gwt.user.client.ui.SuggestOracle.Suggestion) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) HandlesAllKeyEvents(com.google.gwt.event.dom.client.HandlesAllKeyEvents) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)

Example 12 with KeyPressEvent

use of com.google.gwt.event.dom.client.KeyPressEvent 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 13 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 14 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 15 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)

Aggregations

KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)20 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)12 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 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)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 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