summaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-10-05 11:23:46 +0300
committerVaadin Code Review <review@vaadin.com>2015-10-05 11:10:13 +0000
commit5097095625403405d030575fcc1102f02aa3e327 (patch)
tree99d68d5d570a33f6fb2435b4f7d68dc5c563641c /server/src/com
parent743095d97bbd632e0493fca29ba2308b17b86716 (diff)
downloadvaadin-framework-5097095625403405d030575fcc1102f02aa3e327.tar.gz
vaadin-framework-5097095625403405d030575fcc1102f02aa3e327.zip
Add support for TreeContextClickEvents (#19062)
Tree connector now overrides the send context click event providing the row key to the server-side via RPC call. This is then passed on to a TreeContextClickEvent and fired to listeners. This patch modifies the test base for context click testing by making it tolerate 1 piksel differences. This was to fix any subpixel related issues in coordinate comparison. Change-Id: Iacced274a6b518b5f89378cbc32b8381362e1e4f
Diffstat (limited to 'server/src/com')
-rw-r--r--server/src/com/vaadin/ui/Tree.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java
index b41139275b..2c537e3a98 100644
--- a/server/src/com/vaadin/ui/Tree.java
+++ b/server/src/com/vaadin/ui/Tree.java
@@ -38,6 +38,7 @@ import com.vaadin.data.util.ContainerHierarchicalWrapper;
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ContextClickEvent;
import com.vaadin.event.DataBoundTransferable;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
@@ -59,6 +60,7 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.dd.VerticalDropLocation;
import com.vaadin.shared.ui.tree.TreeConstants;
+import com.vaadin.shared.ui.tree.TreeServerRpc;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignException;
@@ -75,6 +77,32 @@ import com.vaadin.util.ReflectTools;
public class Tree extends AbstractSelect implements Container.Hierarchical,
Action.Container, ItemClickNotifier, DragSource, DropTarget {
+ public static class TreeContextClickEvent extends ContextClickEvent {
+
+ private final Object itemId;
+
+ public TreeContextClickEvent(Tree source, Object itemId,
+ MouseEventDetails mouseEventDetails) {
+ super(source, mouseEventDetails);
+ this.itemId = itemId;
+ }
+
+ @Override
+ public Tree getComponent() {
+ return (Tree) super.getComponent();
+ }
+
+ /**
+ * Returns the item id of context clicked row.
+ *
+ * @return item id of clicked row; <code>null</code> if no row is
+ * present at the location
+ */
+ public Object getItemId() {
+ return itemId;
+ }
+ }
+
/* Private members */
private static final String NULL_ALT_EXCEPTION_MESSAGE = "Parameter 'altText' needs to be non null";
@@ -154,6 +182,14 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
*/
public Tree() {
this(null);
+
+ registerRpc(new TreeServerRpc() {
+ @Override
+ public void contextClick(String rowKey, MouseEventDetails details) {
+ fireEvent(new TreeContextClickEvent(Tree.this,
+ itemIdMapper.get(rowKey), details));
+ }
+ });
}
/**