com.vaadin.client.ui.VTextField Java Examples

The following examples show how to use com.vaadin.client.ui.VTextField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoCompleteTextFieldConnector.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void extend(final ServerConnector target) {
    textFieldWidget = (VTextField) ((ComponentConnector) target).getWidget();
    textFieldWidget.setImmediate(true);
    textFieldWidget.textChangeEventMode = "EAGER";
    panel.setWidget(select);
    panel.setStyleName("suggestion-popup");
    panel.setOwner(textFieldWidget);

    textFieldWidget.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(final KeyUpEvent event) {
            if (panel.isAttached()) {
                handlePanelEventDelegation(event);
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                rpc.executeQuery(textFieldWidget.getValue(), textFieldWidget.getCursorPos());
            } else {
                doAskForSuggestion();
            }
        }
    });
}
 
Example #2
Source File: SuggestionsSelectList.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds suggestions to the suggestion menu bar.
 * 
 * @param suggestions
 *            the suggestions to be added
 * @param textFieldWidget
 *            the text field which the suggestion is attached to to bring
 *            back the focus after selection
 * @param popupPanel
 *            pop-up panel where the menu bar is shown to hide it after
 *            selection
 * @param suggestionServerRpc
 *            server RPC to ask for new suggestion after a selection
 */
public void addItems(final List<SuggestTokenDto> suggestions, final VTextField textFieldWidget,
        final PopupPanel popupPanel, final TextFieldSuggestionBoxServerRpc suggestionServerRpc) {
    for (int index = 0; index < suggestions.size(); index++) {
        final SuggestTokenDto suggestToken = suggestions.get(index);
        final MenuItem mi = new MenuItem(suggestToken.getSuggestion(), true, new ScheduledCommand() {
            @Override
            public void execute() {
                final String tmpSuggestion = suggestToken.getSuggestion();
                final TokenStartEnd tokenStartEnd = tokenMap.get(tmpSuggestion);
                final String text = textFieldWidget.getValue();
                final StringBuilder builder = new StringBuilder(text);
                builder.replace(tokenStartEnd.getStart(), tokenStartEnd.getEnd() + 1, tmpSuggestion);
                textFieldWidget.setValue(builder.toString(), true);
                popupPanel.hide();
                textFieldWidget.setFocus(true);
                suggestionServerRpc.suggest(builder.toString(), textFieldWidget.getCursorPos());
            }
        });
        tokenMap.put(suggestToken.getSuggestion(),
                new TokenStartEnd(suggestToken.getStart(), suggestToken.getEnd()));
        Roles.getListitemRole().set(mi.getElement());
        WidgetUtil.sinkOnloadForImages(mi.getElement());
        addItem(mi);
    }
}
 
Example #3
Source File: CubaSuggestionFieldWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
public CubaSuggestionFieldWidget() {
    textField = GWT.create(VTextField.class);
    initTextField();

    suggestionsContainer = new SuggestionsContainer(this);
    suggestionsPopup = new CubaSuggestionFieldWidget.SuggestionPopup(suggestionsContainer);

    suggestionTimer = new CubaSuggestionFieldWidget.SuggestionTimer();
}