Search in sources :

Example 11 with TextBox

use of com.google.gwt.user.client.ui.TextBox 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 12 with TextBox

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

the class ProjectInfoScreen method getPluginConfigValues.

private Map<String, Map<String, ConfigParameterValue>> getPluginConfigValues() {
    Map<String, Map<String, ConfigParameterValue>> pluginConfigValues = new HashMap<>(pluginConfigWidgets.size());
    for (Entry<String, Map<String, HasEnabled>> e : pluginConfigWidgets.entrySet()) {
        Map<String, ConfigParameterValue> values = new HashMap<>(e.getValue().size());
        pluginConfigValues.put(e.getKey(), values);
        for (Entry<String, HasEnabled> e2 : e.getValue().entrySet()) {
            HasEnabled widget = e2.getValue();
            if (widget instanceof TextBox) {
                values.put(e2.getKey(), ConfigParameterValue.create().value(((TextBox) widget).getValue().trim()));
            } else if (widget instanceof CheckBox) {
                values.put(e2.getKey(), ConfigParameterValue.create().value(Boolean.toString(((CheckBox) widget).getValue())));
            } else if (widget instanceof ListBox) {
                ListBox listBox = (ListBox) widget;
                // the inherited value is at index 0,
                // if it is selected no value should be set on this project
                String value = listBox.getSelectedIndex() > 0 ? listBox.getValue(listBox.getSelectedIndex()) : null;
                values.put(e2.getKey(), ConfigParameterValue.create().value(value));
            } else if (widget instanceof StringListPanel) {
                values.put(e2.getKey(), ConfigParameterValue.create().values(((StringListPanel) widget).getValues(0).toArray(new String[] {})));
            } else {
                throw new UnsupportedOperationException("unsupported widget type");
            }
        }
    }
    return pluginConfigValues;
}
Also used : HasEnabled(com.google.gwt.user.client.ui.HasEnabled) HashMap(java.util.HashMap) ConfigParameterValue(com.google.gerrit.client.projects.ConfigInfo.ConfigParameterValue) TextBox(com.google.gwt.user.client.ui.TextBox) NpIntTextBox(com.google.gerrit.client.ui.NpIntTextBox) NpTextBox(com.google.gwtexpui.globalkey.client.NpTextBox) CheckBox(com.google.gwt.user.client.ui.CheckBox) AccessMap(com.google.gerrit.client.access.AccessMap) Map(java.util.Map) HashMap(java.util.HashMap) NativeMap(com.google.gerrit.client.rpc.NativeMap) ListBox(com.google.gwt.user.client.ui.ListBox) StringListPanel(com.google.gerrit.client.StringListPanel)

Example 13 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project gwt-test-utils by gwt-test-utils.

the class TextBoxTest method selectionRange.

@Test
public void selectionRange() {
    // Given
    TextBox t = new TextBox();
    t.setValue("0123456789");
    RootPanel.get().add(t);
    // When
    t.setSelectionRange(4, 3);
    // Then
    assertThat(t.getSelectionLength()).isEqualTo(3);
    assertThat(t.getSelectedText()).isEqualTo("456");
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox) Test(org.junit.Test)

Example 14 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project gwt-test-utils by gwt-test-utils.

the class TextBoxTest method maxLength.

@Test
public void maxLength() {
    // Given
    TextBox t = new TextBox();
    // Preconditions
    assertThat(t.getMaxLength()).isEqualTo(0);
    // When
    t.setMaxLength(10);
    // Then
    assertThat(t.getMaxLength()).isEqualTo(10);
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox) Test(org.junit.Test)

Example 15 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project gwt-test-utils by gwt-test-utils.

the class TextBoxTest method value.

@Test
public void value() {
    // Given
    TextBox t = new TextBox();
    // Preconditions
    assertThat(t.getValue()).isEqualTo("");
    // When
    t.setValue("value");
    // Then
    assertThat(t.getValue()).isEqualTo("value");
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox) Test(org.junit.Test)

Aggregations

TextBox (com.google.gwt.user.client.ui.TextBox)31 Test (org.junit.Test)10 Label (com.google.gwt.user.client.ui.Label)9 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)6 Grid (com.google.gwt.user.client.ui.Grid)4 HashMap (java.util.HashMap)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)2 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)2 HTML (com.google.gwt.user.client.ui.HTML)2 AttributeDefinition (cz.metacentrum.perun.webgui.model.AttributeDefinition)2 ThemedButton (org.rstudio.core.client.widget.ThemedButton)2 StringListPanel (com.google.gerrit.client.StringListPanel)1 AccessMap (com.google.gerrit.client.access.AccessMap)1