Search in sources :

Example 1 with KeyDownEvent

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

the class GlobalKey method dialog.

public static void dialog(final PopupPanel panel) {
    initEvents();
    initDialog();
    assert panel.isShowing();
    assert active == global;
    active = new State(panel);
    active.add(new HidePopupPanelCommand(0, KeyCodes.KEY_ESCAPE, panel));
    panel.addCloseHandler(restoreGlobal);
    panel.addDomHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
                panel.hide();
            }
        }
    }, KeyDownEvent.getType());
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler)

Example 2 with KeyDownEvent

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

the class Gerrit method whoAmI.

private static void whoAmI(boolean canLogOut) {
    AccountInfo account = getUserAccount();
    final UserPopupPanel userPopup = new UserPopupPanel(account, canLogOut, true);
    final FlowPanel userSummaryPanel = new FlowPanel();
    class PopupHandler implements KeyDownHandler, ClickHandler {

        private void showHidePopup() {
            if (userPopup.isShowing() && userPopup.isVisible()) {
                userPopup.hide();
            } else {
                userPopup.showRelativeTo(userSummaryPanel);
            }
        }

        @Override
        public void onClick(ClickEvent event) {
            showHidePopup();
        }

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                showHidePopup();
                event.preventDefault();
            }
        }
    }
    final PopupHandler popupHandler = new PopupHandler();
    final InlineLabel l = new InlineLabel(FormatUtil.name(account));
    l.setStyleName(RESOURCES.css().menuBarUserName());
    final AvatarImage avatar = new AvatarImage(account, 26, false);
    avatar.setStyleName(RESOURCES.css().menuBarUserNameAvatar());
    userSummaryPanel.setStyleName(RESOURCES.css().menuBarUserNamePanel());
    userSummaryPanel.add(l);
    userSummaryPanel.add(avatar);
    // "BLACK DOWN-POINTING SMALL TRIANGLE"
    userSummaryPanel.add(new InlineLabel(" ▾"));
    userPopup.addAutoHidePartner(userSummaryPanel.getElement());
    FocusPanel fp = new FocusPanel(userSummaryPanel);
    fp.setStyleName(RESOURCES.css().menuBarUserNameFocusPanel());
    fp.addKeyDownHandler(popupHandler);
    fp.addClickHandler(popupHandler);
    menuRight.add(fp);
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel) FocusPanel(com.google.gwt.user.client.ui.FocusPanel) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 3 with KeyDownEvent

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

the class NpIntTextBox method init.

private void init() {
    addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            int code = event.getNativeKeyCode();
            onKey(event, code, code);
        }
    });
    addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            int charCode = event.getCharCode();
            int keyCode = event.getNativeEvent().getKeyCode();
            onKey(event, charCode, keyCode);
        }
    });
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler)

Example 4 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent in project rstudio by rstudio.

the class FocusTransitionManager method register.

private void register(final Widget widget) {
    if (registration_.contains(widget))
        return;
    registration_.add(widget);
    widget.addDomHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
                boolean forward = !event.isShiftKeyDown();
                Widget target = get(widget, forward);
                if (target == null)
                    return;
                if (target instanceof CanFocus) {
                    event.stopPropagation();
                    event.preventDefault();
                    focus((CanFocus) target);
                } else if (target instanceof Focusable) {
                    event.stopPropagation();
                    event.preventDefault();
                    focus((Focusable) target);
                }
            }
        }
    }, KeyDownEvent.getType());
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) CanFocus(org.rstudio.core.client.widget.CanFocus) Widget(com.google.gwt.user.client.ui.Widget) Focusable(com.google.gwt.user.client.ui.Focusable)

Example 5 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent in project rstudio by rstudio.

the class VersionControlPage method onAddWidgets.

@Override
protected void onAddWidgets() {
    NewProjectResources.Styles styles = NewProjectResources.INSTANCE.styles();
    VerticalPanel urlPanel = new VerticalPanel();
    urlPanel.addStyleName(styles.wizardMainColumn());
    Label urlLabel = new Label("Repository URL:");
    urlLabel.addStyleName(styles.wizardTextEntryLabel());
    urlPanel.add(urlLabel);
    txtRepoUrl_ = new TextBox();
    txtRepoUrl_.addDomHandler(new KeyDownHandler() {

        public void onKeyDown(KeyDownEvent event) {
            handleAutoFillCheckoutDir();
        }
    }, KeyDownEvent.getType());
    txtRepoUrl_.setWidth("100%");
    urlPanel.add(txtRepoUrl_);
    addWidget(urlPanel);
    addSpacer();
    txtUsername_ = new TextBox();
    txtUsername_.setWidth("100%");
    if (includeCredentials()) {
        VerticalPanel usernamePanel = new VerticalPanel();
        usernamePanel.addStyleName(styles.wizardMainColumn());
        Label usernameLabel = new Label("Username (if required for this repository URL):");
        usernameLabel.addStyleName(styles.wizardTextEntryLabel());
        usernamePanel.add(usernameLabel);
        usernamePanel.add(txtUsername_);
        addWidget(usernamePanel);
        addSpacer();
    }
    Label dirNameLabel = new Label("Project directory name:");
    dirNameLabel.addStyleName(styles.wizardTextEntryLabel());
    addWidget(dirNameLabel);
    txtDirName_ = new TextBox();
    txtDirName_.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            if (!event.getValue().equals(guessRepoDir()))
                suppressDirNameDetection_ = true;
        }
    });
    txtDirName_.addStyleName(styles.wizardMainColumn());
    addWidget(txtDirName_);
    addSpacer();
    existingRepoDestDir_ = new DirectoryChooserTextBox("Create project as subdirectory of:", txtRepoUrl_);
    addWidget(existingRepoDestDir_);
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Label(com.google.gwt.user.client.ui.Label) TextBox(com.google.gwt.user.client.ui.TextBox) DirectoryChooserTextBox(org.rstudio.core.client.widget.DirectoryChooserTextBox) DirectoryChooserTextBox(org.rstudio.core.client.widget.DirectoryChooserTextBox)

Aggregations

KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)46 Test (org.junit.Test)30 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)15 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)5 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)3 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 FindTextBox (org.rstudio.core.client.widget.FindTextBox)3 NativeEvent (com.google.gwt.dom.client.NativeEvent)2 MouseDownEvent (com.google.gwt.event.dom.client.MouseDownEvent)2 MouseDownHandler (com.google.gwt.event.dom.client.MouseDownHandler)2 EventHandler (com.google.gwt.event.shared.EventHandler)2 CanFocus (org.rstudio.core.client.widget.CanFocus)2 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)2 ToolbarLabel (org.rstudio.core.client.widget.ToolbarLabel)2 RSConnectPublishButton (org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton)2 Transform (com.ait.lienzo.client.core.types.Transform)1