]> source.dussan.org Git - vaadin-framework.git/commitdiff
Barebones fix for #6745: Connectors for Tree, i.e. ugly but works. We can make it...
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Tue, 23 Aug 2011 13:02:17 +0000 (13:02 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Tue, 23 Aug 2011 13:02:17 +0000 (13:02 +0000)
Includes TestBench test for the feature.

svn changeset:20577/svn branch:6.7

15 files changed:
WebContent/VAADIN/themes/base/tree/img/connector-item-last.png [new file with mode: 0644]
WebContent/VAADIN/themes/base/tree/img/connector-item.png [new file with mode: 0644]
WebContent/VAADIN/themes/base/tree/img/connector.png [new file with mode: 0644]
WebContent/VAADIN/themes/base/tree/tree.css
WebContent/VAADIN/themes/reindeer/tree/tree.css
WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed-last.png [new file with mode: 0644]
WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed.png [new file with mode: 0644]
WebContent/VAADIN/themes/runo/tree/img/connectors/connector-item.png [new file with mode: 0644]
WebContent/VAADIN/themes/runo/tree/img/connectors/connector.png [new file with mode: 0644]
WebContent/VAADIN/themes/runo/tree/img/connectors/expanded-last.png [new file with mode: 0644]
WebContent/VAADIN/themes/runo/tree/img/connectors/expanded.png [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/VTree.java
src/com/vaadin/ui/themes/BaseTheme.java
tests/src/com/vaadin/tests/components/tree/TreeConnectors.html [new file with mode: 0644]
tests/src/com/vaadin/tests/components/tree/TreeConnectors.java [new file with mode: 0644]

diff --git a/WebContent/VAADIN/themes/base/tree/img/connector-item-last.png b/WebContent/VAADIN/themes/base/tree/img/connector-item-last.png
new file mode 100644 (file)
index 0000000..2eb04a3
Binary files /dev/null and b/WebContent/VAADIN/themes/base/tree/img/connector-item-last.png differ
diff --git a/WebContent/VAADIN/themes/base/tree/img/connector-item.png b/WebContent/VAADIN/themes/base/tree/img/connector-item.png
new file mode 100644 (file)
index 0000000..5f88fe1
Binary files /dev/null and b/WebContent/VAADIN/themes/base/tree/img/connector-item.png differ
diff --git a/WebContent/VAADIN/themes/base/tree/img/connector.png b/WebContent/VAADIN/themes/base/tree/img/connector.png
new file mode 100644 (file)
index 0000000..2844bba
Binary files /dev/null and b/WebContent/VAADIN/themes/base/tree/img/connector.png differ
index 9e056dc4d62e9f2483d5f0ba83ced180ddc0589b..593771a49c44de2bfab86e704a8bd68536d0410a 100644 (file)
 .v-tree-node-caption:focus {
        outline: none;
 }
+div.v-tree-node-leaf {
+       background: transparent;
+}
+.v-tree-connectors .v-tree-node-leaf,
+.v-tree-connectors .v-tree-node-leaf:hover {
+       background: transparent url(img/connector-item.png) no-repeat 8px 0;
+}
+.v-tree-connectors .v-tree-node-leaf-last,
+.v-tree-connectors .v-tree-node-leaf-last:hover {
+       background: transparent url(img/connector-item-last.png) no-repeat 8px 0;
+}
 .v-tree-node-expanded {
-       background-position: -5px -10px;
+       background: transparent url(../common/img/sprites.png) no-repeat -5px -10px;
 }
-div.v-tree-node-leaf {
+.v-tree-connectors .v-tree-node-children {
+       background: transparent url(img/connector.png) repeat-y 8px bottom;
+}
+.v-tree-connectors .v-tree-node-children-last {
        background: transparent;
 }
 .v-tree-node-caption {
index 3f77bd991d658cf76fb68f830f6f6a0a3a581b66..d33985f713b573c65687d787389dfb28fdfa43da 100644 (file)
 .v-tree-node-expanded {
        background-position: -7px 5px;
 }
+.v-tree-connectors .v-tree-node-leaf {
+       background-position: 8px -1px;
+}
+.v-ie6 .v-tree-connectors div.v-tree-node-leaf {
+       background: transparent url(../../base/tree/img/connector-item.png) no-repeat 8px -1px;
+}
+.v-ie6 .v-tree-connectors div.v-tree-node-leaf-last {
+       background: transparent url(../../base/tree/img/connector-item-last.png) no-repeat 8px -1px;
+}
 .v-tree-node-caption {
        margin-left: 16px;
        padding-bottom: 1px;
diff --git a/WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed-last.png b/WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed-last.png
new file mode 100644 (file)
index 0000000..28b3626
Binary files /dev/null and b/WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed-last.png differ
diff --git a/WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed.png b/WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed.png
new file mode 100644 (file)
index 0000000..db4d41c
Binary files /dev/null and b/WebContent/VAADIN/themes/runo/tree/img/connectors/collapsed.png differ
diff --git a/WebContent/VAADIN/themes/runo/tree/img/connectors/connector-item.png b/WebContent/VAADIN/themes/runo/tree/img/connectors/connector-item.png
new file mode 100644 (file)
index 0000000..b4d0d7a
Binary files /dev/null and b/WebContent/VAADIN/themes/runo/tree/img/connectors/connector-item.png differ
diff --git a/WebContent/VAADIN/themes/runo/tree/img/connectors/connector.png b/WebContent/VAADIN/themes/runo/tree/img/connectors/connector.png
new file mode 100644 (file)
index 0000000..a93f458
Binary files /dev/null and b/WebContent/VAADIN/themes/runo/tree/img/connectors/connector.png differ
diff --git a/WebContent/VAADIN/themes/runo/tree/img/connectors/expanded-last.png b/WebContent/VAADIN/themes/runo/tree/img/connectors/expanded-last.png
new file mode 100644 (file)
index 0000000..504b715
Binary files /dev/null and b/WebContent/VAADIN/themes/runo/tree/img/connectors/expanded-last.png differ
diff --git a/WebContent/VAADIN/themes/runo/tree/img/connectors/expanded.png b/WebContent/VAADIN/themes/runo/tree/img/connectors/expanded.png
new file mode 100644 (file)
index 0000000..5c036ed
Binary files /dev/null and b/WebContent/VAADIN/themes/runo/tree/img/connectors/expanded.png differ
index a1647c2c5222bd8b1522a6f0d1eeac38c51749c4..d7f575d67543ce1f2fd900486d18ab7af36a57d6 100644 (file)
@@ -287,7 +287,8 @@ public class VTree extends FocusElementPanel implements Paintable,
             childTree.childNodeContainer.addStyleDependentName("root");
         }
         if (childTree != null) {
-            childTree.addStyleDependentName("last");
+            boolean leaf = !uidl.getTag().equals("node");
+            childTree.addStyleDependentName(leaf ? "leaf-last" : "last");
             childTree.childNodeContainer.addStyleDependentName("last");
         }
         final String selectMode = uidl.getStringAttribute("selectmode");
@@ -1090,9 +1091,8 @@ public class VTree extends FocusElementPanel implements Paintable,
                     childNodeContainer.add(childTree);
                 }
                 if (!i.hasNext()) {
-                    childTree
-                            .addStyleDependentName(childTree.isLeaf() ? "leaf-last"
-                                    : "last");
+                    childTree.addStyleDependentName(childTree.isLeaf()
+                            ? "leaf-last" : "last");
                     childTree.childNodeContainer.addStyleDependentName("last");
                 }
             }
index c8ba08d30dd4b16f216426b0f52caf1cec83d164..b501f8a05c1f3aaff2f2313641069dde67c0d340 100644 (file)
@@ -44,4 +44,10 @@ public class BaseTheme {
     @Deprecated
     public static final String PANEL_LIGHT = "light";
 
+    /**
+     * Adds the connector lines between a parent node and its child nodes to
+     * indicate the tree hierarchy better.
+     */
+    public static final String TREE_CONNECTORS = "connectors";
+
 }
\ No newline at end of file
diff --git a/tests/src/com/vaadin/tests/components/tree/TreeConnectors.html b/tests/src/com/vaadin/tests/components/tree/TreeConnectors.html
new file mode 100644 (file)
index 0000000..b76c65f
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="/" />
+<title>TreeConnectors</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TreeConnectors</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/TreeConnectors?theme=base</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>base</td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/run/TreeConnectors?theme=reindeer</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>reindeer</td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/run/TreeConnectors?theme=runo</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>runo</td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/run/TreeConnectors?theme=liferay</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>liferay</td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/run/TreeConnectors?theme=chameleon</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>chameleon</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/src/com/vaadin/tests/components/tree/TreeConnectors.java b/tests/src/com/vaadin/tests/components/tree/TreeConnectors.java
new file mode 100644 (file)
index 0000000..08d4df0
--- /dev/null
@@ -0,0 +1,85 @@
+package com.vaadin.tests.components.tree;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.util.HierarchicalContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.themes.BaseTheme;
+
+@SuppressWarnings("serial")
+public class TreeConnectors extends TestBase {
+
+    @Override
+    protected void setup() {
+        final Tree tree = new Tree(null, createContainer());
+        tree.addStyleName(BaseTheme.TREE_CONNECTORS);
+        for (Object rootItems : tree.rootItemIds()) {
+            tree.expandItemsRecursively(rootItems);
+        }
+        tree.setChildrenAllowed("Item 73", false);
+
+        addComponent(tree);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Tree nodes should be connected with lines indicating the hierarchy.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 6745;
+    }
+
+    private HierarchicalContainer createContainer() {
+        HierarchicalContainer cont = new HierarchicalContainer();
+        cont.addContainerProperty("name", String.class, "");
+
+        for (int i = 0; i < 20; i++) {
+            Item item = cont.addItem("Item " + i);
+            item.getItemProperty("name").setValue("Item " + i);
+            cont.setChildrenAllowed("Item " + i, false);
+
+            if (i == 1 || i == 4) {
+                cont.setChildrenAllowed("Item " + i, true);
+            }
+
+            // Add three items to item 1
+            if (i > 1 && i < 4) {
+                cont.setParent("Item " + i, "Item 1");
+            }
+
+            // Add 5 items to item 4
+            if (i > 4 && i < 10) {
+                cont.setChildrenAllowed("Item " + i, true);
+
+                if (i == 7) {
+                    item = cont.addItem("Item 71");
+                    item.getItemProperty("name").setValue("Item 71");
+                    cont.setParent("Item 71", "Item " + i);
+                    cont.setChildrenAllowed("Item 71", false);
+
+                    item = cont.addItem("Item 72");
+                    item.getItemProperty("name").setValue("Item 72");
+                    cont.setParent("Item 72", "Item " + i);
+                    cont.setChildrenAllowed("Item 72", true);
+
+                    item = cont.addItem("Item 73");
+                    item.getItemProperty("name").setValue("Item 73");
+                    cont.setParent("Item 73", "Item 72");
+                    cont.setChildrenAllowed("Item 73", true);
+
+                    item = cont.addItem("Item 74");
+                    item.getItemProperty("name").setValue("Item 74");
+                    cont.setParent("Item 74", "Item " + i);
+                    cont.setChildrenAllowed("Item 74", true);
+                }
+
+                cont.setParent("Item " + i, "Item " + (i - 1));
+
+            }
+        }
+
+        return cont;
+    }
+}