Search in sources :

Example 11 with KeyUpEvent

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

the class ChooseFolderDialog method createMainWidget.

@Override
public Widget createMainWidget() {
    Widget mainWidget = super.createMainWidget();
    browser_.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            maybeInvalidateSelection();
        }
    });
    browser_.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {
            maybeInvalidateSelection();
        }
    });
    return mainWidget;
}
Also used : KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) Widget(com.google.gwt.user.client.ui.Widget) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)

Example 12 with KeyUpEvent

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

the class HelpPane method createSecondaryToolbar.

@Override
protected SecondaryToolbar createSecondaryToolbar() {
    SecondaryToolbar toolbar = new SecondaryToolbar();
    toolbar.addLeftPopupMenu(title_ = new Label(), history_.getMenu());
    if (isFindSupported()) {
        final SmallButton btnNext = new SmallButton(">", true);
        btnNext.setTitle("Find next (Enter)");
        btnNext.setVisible(false);
        btnNext.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                findNext();
            }
        });
        final SmallButton btnPrev = new SmallButton("<", true);
        btnPrev.setTitle("Find previous");
        btnPrev.setVisible(false);
        btnPrev.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                findPrev();
            }
        });
        findTextBox_ = new FindTextBox("Find in Topic");
        findTextBox_.setOverrideWidth(90);
        toolbar.addLeftWidget(findTextBox_);
        findTextBox_.addKeyUpHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                // ignore modifier key release
                if (event.getNativeKeyCode() == KeyCodes.KEY_CTRL || event.getNativeKeyCode() == KeyCodes.KEY_ALT || event.getNativeKeyCode() == KeyCodes.KEY_SHIFT) {
                    return;
                }
                WindowEx contentWindow = getContentWindow();
                if (contentWindow != null) {
                    // into the main content window
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
                        event.preventDefault();
                        event.stopPropagation();
                        if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE)
                            clearTerm();
                        contentWindow.focus();
                    } else {
                        // minimizing or maximizing the help pane
                        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                        // check for term
                        String term = findTextBox_.getValue().trim();
                        int modifier = KeyboardShortcut.getModifierValue(event.getNativeEvent());
                        boolean isShift = modifier == KeyboardShortcut.SHIFT;
                        // if there is a term then search for it
                        if (term.length() > 0) {
                            // make buttons visible
                            setButtonVisibility(true);
                            // perform the find (check for incremental)
                            if (isIncrementalFindSupported()) {
                                boolean incremental = !event.isAnyModifierKeyDown() && (event.getNativeKeyCode() != KeyCodes.KEY_ENTER);
                                performFind(term, !isShift, incremental);
                            } else {
                                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                                    performFind(term, !isShift, false);
                            }
                        } else // no term means clear term and remove selection
                        {
                            if (isIncrementalFindSupported()) {
                                clearTerm();
                                contentWindow.removeSelection();
                            }
                        }
                    }
                }
            }

            private void clearTerm() {
                findTextBox_.setValue("");
                setButtonVisibility(false);
            }

            private void setButtonVisibility(final boolean visible) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        btnNext.setVisible(visible);
                        btnPrev.setVisible(visible);
                    }
                });
            }
        });
        findTextBox_.addKeyDownHandler(new KeyDownHandler() {

            @Override
            public void onKeyDown(KeyDownEvent event) {
                // from handling them
                if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB || event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                    event.preventDefault();
                    event.stopPropagation();
                }
            }
        });
        if (isIncrementalFindSupported()) {
            btnPrev.getElement().getStyle().setMarginRight(3, Unit.PX);
            toolbar.addLeftWidget(btnPrev);
            toolbar.addLeftWidget(btnNext);
        }
    }
    return toolbar;
}
Also used : KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) NativeKeyDownEvent(org.rstudio.core.client.events.NativeKeyDownEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SmallButton(org.rstudio.core.client.widget.SmallButton) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar) WindowEx(org.rstudio.core.client.dom.WindowEx) FindTextBox(org.rstudio.core.client.widget.FindTextBox)

Example 13 with KeyUpEvent

use of com.google.gwt.event.dom.client.KeyUpEvent 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 14 with KeyUpEvent

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

the class AddMemberToGroupTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add member(s)");
    // MAIN PANEL
    final VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    boolean isMembersGroup = group.isCoreGroup();
    // if members or admins group, hide
    if (isMembersGroup) {
        firstTabPanel.add(new HTML("<p>Group \"" + group.getName() + "\" can't have members managed from Group admin. Please use VO admin section.</p>"));
        this.contentWidget.setWidget(firstTabPanel);
        return getWidget();
    }
    // MENU
    TabMenu tabMenu = new TabMenu();
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    // for resize
    final TabItem tab = this;
    // CALLBACKS
    // for both
    final FindCompleteRichMembers findMembers;
    // for both
    final GetCompleteRichMembers getAllMembers;
    // for VO/group admin differs search
    final FindCandidatesOrUsersToAddToVo findCandidatesOrUsersToAddToVo;
    // elements handled by callback events
    final CustomButton searchButton = new CustomButton("Search in VO", ButtonTranslation.INSTANCE.searchMemberInVo(), SmallIcons.INSTANCE.findIcon());
    final CustomButton searchGloballyButton = new CustomButton("Search globally", ButtonTranslation.INSTANCE.searchForMembersInExtSources(), SmallIcons.INSTANCE.findIcon());
    final CustomButton listAllButton = new CustomButton("List all VO members", ButtonTranslation.INSTANCE.listAllMembersInVo(), SmallIcons.INSTANCE.userGreenIcon());
    final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
    // search through whole VO
    findMembers = new FindCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, group.getVoId(), "", null);
    getAllMembers = new GetCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, group.getVoId(), null);
    if (session.isVoAdmin(group.getVoId())) {
        // will search vo ext sources and users
        findCandidatesOrUsersToAddToVo = new FindCandidatesOrUsersToAddToVo(group.getVoId(), 0, "", null);
    } else {
        // will search group ext sources only
        findCandidatesOrUsersToAddToVo = new FindCandidatesOrUsersToAddToVo(group.getVoId(), group.getId(), "", null);
    }
    final CellTable<Candidate> candidatesTable = findCandidatesOrUsersToAddToVo.getEmptyTable();
    final CellTable<RichMember> table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {

        // when user click on a row -> open new tab
        public void update(int index, RichMember object, RichMember value) {
            session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), groupId));
        }
    });
    final CustomButton inviteButton = new CustomButton("Invite selected", SmallIcons.INSTANCE.emailIcon());
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedMemberToGroup());
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        public void searchFor(String text) {
            searchString = text;
            findMembers.searchFor(searchString);
            search = true;
            searchCandidates = false;
            // remove previous table
            firstTabPanel.getWidget(2).removeFromParent();
            firstTabPanel.add(sp);
            UiElements.runResizeCommands(tab);
        }
    }, searchButton);
    searchBox.getTextBox().setText(searchString);
    // bind text box also to search globally
    searchBox.getTextBox().addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            if (!searchBox.getTextBox().getText().trim().isEmpty()) {
                searchGloballyButton.setEnabled(true);
            // do not trigger search on both !!
            } else {
                searchGloballyButton.setEnabled(false);
            }
        }
    });
    searchBox.getTextBox().addBlurHandler(new BlurHandler() {

        @Override
        public void onBlur(BlurEvent event) {
            // fake some meaningless KeyUpEvent
            DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN), searchBox.getTextBox());
        }
    });
    searchBox.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            // fake some meaningless KeyUpEvent
            DomEvent.fireNativeEvent(Document.get().createKeyUpEvent(false, false, false, false, KeyCodes.KEY_DOWN), searchBox.getTextBox());
        }
    });
    // button click triggers action
    searchGloballyButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            if (UiElements.searchStingCantBeEmpty(searchBox.getTextBox().getText().trim())) {
                new PerunSearchEvent() {

                    public void searchFor(String text) {
                        searchString = text;
                        findCandidatesOrUsersToAddToVo.searchFor(searchString);
                        searchCandidates = true;
                        search = false;
                        // remove previous table
                        firstTabPanel.getWidget(2).removeFromParent();
                        firstTabPanel.add(sp2);
                        UiElements.runResizeCommands(tab);
                    }
                }.searchFor(searchBox.getTextBox().getText().trim());
            }
        }
    });
    searchGloballyButton.setEnabled(false);
    findMembers.setEvents(JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            listAllButton.setEnabled(true);
            searchGloballyButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
            ArrayList<RichMember> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                findMembers.getSelectionModel().setSelected(list.get(0), true);
            }
        }

        @Override
        public void onError(PerunError error) {
            listAllButton.setEnabled(true);
            searchGloballyButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            listAllButton.setEnabled(false);
            searchGloballyButton.setEnabled(false);
            disabled.setVisible(false);
            searchBox.getTextBox().setEnabled(false);
            addButton.setEnabled(false);
            inviteButton.setEnabled(false);
        }
    }));
    getAllMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // pass data to table handling callback
            findMembers.onFinished(jso);
            ((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("VO has no members.");
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onError(PerunError error) {
            // pass data to table handling callback
            findMembers.onError(error);
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            searchButton.setEnabled(false);
            disabled.setVisible(true);
            searchBox.getTextBox().setEnabled(false);
            addButton.setEnabled(false);
            inviteButton.setEnabled(false);
        }
    }));
    findCandidatesOrUsersToAddToVo.setEvents(JsonCallbackEvents.disableButtonEvents(searchGloballyButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            listAllButton.setEnabled(true);
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
            ArrayList<Candidate> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                findCandidatesOrUsersToAddToVo.setSelected(list.get(0));
            }
        }

        @Override
        public void onError(PerunError error) {
            listAllButton.setEnabled(true);
            searchButton.setEnabled(true);
            searchBox.getTextBox().setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            disabled.setVisible(false);
            listAllButton.setEnabled(false);
            searchButton.setEnabled(false);
            searchBox.getTextBox().setEnabled(false);
            addButton.setEnabled(false);
            inviteButton.setEnabled(false);
        }
    }));
    // DISABLED CHECKBOX
    disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
    disabled.setVisible(false);
    // checkbox click handler
    disabled.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            getAllMembers.excludeDisabled(!disabled.getValue());
            findMembers.clearTable();
            getAllMembers.retrieveData();
        }
    });
    listAllButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            search = false;
            searchCandidates = false;
            searchString = "";
            searchBox.getTextBox().setText("");
            findMembers.clearTable();
            findCandidatesOrUsersToAddToVo.clearTable();
            getAllMembers.retrieveData();
            // remove previous table
            firstTabPanel.getWidget(2).removeFromParent();
            firstTabPanel.add(sp);
            UiElements.runResizeCommands(tab);
        }
    });
    // click handler
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (searchCandidates) {
                // searched users or candidates
                Candidate candidateToBeAdded = findCandidatesOrUsersToAddToVo.getSelected();
                if (candidateToBeAdded == null) {
                    UiElements.cantSaveEmptyListDialogBox(null);
                } else {
                    if (candidateToBeAdded.getObjectType().equalsIgnoreCase("Candidate")) {
                        CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            private Candidate saveSelected;

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // put names to already added
                                if (saveSelected != null) {
                                    GeneralObject go = saveSelected.cast();
                                    alreadyAddedList.add(go);
                                }
                                findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                                rebuildAlreadyAddedWidget();
                                // clear search
                                searchBox.getTextBox().setText("");
                            }

                            @Override
                            public void onLoadingStart() {
                                saveSelected = findCandidatesOrUsersToAddToVo.getSelected();
                            }
                        }));
                        request.createMember(group.getVoId(), group, candidateToBeAdded);
                    } else {
                        CreateMember request = new CreateMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            private User saveSelected;

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // put names to already added
                                if (saveSelected != null) {
                                    GeneralObject go = saveSelected.cast();
                                    alreadyAddedList.add(go);
                                    findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                                    rebuildAlreadyAddedWidget();
                                    // clear search
                                    searchBox.getTextBox().setText("");
                                }
                            }

                            @Override
                            public void onLoadingStart() {
                                Candidate cand = findCandidatesOrUsersToAddToVo.getSelected();
                                saveSelected = cand.cast();
                            }
                        }));
                        User user = candidateToBeAdded.cast();
                        request.createMember(group.getVoId(), group, user);
                    }
                }
            } else {
                // searched members / all members
                final ArrayList<RichMember> membersToAdd = findMembers.getTableSelectedList();
                if (UiElements.cantSaveEmptyListDialogBox(membersToAdd)) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < membersToAdd.size(); i++) {
                        final int n = i;
                        AddMember request = new AddMember(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            private RichMember saveSelected;

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // unselect added person
                                findMembers.getSelectionModel().setSelected(saveSelected, false);
                                // put names to already added
                                GeneralObject go = saveSelected.cast();
                                alreadyAddedList.add(go);
                                rebuildAlreadyAddedWidget();
                                // clear search
                                searchBox.getTextBox().setText("");
                            }

                            @Override
                            public void onLoadingStart() {
                                saveSelected = membersToAdd.get(n);
                            }
                        }));
                        request.addMemberToGroup(group, membersToAdd.get(i));
                    }
                }
            }
        }
    });
    tabMenu.addWidget(searchGloballyButton);
    tabMenu.addWidget(listAllButton);
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(inviteButton);
    inviteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (searchCandidates) {
                // we expect, that candidate is always single
                Candidate candid = findCandidatesOrUsersToAddToVo.getSelected();
                if (candid != null) {
                    if (candid.getObjectType().equalsIgnoreCase("Candidate")) {
                        SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                            }
                        }));
                        invite.inviteUser(candid);
                    } else {
                        SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                findCandidatesOrUsersToAddToVo.clearTableSelectedSet();
                            }
                        }));
                        User user = candid.cast();
                        invite.inviteUser(user);
                    }
                }
            } else {
                // members / all members
                SendInvitation invite = new SendInvitation(group.getVoId(), groupId);
                ArrayList<RichMember> usrs = findMembers.getTableSelectedList();
                for (int i = 0; i < usrs.size(); i++) {
                    if (i == usrs.size() - 1) {
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                findMembers.clearTableSelectedSet();
                            }
                        }));
                    } else {
                        invite.setEvents(JsonCallbackEvents.disableButtonEvents(inviteButton));
                    }
                    invite.inviteUser(usrs.get(i).getUser());
                }
            }
        }
    });
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            // with refresh if somebody was added
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    tabMenu.addWidget(disabled);
    rebuildAlreadyAddedWidget();
    firstTabPanel.add(alreadyAdded);
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findMembers, table, addButton);
    inviteButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findMembers, table, inviteButton);
    JsonUtils.addTableManagedButton(findCandidatesOrUsersToAddToVo, candidatesTable, addButton);
    JsonUtils.addTableManagedButton(findCandidatesOrUsersToAddToVo, candidatesTable, inviteButton);
    table.addStyleName("perun-table");
    sp.setWidget(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    candidatesTable.addStyleName("perun-table");
    sp2.setWidget(candidatesTable);
    sp2.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp2, 350, this);
    // if not empty - start searching
    if (search) {
        findMembers.searchFor(searchString);
        firstTabPanel.add(sp);
    } else if (searchCandidates) {
        findCandidatesOrUsersToAddToVo.searchFor(searchString);
        firstTabPanel.add(sp2);
    } else {
        getAllMembers.excludeDisabled(!disabled.getValue());
        getAllMembers.retrieveData();
        firstTabPanel.add(sp);
    }
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) BlurHandler(com.google.gwt.event.dom.client.BlurHandler) User(cz.metacentrum.perun.webgui.model.User) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) CreateMember(cz.metacentrum.perun.webgui.json.membersManager.CreateMember) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddMember(cz.metacentrum.perun.webgui.json.groupsManager.AddMember) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject) Candidate(cz.metacentrum.perun.webgui.model.Candidate) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) RichMember(cz.metacentrum.perun.webgui.model.RichMember) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FindCandidatesOrUsersToAddToVo(cz.metacentrum.perun.webgui.json.vosManager.FindCandidatesOrUsersToAddToVo) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) SendInvitation(cz.metacentrum.perun.webgui.json.registrarManager.SendInvitation) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) PerunError(cz.metacentrum.perun.webgui.model.PerunError) FindCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers)

Example 15 with KeyUpEvent

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

the class CopyableLabel method showTextBox.

private void showTextBox() {
    if (textBox == null) {
        textBox = new TextBox();
        textBox.setText(getText());
        textBox.setVisibleLength(visibleLen);
        textBox.setReadOnly(true);
        textBox.addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(final KeyPressEvent event) {
                if (event.isControlKeyDown() || event.isMetaKeyDown()) {
                    switch(event.getCharCode()) {
                        case 'c':
                        case 'x':
                            textBox.addKeyUpHandler(new KeyUpHandler() {

                                @Override
                                public void onKeyUp(final KeyUpEvent event) {
                                    Scheduler.get().scheduleDeferred(new Command() {

                                        @Override
                                        public void execute() {
                                            hideTextBox();
                                        }
                                    });
                                }
                            });
                            break;
                    }
                }
            }
        });
        textBox.addBlurHandler(new BlurHandler() {

            @Override
            public void onBlur(final BlurEvent event) {
                hideTextBox();
            }
        });
        content.insert(textBox, 1);
    }
    textLabel.setVisible(false);
    textBox.setVisible(true);
    Scheduler.get().scheduleDeferred(new Command() {

        @Override
        public void execute() {
            textBox.selectAll();
            textBox.setFocus(true);
        }
    });
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) Command(com.google.gwt.user.client.Command) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) TextBox(com.google.gwt.user.client.ui.TextBox) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)

Aggregations

KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)17 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)15 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)5 BlurHandler (com.google.gwt.event.dom.client.BlurHandler)5 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)5 Label (com.google.gwt.user.client.ui.Label)5 NpTextBox (com.google.gwtexpui.globalkey.client.NpTextBox)5 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)4 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)3 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 PerunError (cz.metacentrum.perun.webgui.model.PerunError)2 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)2 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)2 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1