Search in sources :

Example 1 with KeyPressHandler

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

the class ProjectTagsScreen method onInitUI.

@Override
protected void onInitUI() {
    super.onInitUI();
    initPageHeader();
    prev = PagingHyperlink.createPrev();
    prev.setVisible(false);
    next = PagingHyperlink.createNext();
    next.setVisible(false);
    addPanel = new FlowPanel();
    Grid addGrid = new Grid(2, 2);
    addGrid.setStyleName(Gerrit.RESOURCES.css().addBranch());
    int texBoxLength = 50;
    nameTxtBox = new HintTextBox();
    nameTxtBox.setVisibleLength(texBoxLength);
    nameTxtBox.setHintText(AdminConstants.I.defaultTagName());
    nameTxtBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNewTag();
            }
        }
    });
    addGrid.setText(0, 0, AdminConstants.I.columnTagName() + ":");
    addGrid.setWidget(0, 1, nameTxtBox);
    irevTxtBox = new HintTextBox();
    irevTxtBox.setVisibleLength(texBoxLength);
    irevTxtBox.setHintText(AdminConstants.I.defaultRevisionSpec());
    irevTxtBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNewTag();
            }
        }
    });
    addGrid.setText(1, 0, AdminConstants.I.initialRevision() + ":");
    addGrid.setWidget(1, 1, irevTxtBox);
    addTag = new Button(AdminConstants.I.buttonAddTag());
    addTag.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            doAddNewTag();
        }
    });
    addPanel.add(addGrid);
    addPanel.add(addTag);
    tagTable = new TagsTable();
    delTag = new Button(AdminConstants.I.buttonDeleteTag());
    delTag.setStyleName(Gerrit.RESOURCES.css().branchTableDeleteButton());
    delTag.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tagTable.deleteChecked();
        }
    });
    HorizontalPanel buttons = new HorizontalPanel();
    buttons.setStyleName(Gerrit.RESOURCES.css().branchTablePrevNextLinks());
    buttons.add(delTag);
    buttons.add(prev);
    buttons.add(next);
    add(tagTable);
    add(buttons);
    add(addPanel);
}
Also used : HintTextBox(com.google.gerrit.client.ui.HintTextBox) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Button(com.google.gwt.user.client.ui.Button) Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 2 with KeyPressHandler

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

the class GlobalKey method initEvents.

private static void initEvents() {
    if (active == null) {
        DocWidget.get().addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                final KeyCommandSet s = active.live;
                if (s != active.all) {
                    active.live = active.all;
                    restoreTimer.cancel();
                }
                s.onKeyPress(event);
            }
        });
        restoreTimer = new Timer() {

            @Override
            public void run() {
                active.live = active.all;
            }
        };
        global = new State(null);
        active = global;
    }
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Timer(com.google.gwt.user.client.Timer)

Example 3 with KeyPressHandler

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

the class MyWatchedProjectsScreen method createWidgets.

protected void createWidgets() {
    nameBox = new RemoteSuggestBox(new ProjectNameSuggestOracle());
    nameBox.setVisibleLength(50);
    nameBox.setHintText(Util.C.defaultProjectName());
    nameBox.addSelectionHandler(new SelectionHandler<String>() {

        @Override
        public void onSelection(SelectionEvent<String> event) {
            doAddNew();
        }
    });
    filterTxt = new HintTextBox();
    filterTxt.setVisibleLength(50);
    filterTxt.setHintText(Util.C.defaultFilter());
    filterTxt.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doAddNew();
            }
        }
    });
    addNew = new Button(Util.C.buttonWatchProject());
    addNew.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            doAddNew();
        }
    });
    browse = new Button(Util.C.buttonBrowseProjects());
    browse.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            // under page header
            int top = grid.getAbsoluteTop() - 50;
            // Try to place it to the right of everything else, but not
            // right justified
            int left = 5 + Math.max(grid.getAbsoluteLeft() + grid.getOffsetWidth(), watchesTab.getAbsoluteLeft() + watchesTab.getOffsetWidth());
            projectsPopup.setPreferredCoordinates(top, left);
            projectsPopup.displayPopup();
        }
    });
    watchesTab = new MyWatchesTable();
    delSel = new Button(Util.C.buttonDeleteSshKey());
    delSel.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            watchesTab.deleteChecked();
        }
    });
}
Also used : HintTextBox(com.google.gerrit.client.ui.HintTextBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Button(com.google.gwt.user.client.ui.Button) ProjectNameSuggestOracle(com.google.gerrit.client.ui.ProjectNameSuggestOracle) RemoteSuggestBox(com.google.gerrit.client.ui.RemoteSuggestBox)

Example 4 with KeyPressHandler

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

the class CreateGroupScreen method addCreateGroupPanel.

private void addCreateGroupPanel() {
    VerticalPanel addPanel = new VerticalPanel();
    addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
    addPanel.add(new SmallHeading(AdminConstants.I.headingCreateGroup()));
    addTxt = new NpTextBox() {

        @Override
        public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            if (event.getTypeInt() == Event.ONPASTE) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        if (addTxt.getValue().trim().length() != 0) {
                            addNew.setEnabled(true);
                        }
                    }
                });
            }
        }
    };
    addTxt.sinkEvents(Event.ONPASTE);
    addTxt.setVisibleLength(60);
    addTxt.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doCreateGroup();
            }
        }
    });
    addPanel.add(addTxt);
    addNew = new Button(AdminConstants.I.buttonCreateGroup());
    addNew.setEnabled(false);
    addNew.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            doCreateGroup();
        }
    });
    addPanel.add(addNew);
    add(addPanel);
    new OnEditEnabler(addNew, addTxt);
}
Also used : SmallHeading(com.google.gerrit.client.ui.SmallHeading) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Button(com.google.gwt.user.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) OnEditEnabler(com.google.gerrit.client.ui.OnEditEnabler) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox)

Example 5 with KeyPressHandler

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

the class CreateProjectScreen method initCreateTxt.

private void initCreateTxt() {
    project = new NpTextBox() {

        @Override
        public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            if (event.getTypeInt() == Event.ONPASTE) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        if (project.getValue().trim().length() != 0) {
                            create.setEnabled(true);
                        }
                    }
                });
            }
        }
    };
    project.sinkEvents(Event.ONPASTE);
    project.setVisibleLength(50);
    project.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                doCreateProject();
            }
        }
    });
    new OnEditEnabler(create, project);
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) OnEditEnabler(com.google.gerrit.client.ui.OnEditEnabler) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox)

Aggregations

KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)20 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)20 BlurHandler (com.google.gwt.event.dom.client.BlurHandler)9 Test (org.junit.Test)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 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)4 Button (com.google.gwt.user.client.ui.Button)4 HintTextBox (com.google.gerrit.client.ui.HintTextBox)3 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)3 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)3 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 TextBox (org.gwtbootstrap3.client.ui.TextBox)3 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)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