summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2011-07-21 09:02:32 +0000
committerArtur Signell <artur.signell@itmill.com>2011-07-21 09:02:32 +0000
commitd4c6b5e503c7874f835fd3cc4407f0f86977a06e (patch)
treed8e7bf58a9c583e7c123ae1a0d0076a365a2428b /src
parent474ede0ea660ea7fb245ec4c0fee11cddcbda44f (diff)
downloadvaadin-framework-d4c6b5e503c7874f835fd3cc4407f0f86977a06e.tar.gz
vaadin-framework-d4c6b5e503c7874f835fd3cc4407f0f86977a06e.zip
#7220 TreeTable support for Expand/Collapse events
svn changeset:19861/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/Tree.java4
-rw-r--r--src/com/vaadin/ui/TreeTable.java73
2 files changed, 75 insertions, 2 deletions
diff --git a/src/com/vaadin/ui/Tree.java b/src/com/vaadin/ui/Tree.java
index e47d9c7909..3e6d62033e 100644
--- a/src/com/vaadin/ui/Tree.java
+++ b/src/com/vaadin/ui/Tree.java
@@ -826,7 +826,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* @VERSION@
* @since 3.0
*/
- public class ExpandEvent extends Component.Event {
+ public static class ExpandEvent extends Component.Event {
private final Object expandedItemId;
@@ -915,7 +915,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
* @VERSION@
* @since 3.0
*/
- public class CollapseEvent extends Component.Event {
+ public static class CollapseEvent extends Component.Event {
private final Object collapsedItemId;
diff --git a/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java
index dfc2703eb7..987e3a9bfd 100644
--- a/src/com/vaadin/ui/TreeTable.java
+++ b/src/com/vaadin/ui/TreeTable.java
@@ -22,6 +22,10 @@ import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.ui.VTreeTable;
+import com.vaadin.ui.Tree.CollapseEvent;
+import com.vaadin.ui.Tree.CollapseListener;
+import com.vaadin.ui.Tree.ExpandEvent;
+import com.vaadin.ui.Tree.ExpandListener;
import com.vaadin.ui.treetable.Collapsible;
import com.vaadin.ui.treetable.HierarchicalContainerOrderedWrapper;
@@ -479,6 +483,12 @@ public class TreeTable extends Table implements Hierarchical {
setCurrentPageFirstItemIndex(getCurrentPageFirstItemIndex());
toggledItemId = itemId;
requestRepaint();
+
+ if (isCollapsed(itemId)) {
+ fireCollapseEvent(itemId);
+ } else {
+ fireExpandEvent(itemId);
+ }
}
@Override
@@ -631,4 +641,67 @@ public class TreeTable extends Table implements Hierarchical {
return hierarchyColumnId;
}
+ /**
+ * Adds an expand listener.
+ *
+ * @param listener
+ * the Listener to be added.
+ */
+ public void addListener(ExpandListener listener) {
+ addListener(ExpandEvent.class, listener, ExpandListener.EXPAND_METHOD);
+ }
+
+ /**
+ * Removes an expand listener.
+ *
+ * @param listener
+ * the Listener to be removed.
+ */
+ public void removeListener(ExpandListener listener) {
+ removeListener(ExpandEvent.class, listener,
+ ExpandListener.EXPAND_METHOD);
+ }
+
+ /**
+ * Emits an expand event.
+ *
+ * @param itemId
+ * the item id.
+ */
+ protected void fireExpandEvent(Object itemId) {
+ fireEvent(new ExpandEvent(this, itemId));
+ }
+
+ /**
+ * Adds a collapse listener.
+ *
+ * @param listener
+ * the Listener to be added.
+ */
+ public void addListener(CollapseListener listener) {
+ addListener(CollapseEvent.class, listener,
+ CollapseListener.COLLAPSE_METHOD);
+ }
+
+ /**
+ * Removes a collapse listener.
+ *
+ * @param listener
+ * the Listener to be removed.
+ */
+ public void removeListener(CollapseListener listener) {
+ removeListener(CollapseEvent.class, listener,
+ CollapseListener.COLLAPSE_METHOD);
+ }
+
+ /**
+ * Emits a collapse event.
+ *
+ * @param itemId
+ * the item id.
+ */
+ protected void fireCollapseEvent(Object itemId) {
+ fireEvent(new CollapseEvent(this, itemId));
+ }
+
}