Search in sources :

Example 1 with TextBoxBase

use of com.google.gwt.user.client.ui.TextBoxBase in project opennms by OpenNMS.

the class VSearchBox method onLoad.

@Override
public void onLoad() {
    m_componentHolder.clear();
    this.setStyleName("topology-search");
    final TextBoxBase textField = new TextBox();
    textField.setWidth("245px");
    textField.setStyleName("topology-search-box");
    textField.getElement().setAttribute("placeholder", "Search...");
    textField.setFocus(true);
    RemoteSuggestOracle oracle = new RemoteSuggestOracle();
    m_suggestBox = new SuggestBox(oracle, textField);
    m_suggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {

        @Override
        public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
            SearchSuggestion selectedItem = (SearchSuggestion) event.getSelectedItem();
            textField.setText("");
            m_connector.addToFocus(selectedItem);
        }
    });
    if (m_isMultiValued) {
        m_suggestBox.setStyleName("multivalue");
    }
    m_suggestBox.addStyleName("wideTextField");
    m_suggestBox.addSelectionHandler(this);
    m_suggestBox.addKeyUpHandler(this);
    m_componentHolder.setWidth("245px");
    m_componentHolder.add(m_suggestBox);
    if (m_focusedContainer == null) {
        m_focusedContainer = new VerticalPanel();
        m_scrollContainer = new FlowPanel();
        m_scrollContainer.add(m_focusedContainer);
    }
    m_focusedContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    m_focusedContainer.setTitle("Focused Vertices");
    m_componentHolder.add(m_scrollContainer);
    Timer timer = new Timer() {

        @Override
        public void run() {
            updateScrollPanelSize();
        }
    };
    timer.schedule(1000);
    m_windowResizeRegistration = Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            updateScrollPanelSize();
        }
    });
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase) ResizeEvent(com.google.gwt.event.logical.shared.ResizeEvent) SuggestBox(com.google.gwt.user.client.ui.SuggestBox) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) Timer(com.google.gwt.user.client.Timer) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 2 with TextBoxBase

use of com.google.gwt.user.client.ui.TextBoxBase in project gerrit by GerritCodeReview.

the class OnEditEnabler method on.

private void on(final GwtEvent<?> e) {
    if (widget.isEnabled() || !(e.getSource() instanceof FocusWidget) || !((FocusWidget) e.getSource()).isEnabled()) {
        if (e.getSource() instanceof ValueBoxBase) {
            final TextBoxBase box = ((TextBoxBase) e.getSource());
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    if (box.getValue().trim().equals(originalValue)) {
                        widget.setEnabled(false);
                    }
                }
            });
        }
        return;
    }
    if (e.getSource() instanceof TextBoxBase) {
        onTextBoxBase((TextBoxBase) e.getSource());
    } else {
        // For many widgets, we can assume that a change is an edit. If
        // a widget does not work that way, it should be special cased
        // above.
        widget.setEnabled(true);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ValueBoxBase(com.google.gwt.user.client.ui.ValueBoxBase) FocusWidget(com.google.gwt.user.client.ui.FocusWidget) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase)

Example 3 with TextBoxBase

use of com.google.gwt.user.client.ui.TextBoxBase in project rstudio by rstudio.

the class NewConnectionSnippetHost method createParameterizedUI.

private Grid createParameterizedUI(final NewConnectionInfo info) {
    final ArrayList<NewConnectionSnippetParts> snippetParts = parseSnippet(info.getSnippet());
    int visibleRows = snippetParts.size();
    int visibleParams = Math.min(visibleRows, maxRows_);
    // If we have a field that shares the first row, usually port:
    boolean hasSecondaryHeaderField = false;
    if (visibleParams >= 2 && snippetParts.get(0).getOrder() == snippetParts.get(1).getOrder()) {
        visibleRows--;
        visibleParams++;
        hasSecondaryHeaderField = true;
    }
    boolean showAdvancedButton = visibleRows > maxRows_;
    visibleRows = Math.min(visibleRows, maxRows_);
    final ArrayList<NewConnectionSnippetParts> secondarySnippetParts = new ArrayList<NewConnectionSnippetParts>(snippetParts.subList(visibleParams, snippetParts.size()));
    final Grid connGrid = new Grid(visibleRows + (showAdvancedButton ? 1 : 0), 4);
    connGrid.addStyleName(RES.styles().grid());
    connGrid.getCellFormatter().setWidth(0, 0, "150px");
    connGrid.getCellFormatter().setWidth(0, 1, "180px");
    connGrid.getCellFormatter().setWidth(0, 2, "60px");
    connGrid.getCellFormatter().setWidth(0, 3, "74px");
    for (int idxParams = 0, idxRow = 0; idxRow < visibleRows; idxParams++, idxRow++) {
        connGrid.getRowFormatter().setStyleName(idxRow, RES.styles().gridRow());
        final String key = snippetParts.get(idxParams).getKey();
        Label label = new Label(key + ":");
        label.addStyleName(RES.styles().label());
        connGrid.setWidget(idxRow, 0, label);
        connGrid.getRowFormatter().setVerticalAlign(idxRow, HasVerticalAlignment.ALIGN_TOP);
        String textboxStyle = RES.styles().textbox();
        if (idxRow == 0 && hasSecondaryHeaderField) {
            textboxStyle = RES.styles().firstTextbox();
        } else {
            connGrid.getCellFormatter().getElement(idxRow, 1).setAttribute("colspan", "4");
        }
        final TextBoxBase textboxBase;
        if (key.toLowerCase() == "parameters") {
            TextArea textarea = new TextArea();
            textarea.setVisibleLines(7);
            textarea.addStyleName(RES.styles().textarea());
            connGrid.setWidget(idxRow, 1, textarea);
            textboxBase = textarea;
        } else {
            TextBox textbox = new TextBox();
            textbox.setText(snippetParts.get(idxParams).getValue());
            textbox.addStyleName(textboxStyle);
            textboxBase = textbox;
        }
        connGrid.setWidget(idxRow, 1, textboxBase);
        textboxBase.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent arg0) {
                partsKeyValues_.put(key, textboxBase.getValue());
                updateCodePanel();
            }
        });
        if (idxRow == 0 && hasSecondaryHeaderField) {
            idxParams++;
            final String secondKey = snippetParts.get(idxParams).getKey();
            Label secondLabel = new Label(secondKey + ":");
            secondLabel.addStyleName(RES.styles().secondLabel());
            connGrid.setWidget(idxRow, 2, secondLabel);
            connGrid.getRowFormatter().setVerticalAlign(idxRow, HasVerticalAlignment.ALIGN_TOP);
            final TextBox secondTextbox = new TextBox();
            secondTextbox.setText(snippetParts.get(idxParams).getValue());
            secondTextbox.addStyleName(RES.styles().secondTextbox());
            connGrid.setWidget(idxRow, 3, secondTextbox);
            connGrid.getCellFormatter().getElement(idxRow, 3).setAttribute("colspan", "2");
            secondTextbox.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent arg0) {
                    partsKeyValues_.put(secondKey, secondTextbox.getValue());
                    updateCodePanel();
                }
            });
        }
    }
    if (showAdvancedButton) {
        ThemedButton pushButton = new ThemedButton("Advanced Options...", new ClickHandler() {

            public void onClick(ClickEvent event) {
                new NewConnectionSnippetDialog(new OperationWithInput<HashMap<String, String>>() {

                    @Override
                    public void execute(final HashMap<String, String> result) {
                        for (String key : result.keySet()) {
                            partsKeyValues_.put(key, result.get(key));
                        }
                        updateCodePanel();
                    }
                }, secondarySnippetParts, info).showModal();
            }
        });
        connGrid.getRowFormatter().setStyleName(visibleRows, RES.styles().lastRow());
        connGrid.getCellFormatter().getElement(visibleRows, 1).setAttribute("colspan", "4");
        connGrid.setWidget(visibleRows, 1, pushButton);
    }
    return connGrid;
}
Also used : TextArea(com.google.gwt.user.client.ui.TextArea) HashMap(java.util.HashMap) Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) Label(com.google.gwt.user.client.ui.Label) TextBox(com.google.gwt.user.client.ui.TextBox) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase) ThemedButton(org.rstudio.core.client.widget.ThemedButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Aggregations

TextBoxBase (com.google.gwt.user.client.ui.TextBoxBase)3 TextBox (com.google.gwt.user.client.ui.TextBox)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 Timer (com.google.gwt.user.client.Timer)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 FocusWidget (com.google.gwt.user.client.ui.FocusWidget)1 Grid (com.google.gwt.user.client.ui.Grid)1 Label (com.google.gwt.user.client.ui.Label)1 SuggestBox (com.google.gwt.user.client.ui.SuggestBox)1 TextArea (com.google.gwt.user.client.ui.TextArea)1 ValueBoxBase (com.google.gwt.user.client.ui.ValueBoxBase)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1