]> source.dussan.org Git - vaadin-framework.git/commitdiff
committing forgotten class
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 11 Jul 2007 11:43:12 +0000 (11:43 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 11 Jul 2007 11:43:12 +0000 (11:43 +0000)
svn changeset:1841/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/ITreeAction.java [new file with mode: 0644]

diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITreeAction.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITreeAction.java
new file mode 100644 (file)
index 0000000..dd8008d
--- /dev/null
@@ -0,0 +1,65 @@
+package com.itmill.toolkit.terminal.gwt.client.ui;
+
+
+/**
+ * This class is used for "row actions" in ITree and ITable
+ */
+public class ITreeAction extends IAction {
+       
+       String targetKey = "";
+       String actionKey = "";
+       
+       public ITreeAction(IActionOwner owner) {
+               super(owner);
+       }
+       
+       public ITreeAction(IActionOwner owner, String target, String action) {
+               this(owner);
+               this.targetKey = target;
+               this.actionKey = action;
+       }
+       
+       
+       /**
+        * Sends message to server that this action has been fired.
+        * Messages are "standard" Toolkit messages whose value is comma
+        * separated pair of targetKey (row, treeNod ...) and actions id.
+        * 
+        * Variablename is always "action".
+        * 
+        * Actions are always sent immediatedly to server.
+        */
+       public void execute() {
+               owner.getClient().updateVariable(
+                               owner.getPaintableId(), 
+                               "action", 
+                               targetKey + "," + actionKey, 
+                               true);
+               owner.getClient().getContextMenu().hide();
+       }
+       
+       public String getActionKey() {
+               return actionKey;
+       }
+
+       public void setActionKey(String actionKey) {
+               this.actionKey = actionKey;
+       }
+
+       public String getTargetKey() {
+               return targetKey;
+       }
+
+       public void setTargetKey(String targetKey) {
+               this.targetKey = targetKey;
+       }
+
+       public String getHTML() {
+               StringBuffer sb = new StringBuffer();
+               if(iconUrl != null) {
+                       sb.append("<img src=\""+iconUrl+"\" alt=\"icon\" />");
+               }
+               sb.append(caption);
+               return sb.toString();
+       }
+}