Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.SelectElement


     * @see <a href="http://stackoverflow.com/questions/12494815/gwt-listbox-onmouseover-tooltip">Stack Overflow</a>
     */
    @Override
    public void setTitle(String title) {
        super.setTitle(title);
        SelectElement selectElement = SelectElement.as(this.getElement());
        NodeList<OptionElement> options = selectElement.getOptions();
        for (int i = 0; i < options.getLength(); i++) {
            options.getItem(i).setTitle(title);
        }
    }
View Full Code Here


  @Override
  public Object onBrowserEvent(Element parent, String value, Object viewData,
      NativeEvent event, ValueUpdater<String> valueUpdater) {
    String type = event.getType();
    if (valueUpdater != null && "change".equals(type)) {
      SelectElement select = parent.getFirstChild().cast();
      valueUpdater.update(options.get(select.getSelectedIndex()));
    }
    return viewData;
  }
View Full Code Here

      }
    });
  }

  private void setupLocaleSelect() {
    final SelectElement select = (SelectElement) Document.get().getElementById("lang");
    String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
    String[] localeNames = LocaleInfo.getAvailableLocaleNames();
    for (String locale : localeNames) {
      if (!DEFAULT_LOCALE.equals(locale)) {
        String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
        OptionElement option = Document.get().createOptionElement();
        option.setValue(locale);
        option.setText(displayName);
        select.add(option, null);
        if (locale.equals(currentLocale)) {
          select.setSelectedIndex(select.getLength() - 1);
        }
      }
    }
    EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

      @Override
      public boolean onChange(ChangeEvent event, Element context) {
        UrlBuilder builder = Location.createUrlBuilder().setParameter(
                "locale", select.getValue());
        Window.Location.replace(builder.buildString());
        localeService.storeLocale(select.getValue());
        return true;
      }
    });
  }
View Full Code Here

                              event,
                              valueUpdater );
        final String type = event.getType();
        if ( "change".equals( type ) ) {
            final Object key = context.getKey();
            final SelectElement select = parent.getFirstChild().cast();
            final String newValue = options.get( select.getSelectedIndex() );
            setViewData( key, newValue );
            finishEditing( parent,
                           newValue,
                           key,
                           valueUpdater );
View Full Code Here

   *
   * @param multiple true if multiple selection of options is allowed
   * @return the newly-created element
   */
  public static com.google.gwt.user.client.Element createSelect(boolean multiple) {
    SelectElement selectElement = Document.get().createSelectElement();
    selectElement.setMultiple(multiple);
    return selectElement.cast();
  }
View Full Code Here

   */
  public static void insertListItem(Element selectElem, String item,
      String value, int index) {
    assert !isPotential(selectElem) : "Cannot insert into a PotentialElement";

    SelectElement select = selectElem.<SelectElement> cast();
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setValue(value);

    if ((index == -1) || (index == select.getLength())) {
      select.add(option, null);
    } else {
      OptionElement before = select.getOptions().getItem(index);
      select.add(option, before);
    }
  }
View Full Code Here

   *          <code>&lt;option&gt;</code>; cannot be <code>null</code>
   * @param index the index at which to insert the child
   */
  public static void insertListItem(Element selectElem, String item,
      String value, int index) {
    SelectElement select = selectElem.<SelectElement> cast();
    OptionElement option = Document.get().createOptionElement();
    option.setText(item);
    option.setValue(value);

    if ((index == -1) || (index == select.getLength())) {
      select.add(option, null);
    } else {
      OptionElement before = select.getOptions().getItem(index);
      select.add(option, before);
    }
  }
View Full Code Here

   * @param value the item's value, to be submitted if it is part of a
   *          {@link FormPanel}.
   * @param index the index at which to insert it
   */
  public void insertItem(String item, Direction dir, String value, int index) {
    SelectElement select = getSelectElement();
    OptionElement option = Document.get().createOptionElement();
    setOptionText(option, item, dir);
    option.setValue(value);

    int itemCount = select.getLength();
    if (index < 0 || index > itemCount) {
      index = itemCount;
    }
    if (index == itemCount) {
      select.add(option, null);
    } else {
      OptionElement before = select.getOptions().getItem(index);
      select.add(option, before);
    }
  }
View Full Code Here

  }

  public void testNakedSet() {
    assertNull(subject.getValue());
   
    SelectElement elm = getSelect();
    assertEquals(0, elm.getLength());

    Foo barFoo = new Foo("bar");

    setAndCheck(barFoo);
   
    assertEquals(1, elm.getLength());
    assertEquals(renderer.render(barFoo), elm.getValue());
  }
View Full Code Here

      assertEquals("item text", box.getItemText(1));
    }
  }

  private void assertOptionText(String expected, ListBox listBox, int index) {
    SelectElement select = listBox.getElement().cast();
    assertEquals(expected, select.getOptions().getItem(index).getText());
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.SelectElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.