void basic(VerticalLayout layout) {
    // BEGIN-EXAMPLE: component.select.twincolselect.basic
    // BOOK: components.selecting#twincolselect
    final TwinColSelect select = new TwinColSelect("Select Targets to Destroy");

    // Put some data in the select
    String planets[] = {
      "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"
    };
    for (int pl = 0; pl < planets.length; pl++) select.addItem(planets[pl]);

    // Preselect a few items
    HashSet<String> preselected = new HashSet<String>();
    Collections.addAll(preselected, "Venus", "Earth", "Mars");
    select.setValue(preselected);

    select.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 6081009810084203857L;

          public void valueChange(ValueChangeEvent event) {
            System.out.println(event.getProperty().getType().getName());
            if (event.getProperty().getValue() != null)
              System.out.println(event.getProperty().getValue().getClass().getName());
          }
        });
    select.setImmediate(true);

    layout.addComponent(select);
    // END-EXAMPLE: component.select.twincolselect.basic
  }
Пример #2
0
  /**
   * Sets the corresponding values of specific user to the dialog.
   *
   * @param selectedUser . User that locate in the row of User table in which has been pressed the
   *     button Change settings.
   */
  public void setSelectedUser(User selectedUser) {
    userFullName.setValue(selectedUser.getFullName());
    userName.setValue(selectedUser.getUsername());
    password.setValue("*****");
    passwordConfim.setValue("*****");
    userEmail.setValue(selectedUser.getEmail().toString());
    roleSelector.setValue(selectedUser.getRoles());

    selectUser = selectedUser;
  }
  void css(VerticalLayout layout) {
    // BEGIN-EXAMPLE: component.select.twincolselect.css
    // BOOK: components.selecting#twincolselect
    final TwinColSelect select = new TwinColSelect("Select Targets to Destroy");

    select.addStyleName("twincolselectexample");

    // Set the column captions (optional)
    select.setLeftColumnCaption("These are left");
    select.setRightColumnCaption("These are done for");

    // Put some data in the select
    String planets[] = {
      "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"
    };
    for (int pl = 0; pl < planets.length; pl++) select.addItem(planets[pl]);

    // Set the number of visible items
    select.setHeight("200px");
    select.setRows(6);

    // Set width by the number of character columns
    select.setColumns(10);

    // Preselect a few items
    HashSet<String> preselected = new HashSet<String>();
    Collections.addAll(preselected, "Venus", "Earth", "Mars");
    select.setValue(preselected);

    select.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 6081009810084203857L;

          public void valueChange(ValueChangeEvent event) {
            System.out.println(event.getProperty().getType().getName());
            if (event.getProperty().getValue() != null)
              System.out.println(event.getProperty().getValue().getClass().getName());
          }
        });
    select.setImmediate(true);

    layout.addComponent(select);
    // END-EXAMPLE: component.select.twincolselect.css
  }
Пример #4
0
 /* (non-Javadoc)
  * @see com.vaadin.ui.AbstractField#setInternalValue(java.lang.Object)
  */
 @Override
 protected void setInternalValue(Collect value) {
   selectField.setValue(new TreeSet<String>(value.getIncludeGroups()));
 }