You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TreeWideContent.java 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. package com.vaadin.tests.components.tree;
  2. import com.vaadin.annotations.Widgetset;
  3. import com.vaadin.data.TreeData;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.tests.components.AbstractTestUI;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.Tree;
  8. @Widgetset("com.vaadin.DefaultWidgetSet")
  9. public class TreeWideContent extends AbstractTestUI {
  10. @Override
  11. protected void setup(VaadinRequest request) {
  12. Tree<String> tree = new Tree<>();
  13. tree.setWidth("150px");
  14. tree.setHeight("100px");
  15. TreeData<String> data = new TreeData();
  16. data.addItem(null, "Foo");
  17. data.addItem("Foo", "Extra long text content that should be wider"
  18. + " than the allocated width of the Tree.");
  19. data.addItem(null, "Bar");
  20. data.addItem(null, "Baz");
  21. tree.setTreeData(data);
  22. // Expand the wide one initially.
  23. tree.expand("Foo");
  24. addComponent(tree);
  25. addComponent(new Button("Toggle auto recalc", event -> tree
  26. .setAutoRecalculateWidth(!tree.isAutoRecalculateWidth())));
  27. }
  28. }