@Test public void testSetValue() { final List<String> values = new Lists.Builder<String>().add("value1").add("value2").add(VALUE).build(); final String[] varArgs = new String[values.size() - 1]; values.subList(1, values.size()).toArray(varArgs); when(widget.getItemCount()).thenReturn(values.size()); when(widget.getItemText(anyInt())).thenReturn(values.get(0), varArgs); domElement.setValue(VALUE); verify(widget).setSelectedIndex(values.indexOf(VALUE)); }
@Override public void setValue(final String value) { this.originalValue = value; for (int i = 0; i < widget.getItemCount(); i++) { if (Objects.equals(widget.getItemText(i), value)) { widget.setSelectedIndex(i); break; } } }
ListBoxDOMElement extends BaseDOMElement<String, ListBox> implements TakesValue<String>,
                                                                                  Focusable { @Override public void setValue(final String value) { this.originalValue = value; for (int i = 0; i < widget.getItemCount(); i++) { if (Objects.equals(widget.getItemText(i), value)) { widget.setSelectedIndex(i); break; } } } }
ListBoxDOMElement extends BaseDOMElement<String, ListBox> implements TakesValue<String>,
                                                                                  Focusable { @Override public void setValue(final String value) { this.originalValue = value; for (int i = 0; i < widget.getItemCount(); i++) { if (Objects.equals(widget.getItemText(i), value)) { widget.setSelectedIndex(i); break; } } } ListBoxDOMElement(final ListBox widget,
                             final GridLayer gridLayer,
                             final GridWidget gridWidget,
                             final SessionManager sessionManager,
                             final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                             final Function<GridCellTuple, Command> hasNoValueCommand,
                             final Function<GridCellValueTuple, Command> hasValueCommand); }
ListBoxDOMElement extends BaseDOMElement<String, ListBox> implements TakesValue<String>,
                                                                                  Focusable { @Override public void setValue(final String value) { this.originalValue = value; for (int i = 0; i < widget.getItemCount(); i++) { if (Objects.equals(widget.getItemText(i), value)) { widget.setSelectedIndex(i); break; } } } ListBoxDOMElement(final ListBox widget,
                             final GridLayer gridLayer,
                             final GridWidget gridWidget,
                             final SessionManager sessionManager,
                             final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                             final Function<GridCellTuple, Command> hasNoValueCommand,
                             final Function<GridCellValueTuple, Command> hasValueCommand); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override void initialise(final GridBodyCellRenderContext context); @Override @SuppressWarnings("unchecked") void flush(final String value); }
ListBoxDOMElement extends BaseDOMElement<String, ListBox> implements TakesValue<String>,
                                                                                  Focusable { @Override public void setValue(final String value) { this.originalValue = value; for (int i = 0; i < widget.getItemCount(); i++) { if (Objects.equals(widget.getItemText(i), value)) { widget.setSelectedIndex(i); break; } } } ListBoxDOMElement(final ListBox widget,
                             final GridLayer gridLayer,
                             final GridWidget gridWidget,
                             final SessionManager sessionManager,
                             final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                             final Function<GridCellTuple, Command> hasNoValueCommand,
                             final Function<GridCellValueTuple, Command> hasValueCommand); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override void initialise(final GridBodyCellRenderContext context); @Override @SuppressWarnings("unchecked") void flush(final String value);  }