diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-06-20 12:59:14 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-06-20 12:59:14 +0300 |
commit | f700c01e12ea5be80d88587a2720a03187922f2c (patch) | |
tree | e6e1cdd58cfe034769e29cdc85abc70dd1746331 /server | |
parent | 086170faf858062d2d85fca7fade901a6070c2c2 (diff) | |
download | vaadin-framework-f700c01e12ea5be80d88587a2720a03187922f2c.tar.gz vaadin-framework-f700c01e12ea5be80d88587a2720a03187922f2c.zip |
Enable row height and content mode settings for Tree (#9540)
* Enable row height setting for Tree
* Add content mode for captions
* Align expander element by default to top
The content mode allows use of preformatted and
HTML captions that bring value to row height
Fixes #9411
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Tree.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Tree.java b/server/src/main/java/com/vaadin/ui/Tree.java index aaff872c95..35bc680213 100644 --- a/server/src/main/java/com/vaadin/ui/Tree.java +++ b/server/src/main/java/com/vaadin/ui/Tree.java @@ -218,13 +218,14 @@ public class Tree<T> extends Composite private TreeGrid<T> treeGrid = new TreeGrid<>(); private ItemCaptionGenerator<T> captionGenerator = String::valueOf; private IconGenerator<T> iconProvider = t -> null; + private final TreeRenderer renderer; /** * Constructs a new Tree Component. */ public Tree() { setCompositionRoot(treeGrid); - TreeRenderer renderer = new TreeRenderer(); + renderer = new TreeRenderer(); treeGrid.getDataCommunicator().addDataGenerator(renderer); treeGrid.addColumn(i -> captionGenerator.apply(i), renderer) .setId("column"); @@ -762,4 +763,25 @@ public class Tree<T> extends Composite public void setComponentError(ErrorMessage componentError) { treeGrid.setComponentError(componentError); } + + /** + * Sets the height of a row. If -1 (default), the row height is calculated + * based on the theme for an empty row before the Tree is displayed. + * + * @param rowHeight + * The height of a row in pixels or -1 for automatic calculation + */ + public void setRowHeight(double rowHeight) { + treeGrid.setRowHeight(rowHeight); + } + + /** + * Sets the content mode of the item caption. + * + * @param contentMode + * the content mode + */ + public void setContentMode(ContentMode contentMode) { + renderer.getState().mode = contentMode; + } } |