diff options
author | John Alhroos <john.ahlroos@itmill.com> | 2011-08-16 11:57:04 +0000 |
---|---|---|
committer | John Alhroos <john.ahlroos@itmill.com> | 2011-08-16 11:57:04 +0000 |
commit | 2d518450045c8df937cf1f5d2557c1a4673667b1 (patch) | |
tree | ee1f11b06a370b9cbfb2aedd8ea7d632a33cc498 /src/com/vaadin/ui/Tree.java | |
parent | 3e2524d2d0a45e2571c643f7e173acaff640088d (diff) | |
download | vaadin-framework-2d518450045c8df937cf1f5d2557c1a4673667b1.tar.gz vaadin-framework-2d518450045c8df937cf1f5d2557c1a4673667b1.zip |
Tooltips for Tree + Testbech test for them #6637
svn changeset:20415/svn branch:6.7
Diffstat (limited to 'src/com/vaadin/ui/Tree.java')
-rw-r--r-- | src/com/vaadin/ui/Tree.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java index 3e6d62033e..ede37f2c60 100644 --- a/src/com/vaadin/ui/Tree.java +++ b/src/com/vaadin/ui/Tree.java @@ -104,6 +104,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, private boolean initialPaint = true; /** + * Item tooltip generator + */ + private ItemDescriptionGenerator itemDescriptionGenerator; + + /** * Supported drag modes for Tree. */ public enum TreeDragMode { @@ -608,6 +613,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } } + if (itemDescriptionGenerator != null) { + String description = itemDescriptionGenerator + .generateDescription(this, itemId, null); + if (description != null && !description.equals("")) { + target.addAttribute("descr", description); + } + } + // Adds the attributes target.addAttribute("caption", getItemCaption(itemId)); final Resource icon = getItemIcon(itemId); @@ -1562,4 +1575,26 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } + /** + * Set the item description generator which generates tooltips for the tree + * items + * + * @param generator + * The generator to use or null to disable + */ + public void setItemDescriptionGenerator(ItemDescriptionGenerator generator) { + if (generator != itemDescriptionGenerator) { + itemDescriptionGenerator = generator; + requestRepaint(); + } + } + + /** + * Get the item description generator which generates tooltips for tree + * items + */ + public ItemDescriptionGenerator getItemDescriptionGenerator() { + return itemDescriptionGenerator; + } + } |