private void blinkTable() {
    final Table table = new Table();
    table.setPageLength(5);
    table.addContainerProperty(new Object(), String.class, null);

    for (int i = 0; i < 50; i++) {
      table.addItem(new Object[] {"Row"}, new Object());
    }

    System.out.println("adding component");
    addComponent(table);

    new Thread() {
      @Override
      public void run() {
        getSession().lock();
        try {
          Thread.sleep(500);
          access(
              new Runnable() {
                @Override
                public void run() {
                  System.out.println("removing component");
                  removeComponent(table);
                  button.setCaption(SUCCESS_CAPTION);
                }
              });
        } catch (InterruptedException e) {
          e.printStackTrace();
        } finally {
          getSession().unlock();
        }
      }
    }.start();
  }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
   * VaadinRequest)
   */
  @Override
  protected void setup(VaadinRequest request) {
    final Table table = new Table("Test table", buildContainer());
    table.setSizeFull();
    addComponent(table);
    Button sortButton =
        new Button(
            "Sort",
            new ClickListener() {

              @Override
              public void buttonClick(ClickEvent event) {
                table.sort(new Object[] {"val1"}, new boolean[] {false});
              }
            });
    addComponent(sortButton);
  }
コード例 #3
0
 @Override
 protected void setup() {
   final Table t = new Table();
   t.setContainerDataSource(getDS());
   t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
   t.setMultiSelect(true);
   t.setSelectable(true);
   t.setImmediate(true);
   t.addListener(
       new Property.ValueChangeListener() {
         @Override
         public void valueChange(ValueChangeEvent event) {
           Notification.show("Selected: " + event.getProperty());
         }
       });
   getLayout().addComponent(t);
 }
コード例 #4
0
  @Override
  protected void setup() {
    getLayout().setSizeFull();

    final Table table = new Table();
    table.setSizeFull();

    table.addContainerProperty("column1", String.class, "Humpty");
    table.addContainerProperty("column2", String.class, "Dumpty");
    table.addContainerProperty("column3", String.class, "Doe");

    for (int row = 0; row < 100; row++) {
      table.addItem();
    }

    HorizontalLayout buttons = new HorizontalLayout();
    for (Object col : table.getContainerPropertyIds()) {
      buttons.addComponent(createResetButton(col, table));
    }

    addComponent(table);
    addComponent(buttons);
  }
コード例 #5
0
  @Override
  protected void setup(VaadinRequest request) {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();

    final Table table = new Table();
    table.setColumnReorderingAllowed(true);
    table.setSizeFull();

    BeanItemContainer<TestItem> cont = new BeanItemContainer<>(TestItem.class);

    for (int i = 0; i < ROW_COUNT; i++) {
      TestItem ti = new TestItem();
      ti.setValue1("Value1_" + i);
      ti.setValue2("Value2_" + (ROW_COUNT - i));
      ti.setValue3("Value3_" + i);
      ti.setValue4("Value4_" + (ROW_COUNT - i));
      ti.setValue5("Value5_" + i);
      cont.addBean(ti);
    }

    table.setContainerDataSource(cont);
    table.setImmediate(true);
    table.setSelectable(true);
    table.setMultiSelect(false);

    table.setPageLength(10);
    table.setDragMode(Table.TableDragMode.ROW);

    table.setDropHandler(
        new DropHandler() {
          @Override
          public void drop(DragAndDropEvent dragAndDropEvent) {}

          @Override
          public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
          }
        });

    table.addColumnReorderListener(
        new ColumnReorderListener() {

          @Override
          public void columnReorder(ColumnReorderEvent event) {
            System.out.println("columnReorder");
          }
        });

    table.addHeaderClickListener(
        new HeaderClickListener() {

          @Override
          public void headerClick(HeaderClickEvent event) {
            System.out.println("Header was clicked");
          }
        });

    layout.addComponent(table);

    addComponent(layout);
  }
コード例 #6
0
  @Override
  protected void setup() {
    // Multiselect
    Table t = new Table("Multiselect");
    addComponent(t);
    t.setSelectable(false);
    t.setMultiSelect(true);
    t.setPageLength(5);
    t.addContainerProperty("Name", String.class, null);
    Set<Object> selected = new HashSet<>();
    for (int i = 0; i < 30; i++) {
      Item item = t.addItem(i);
      item.getItemProperty("Name").setValue("Name " + i);
      if (i % 2 == 0) {
        selected.add(i);
      }
    }
    t.setValue(selected);

    // Singleselect
    t = new Table("Singleselect");
    addComponent(t);
    t.setSelectable(false);
    t.setMultiSelect(false);
    t.setPageLength(5);
    t.addContainerProperty("Name", String.class, null);
    for (int i = 0; i < 30; i++) {
      Item item = t.addItem(i);
      item.getItemProperty("Name").setValue("Name " + i);
    }
    t.setValue(3);
  }