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();
}
});
}
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;
}
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");
}
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);
}
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");
}
Aggregations