changeset 814:6db4839e0ba1

Datacage: Added a subclass of TreeNode to carry the informations needed by the loading listeners. flys-client/trunk@2470 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 08 Aug 2011 16:19:00 +0000
parents 57ea5af8a967
children 112f95d7b286
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java flys-client/src/main/java/de/intevation/flys/client/client/widgets/tree/AttributedTreeNode.java
diffstat 3 files changed, 67 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Aug 08 15:54:59 2011 +0000
+++ b/flys-client/ChangeLog	Mon Aug 08 16:19:00 2011 +0000
@@ -1,3 +1,14 @@
+2011-08-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de> 
+
+	* src/main/java/de/intevation/flys/client/client/widgets/tree/AttributedTreeNode.java:
+	  New. Subclassed TreeNode to carry the attribute data from
+	  the meta data service.
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java:
+	  Create AttributedTreeNodes instead of TreeNodes to have the
+	  relevant information at hand if a listener wants to access
+	  the data.
+
 2011-08-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de> 
 
 	* src/main/java/de/intevation/flys/client/shared/model/AttrList.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Mon Aug 08 15:54:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java	Mon Aug 08 16:19:00 2011 +0000
@@ -33,6 +33,8 @@
 import de.intevation.flys.client.shared.model.DataCageTree;
 import de.intevation.flys.client.shared.model.DataCageNode;
 
+import de.intevation.flys.client.client.widgets.tree.AttributedTreeNode;
+
 public class DatacageWindow
 extends      Window
 {
@@ -112,23 +114,24 @@
         treeGrid.setData(convertTree(tree));
     }
 
-    protected static TreeNode convert(DataCageNode node) {
+    protected static AttributedTreeNode convert(DataCageNode node) {
         List<DataCageNode> children = node.getChildren();
 
-        TreeNode [] cs;
+        AttributedTreeNode [] cs;
 
         if (children != null) {
-            cs = new TreeNode[children.size()];
+            cs = new AttributedTreeNode[children.size()];
 
             for (int i = 0, N = children.size(); i < N; ++i) {
                 cs[i] = convert(children.get(i));
             }
         }
         else {
-            cs = new TreeNode[0];
+            cs = new AttributedTreeNode[0];
         }
 
-        return new TreeNode(node.getName(), cs);
+        return new AttributedTreeNode(
+            node.getName(), node.getAttributes(), cs);
     }
 
     protected static Tree convertTree(DataCageTree tree) {
@@ -136,20 +139,21 @@
 
         List<DataCageNode> children = root.getChildren();
 
-        TreeNode [] cs;
+        AttributedTreeNode [] cs;
 
         if (children != null) {
-            cs = new TreeNode[children.size()];
+            cs = new AttributedTreeNode[children.size()];
 
             for (int i = 0, N = children.size(); i < N; ++i) {
                 cs[i] = convert(children.get(i));
             }
         }
         else {
-            cs = new TreeNode[0];
+            cs = new AttributedTreeNode[0];
         }
 
-        TreeNode rn = new TreeNode(root.getName(), cs);
+        AttributedTreeNode rn = new AttributedTreeNode(
+            root.getName(), root.getAttributes(), cs);
 
         Tree r = new Tree();
         r.setRoot(rn);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/widgets/tree/AttributedTreeNode.java	Mon Aug 08 16:19:00 2011 +0000
@@ -0,0 +1,43 @@
+package de.intevation.flys.client.client.widgets.tree;
+
+import com.smartgwt.client.widgets.tree.TreeNode;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+import de.intevation.flys.client.shared.model.AttrList;
+
+public class AttributedTreeNode
+extends      TreeNode
+{
+    protected AttrList attrs;
+
+    public AttributedTreeNode() {
+    }
+
+    public AttributedTreeNode(JavaScriptObject jsObj) {
+        super(jsObj);
+    }
+
+    public AttributedTreeNode(String name) {
+        super(name);
+    }
+
+    public AttributedTreeNode(String name, TreeNode ... children) {
+        super(name, children);
+    }
+
+    public AttributedTreeNode(String name, AttrList attrs) {
+        super(name);
+        this.attrs = attrs;
+    }
+
+    public AttributedTreeNode(String name, AttrList attrs, TreeNode ... children) {
+        super(name, children);
+        this.attrs = attrs;
+    }
+
+    public AttrList getSpecialAttributes() {
+        return attrs;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org