import com.vaadin.shared.ui.tree.TreeMultiSelectionModelState;
import com.vaadin.shared.ui.tree.TreeRendererState;
import com.vaadin.ui.Grid.SelectionMode;
+import com.vaadin.ui.components.grid.DescriptionGenerator;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.renderers.AbstractRenderer;
import com.vaadin.util.ReflectTools;
treeGrid.setStyleGenerator(styleGenerator);
}
+ /**
+ * Sets the description generator that is used for generating tooltip
+ * descriptions for items.
+ *
+ * @since
+ * @param descriptionGenerator
+ * the item description generator to set, or <code>null</code> to
+ * remove a previously set generator
+ */
+ public void setItemDescriptionGenerator(
+ DescriptionGenerator<T> descriptionGenerator) {
+ treeGrid.setDescriptionGenerator(descriptionGenerator);
+ }
+
/**
* Gets the item caption generator.
*
return treeGrid.getStyleGenerator();
}
+ /**
+ * Gets the item description generator.
+ *
+ * @since
+ * @return the item description generator
+ */
+ public DescriptionGenerator<T> getItemDescriptionGenerator() {
+ return treeGrid.getDescriptionGenerator();
+ }
+
/**
* Adds an item click listener. The listener is called when an item of this
* {@code Tree} is clicked.
package com.vaadin.tests.components.tree;
import java.util.Arrays;
-import java.util.Enumeration;
import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
import java.util.stream.Stream;
import com.vaadin.annotations.Theme;
MenuItem componentMenu = menu.addItem("Component", null);
createIconMenu(componentMenu.addItem("Icons", null));
createCaptionMenu(componentMenu.addItem("Captions", null));
+ createDescriptionMenu(componentMenu.addItem("Descriptions", null));
createContentModeMenu(componentMenu.addItem("ContentMode", null));
createSelectionModeMenu(componentMenu.addItem("Selection Mode", null));
createRowHeightMenu(componentMenu.addItem("Row Height", null));
});
}
+ private void createDescriptionMenu(MenuItem descriptionMenu) {
+ descriptionMenu.addItem("No Description", menu -> {
+ tree.setItemDescriptionGenerator(t -> null);
+ });
+ descriptionMenu.addItem("String.valueOf", menu -> {
+ tree.setItemDescriptionGenerator(String::valueOf);
+ });
+ }
+
private void createContentModeMenu(MenuItem contentModeMenu) {
Arrays.stream(ContentMode.values()).forEach(mode -> contentModeMenu
.addItem(mode.toString(), item -> tree.setContentMode(mode)));
.contains("height: " + height + "px;"));
});
}
+
+ @Test
+ public void tree_item_description() {
+ selectMenuPath("Component", "Descriptions", "String.valueOf");
+
+ $(TreeElement.class).first().getItem(0).showTooltip();
+ Assert.assertEquals("", "0 | 0", getTooltipElement().getText());
+ }
}