You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/12/24 07:36:25 UTC
svn commit: r1052454 - in /click/trunk/click: documentation/docs/
examples/src/org/apache/click/examples/page/tree/
extras/src/org/apache/click/extras/tree/
extras/test/org/apache/click/extras/tree/
Author: sabob
Date: Fri Dec 24 06:36:24 2010
New Revision: 1052454
URL: http://svn.apache.org/viewvc?rev=1052454&view=rev
Log:
Deprecate TreeNode constructors CLK-743
Modified:
click/trunk/click/documentation/docs/roadmap-changes.html
click/trunk/click/examples/src/org/apache/click/examples/page/tree/AdvancedTreePage.java
click/trunk/click/examples/src/org/apache/click/examples/page/tree/CheckboxTreePage.java
click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java
click/trunk/click/examples/src/org/apache/click/examples/page/tree/TreePage.java
click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java
click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java
Modified: click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/click/trunk/click/documentation/docs/roadmap-changes.html?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ click/trunk/click/documentation/docs/roadmap-changes.html Fri Dec 24 06:36:24 2010
@@ -183,6 +183,12 @@ Action support and light-weight stateful
However the majority of use cases are catered for by the new stateful
support in the controls: Table, Form, TabbedPanel, Field and AbstractLink.
</li>
+ <li class="change">Deprecated <a href="extras-api/org/apache/click/extras/tree/TreeNode.html#TreeNode(java.lang.Object, java.lang.String, org.apache.click.extras.tree.TreeNode)">TreeNode constructors</a>
+ which accepts a parent node. Instead use
+ <a href="extras-api/org/apache/click/extras/tree/TreeNode.html#add(org.apache.click.extras.tree.TreeNode)">add</a>
+ to build the node hierarchy
+ [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-743">CLK-743</a>].
+ </li>
<li class="change">Deprecated <a href="click-api/org/apache/click/util/ActionListenerAdaptor.html">ActionListenerAdaptor</a>
since ActionListener only has a single method and no adaptor is necessary
[<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-731">CLK-731</a>].
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/tree/AdvancedTreePage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/tree/AdvancedTreePage.java?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/tree/AdvancedTreePage.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/tree/AdvancedTreePage.java Fri Dec 24 06:36:24 2010
@@ -110,50 +110,57 @@ public class AdvancedTreePage extends Bo
return tree;
}
- //Create a node representing the root directory with the specified
- //parameter as the value. Because an id is not specified, a random
- //one will be generated by the node. By default the root node is
- //not rendered by the tree. This can be changed by calling
- //tree.setRootNodeDisplayed(true).
+ // Create a node representing the root directory with the specified
+ // parameter as the value. Because an id is not specified, a random
+ // one will be generated by the node. By default the root node is
+ // not rendered by the tree. This can be changed by calling
+ // tree.setRootNodeDisplayed(true).
TreeNode root = new TreeNode("c:");
- //Create a new directory, setting the root directory as its parent. Here
- //we do specify a id as the 2nd argument, so no id is generated.
- TreeNode dev = new TreeNode("dev","1", root);
-
- //The following 3 nodes represent files in the directory, setting the
- //dev node as their parent. Note the false argument to the constructor.
- //This means that the specific node does not support child nodes, and
- //it will be rendered as a leaf icon. If children are supported (the
- //default value) then even if the node is a leaf, it will still be rendered
- //as a collapsed icon. In the example a default leaf node will be
- //rendered as a directory, and a node that does not support children is
- //rendered as a file.
+ // Create a new directory, setting the root directory as its parent. Here
+ // we do specify a id as the 2nd argument, so no id is generated.
+ TreeNode dev = new TreeNode("dev","1");
+ root.add(dev);
+
+ // The following 3 nodes represent files in the directory as children of
+ // the dev node. Note the false argument to the constructor.
+ // This means that the specific node does not support child nodes, and
+ // it will be rendered as a leaf icon. If children are supported (the
+ // default value) then even if the node is a leaf, it will still be rendered
+ // as a collapsed icon. In the example a default leaf node will be
+ // rendered as a directory, and a node that does not support children is
+ // rendered as a file.
// Also note the node with the long text, will cause the tree to overflow
// and add scrollbars
- new TreeNode("java.pdf", "1.1", dev, false);
- new TreeNode("JEE 6 - the new fantastic approach to write better software (apparently)", "1.2", dev, false);
- new TreeNode("ruby.pdf", "1.3", dev, false);
+ dev.add(new TreeNode("java.pdf", "1.1", false));
+ dev.add(new TreeNode("JEE 6 - the new fantastic approach to write better software (apparently)", "1.2", false));
+ dev.add(new TreeNode("ruby.pdf", "1.3", false));
//We continue constructing the rest of the tree
- TreeNode programFiles = new TreeNode("program files", "2", root);
- new TreeNode("Adobe", "2.1", programFiles);
-
- TreeNode download = new TreeNode("downloads","3", root);
-
- TreeNode web = new TreeNode("web", "3.1", download);
- new TreeNode("html.pdf", "3.1.1", web, false);
- new TreeNode("css.html", "3.1.2", web, false);
-
- TreeNode databases = new TreeNode("databases", "3.2", download);
- TreeNode relationalDb = new TreeNode("relational", "3.2.1", databases);
-
- new TreeNode("mysql.html", "3.2.1.1", relationalDb, false);
- new TreeNode("oracle.pdf", "3.2.1.2", relationalDb, false);
- new TreeNode("postgres", "3.2.1.3", relationalDb, false);
-
- TreeNode objectDb = new TreeNode("object", "3.2.2", databases);
- new TreeNode("db4o.html", "3.2.2.1", objectDb, false);
+ TreeNode programFiles = new TreeNode("program files", "2");
+ root.add(programFiles);
+ programFiles.add(new TreeNode("Adobe", "2.1"));
+
+ TreeNode download = new TreeNode("downloads","3");
+ root.add(download);
+
+ TreeNode web = new TreeNode("web", "3.1");
+ download.add(web);
+ web.add(new TreeNode("html.pdf", "3.1.1", false));
+ web.add(new TreeNode("css.html", "3.1.2", false));
+
+ TreeNode databases = new TreeNode("databases", "3.2");
+ download.add(databases);
+ TreeNode relationalDb = new TreeNode("relational", "3.2.1");
+ databases.add(relationalDb);
+
+ relationalDb.add(new TreeNode("mysql.html", "3.2.1.1", false));
+ relationalDb.add(new TreeNode("oracle.pdf", "3.2.1.2", false));
+ relationalDb.add(new TreeNode("postgres", "3.2.1.3", false));
+
+ TreeNode objectDb = new TreeNode("object", "3.2.2");
+ databases.add(objectDb);
+ objectDb.add(new TreeNode("db4o.html", "3.2.2.1", false));
//Attach the root node containing all the other nodes to the tree
tree.setRootNode(root);
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/tree/CheckboxTreePage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/tree/CheckboxTreePage.java?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/tree/CheckboxTreePage.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/tree/CheckboxTreePage.java Fri Dec 24 06:36:24 2010
@@ -63,7 +63,7 @@ public class CheckboxTreePage extends Bo
// the form.
form = new Form("form");
- //Create the tree and tree model and add it to the page
+ // Create the tree and tree model and add it to the page
tree = buildTree();
tree.addListener(this);
@@ -78,8 +78,8 @@ public class CheckboxTreePage extends Bo
addControl(form);
- //Build the options user interface for users to interactively
- //change the tree values.
+ // Build the options user interface for users to interactively
+ // change the tree values.
buildOptionsUI();
}
@@ -102,74 +102,81 @@ public class CheckboxTreePage extends Bo
public CheckboxTree buildTree() {
tree = createTree();
- //Try and load the already stored nodes from the session.
- //If this is the first time we access the page, this method
- //will return null, indicating no nodes is stored.
+ // Try and load the already stored nodes from the session.
+ // If this is the first time we access the page, this method
+ // will return null, indicating no nodes is stored.
TreeNode existingRootNode = loadNodesFromSession();
if(existingRootNode != null) {
- //OK we had already nodes stored in the session, so no need
- //to rebuild them. We attach the root node and return.
+ // OK we had already nodes stored in the session, so no need
+ // to rebuild them. We attach the root node and return.
tree.setRootNode(existingRootNode);
return tree;
}
- //Create a node representing the root directory with the specified
- //parameter as the value. Because an id is not specified, a random
- //one will be generated by the node. By default the root node is
- //not rendered by the tree. This can be changed by calling
- //tree.setRootNodeDisplayed(true).
+ // Create a node representing the root directory with the specified
+ // parameter as the value. Because an id is not specified, a random
+ // one will be generated by the node. By default the root node is
+ // not rendered by the tree. This can be changed by calling
+ // tree.setRootNodeDisplayed(true).
TreeNode root = new TreeNode("c:");
- //Create a new directory, setting the root directory as its parent. Here
- //we do specify a id as the 2nd argument, so no id is generated.
- TreeNode dev = new TreeNode("dev","1", root);
-
- //The following 3 nodes represent files in the directory, setting the
- //dev node as their parent. Note the false argument to the constructor.
- //This means that the specific node does not support child nodes, and
- //it will be rendered as a leaf icon. If children are supported (the
- //default value) then even if the node is a leaf, it will still be rendered
- //as a collapsed icon. In the example a default leaf node will be
- //rendered as a directory, and a node that does not support children is
- //rendered as a file.
+ // Create a new directory, setting the root directory as its parent. Here
+ // we do specify a id as the 2nd argument, so no id is generated.
+ TreeNode dev = new TreeNode("dev","1");
+ root.add(dev);
+
+ // The following 3 nodes represent files in the directory as children of
+ // the dev node. Note the false argument to the constructor.
+ // This means that the specific node does not support child nodes, and
+ // it will be rendered as a leaf icon. If children are supported (the
+ // default value) then even if the node is a leaf, it will still be rendered
+ // as a collapsed icon. In the example a default leaf node will be
+ // rendered as a directory, and a node that does not support children is
+ // rendered as a file.
// Also note the node with the long text, will cause the tree to overflow
// and add scrollbars
- new TreeNode("java.pdf", "1.1", dev, false);
- new TreeNode("JEE 6 - the new fantastic approach to write better software (apparently)", "1.2", dev, false);
- new TreeNode("ruby.pdf", "1.3", dev, false);
+ dev.add(new TreeNode("java.pdf", "1.1", false));
+ dev.add(new TreeNode("JEE 6 - the new fantastic approach to write better software (apparently)", "1.2", false));
+ dev.add(new TreeNode("ruby.pdf", "1.3", false));
//We continue constructing the rest of the tree
- TreeNode programFiles = new TreeNode("program files", "2", root);
- new TreeNode("Adobe", "2.1", programFiles);
+ TreeNode programFiles = new TreeNode("program files", "2");
+ root.add(programFiles);
+ programFiles.add(new TreeNode("Adobe", "2.1"));
+
+ TreeNode download = new TreeNode("downloads","3");
+ root.add(download);
+
+ TreeNode web = new TreeNode("web", "3.1");
+ download.add(web);
+ web.add(new TreeNode("html.pdf", "3.1.1", false));
+ web.add(new TreeNode("css.html", "3.1.2", false));
+
+ TreeNode databases = new TreeNode("databases", "3.2");
+ download.add(databases);
+ TreeNode relationalDb = new TreeNode("relational", "3.2.1");
+ databases.add(relationalDb);
+
+ relationalDb.add(new TreeNode("mysql.html", "3.2.1.1",false));
+ relationalDb.add(new TreeNode("oracle.pdf", "3.2.1.2", false));
+ relationalDb.add(new TreeNode("postgres", "3.2.1.3", false));
+
+ TreeNode objectDb = new TreeNode("object", "3.2.2");
+ databases.add(objectDb);
+ objectDb.add(new TreeNode("db4o.html", "3.2.2.1", false));
- TreeNode download = new TreeNode("downloads","3", root);
-
- TreeNode web = new TreeNode("web", "3.1", download);
- new TreeNode("html.pdf", "3.1.1", web, false);
- new TreeNode("css.html", "3.1.2", web, false);
-
- TreeNode databases = new TreeNode("databases", "3.2", download);
- TreeNode relationalDb = new TreeNode("relational", "3.2.1", databases);
-
- new TreeNode("mysql.html", "3.2.1.1", relationalDb, false);
- new TreeNode("oracle.pdf", "3.2.1.2", relationalDb, false);
- new TreeNode("postgres", "3.2.1.3", relationalDb, false);
-
- TreeNode objectDb = new TreeNode("object", "3.2.2", databases);
- new TreeNode("db4o.html", "3.2.2.1", objectDb, false);
-
- //Attach the root node containing all the other nodes to the tree
+ // Attach the root node containing all the other nodes to the tree
tree.setRootNode(root);
- //By default root node is not displayed in browser. Here we expand it,
- //so that the root's children are visible.
+ // By default root node is not displayed in browser. Here we expand it,
+ // so that the root's children are visible.
expandRoot();
- //Store the tree nodes in the session so on the next request we do not
- //have to rebuild it. Also because we keep the tree nodes in the session
- //the nodes will keep their state between requests.
+ // Store the tree nodes in the session so on the next request we do not
+ // have to rebuild it. Also because we keep the tree nodes in the session
+ // the nodes will keep their state between requests.
storeNodesInSession(root);
return tree;
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/tree/PageLinkTreePage.java Fri Dec 24 06:36:24 2010
@@ -41,18 +41,20 @@ public class PageLinkTreePage extends Tr
private static final long serialVersionUID = 1L;
- public static final String TREE_NODES_SESSION_KEY = "pageLinkTreeNodes";
+ public static final String LINK_TREE_NODES_SESSION_KEY = "pageLinkTreeNodes";
// Protected Methods ------------------------------------------------------
/**
* Creates and return a new tree instance.
*/
+ @Override
protected Tree createTree() {
return new Tree("tree") {
private static final long serialVersionUID = 1L;
+ @Override
protected void renderValue(HtmlStringBuffer buffer, TreeNode treeNode) {
Object nodeValue = treeNode.getValue();
Class cls = null;
@@ -77,6 +79,7 @@ public class PageLinkTreePage extends Tr
* Build the tree model and stores it in the session. This model represents
* nodes which link to other example Pages.
*/
+ @Override
protected TreeNode createNodes() {
//Create a node representing the root directory with the specified
@@ -88,21 +91,24 @@ public class PageLinkTreePage extends Tr
//Create a new directory, setting the root directory as its parent. Here
//we do specify a id as the 2nd argument, so no id is generated.
- TreeNode general = new TreeNode("Intro", "1", root);
+ TreeNode general = new TreeNode("Intro", "1");
+ root.add(general);
boolean supportsChildNodes = false;
- new TreeNode(HelloWorld.class, "1.1", general, supportsChildNodes);
- new TreeNode(ControlListenerType1Page.class, "1.2", general, supportsChildNodes);
- new TreeNode(ControlListenerType2Page.class, "1.3", general, supportsChildNodes);
-
- TreeNode forms = new TreeNode("Forms", "2", root);
- new TreeNode(SimpleForm.class, "2.1", forms, supportsChildNodes);
- new TreeNode(AdvancedForm.class, "2.2", forms, supportsChildNodes);
-
- TreeNode tables = new TreeNode("Tables", "3", root);
- new TreeNode(SimpleTable.class, "3.1", tables, supportsChildNodes);
- new TreeNode(AdvancedTable.class, "3.2", tables, supportsChildNodes);
+ general.add(new TreeNode(HelloWorld.class, "1.1", supportsChildNodes));
+ general.add(new TreeNode(ControlListenerType1Page.class, "1.2", supportsChildNodes));
+ general.add(new TreeNode(ControlListenerType2Page.class, "1.3", supportsChildNodes));
+
+ TreeNode forms = new TreeNode("Forms", "2");
+ root.add(forms);
+ forms.add(new TreeNode(SimpleForm.class, "2.1", supportsChildNodes));
+ forms.add(new TreeNode(AdvancedForm.class, "2.2", supportsChildNodes));
+
+ TreeNode tables = new TreeNode("Tables", "3");
+ root.add(tables);
+ tables.add(new TreeNode(SimpleTable.class, "3.1", supportsChildNodes));
+ tables.add(new TreeNode(AdvancedTable.class, "3.2", supportsChildNodes));
return root;
}
@@ -112,8 +118,9 @@ public class PageLinkTreePage extends Tr
*
* @return the string under which the nodes are stored in the session
*/
+ @Override
protected String getSessionKey() {
- return TREE_NODES_SESSION_KEY;
+ return LINK_TREE_NODES_SESSION_KEY;
}
}
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/tree/TreePage.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/tree/TreePage.java?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/tree/TreePage.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/tree/TreePage.java Fri Dec 24 06:36:24 2010
@@ -132,41 +132,48 @@ public class TreePage extends BorderPage
//Create a new directory, setting the root directory as its parent. Here
//we do specify a id as the 2nd argument, so no id is generated.
- TreeNode dev = new TreeNode("dev","1", root);
+ TreeNode dev = new TreeNode("dev","1");
+ root.add(dev);
- //The following 3 nodes represent files in the directory, setting the
- //dev node as their parent. Note the false argument to the constructor.
- //This means that the specific node does not support child nodes, and
- //it will be rendered as a leaf icon. If children are supported (the
- //default value) then even if the node is a leaf, it will still be rendered
- //as a collapsed icon. In the example a default leaf node will be
- //rendered as a directory, and a node that does not support children is
- //rendered as a file.
+ //The following 3 nodes represent files in the directory as children of
+ // the dev node. Note the false argument to the constructor.
+ // This means that the specific node does not support child nodes, and
+ // it will be rendered as a leaf icon. If children are supported (the
+ // default value) then even if the node is a leaf, it will still be rendered
+ // as a collapsed icon. In the example a default leaf node will be
+ // rendered as a directory, and a node that does not support children is
+ // rendered as a file.
// Also note the node with the long text, will cause the tree to overflow
// and add scrollbars
- new TreeNode("java.pdf", "1.1", dev, false);
- new TreeNode("JEE 6 - the new fantastic approach to write better software (apparently)", "1.2", dev, false);
- new TreeNode("ruby.pdf", "1.3", dev, false);
+ dev.add(new TreeNode("java.pdf", "1.1", false));
+ dev.add(new TreeNode("JEE 6 - the new fantastic approach to write better software (apparently)", "1.2", false));
+ dev.add(new TreeNode("ruby.pdf", "1.3", false));
//We continue constructing the rest of the tree
- TreeNode programFiles = new TreeNode("program files", "2", root);
- new TreeNode("Adobe", "2.1", programFiles);
-
- TreeNode download = new TreeNode("downloads","3", root);
-
- TreeNode web = new TreeNode("web", "3.1", download);
- new TreeNode("html.pdf", "3.1.1", web, false);
- new TreeNode("css.html", "3.1.2", web, false);
-
- TreeNode databases = new TreeNode("databases", "3.2", download);
- TreeNode relationalDb = new TreeNode("relational", "3.2.1", databases);
-
- new TreeNode("mysql.html", "3.2.1.1", relationalDb, false);
- new TreeNode("oracle.pdf", "3.2.1.2", relationalDb, false);
- new TreeNode("postgres", "3.2.1.3", relationalDb, false);
-
- TreeNode objectDb = new TreeNode("object", "3.2.2", databases);
- new TreeNode("db4o.html", "3.2.2.1", objectDb, false);
+ TreeNode programFiles = new TreeNode("program files", "2");
+ root.add(programFiles);
+ programFiles.add(new TreeNode("Adobe", "2.1"));
+
+ TreeNode download = new TreeNode("downloads","3");
+ root.add(download);
+
+ TreeNode web = new TreeNode("web", "3.1");
+ download.add(web);
+ web.add(new TreeNode("html.pdf", "3.1.1", false));
+ web.add(new TreeNode("css.html", "3.1.2", false));
+
+ TreeNode databases = new TreeNode("databases", "3.2");
+ download.add(databases);
+ TreeNode relationalDb = new TreeNode("relational", "3.2.1");
+ databases.add(relationalDb);
+
+ relationalDb.add(new TreeNode("mysql.html", "3.2.1.1", false));
+ relationalDb.add(new TreeNode("oracle.pdf", "3.2.1.2", false));
+ relationalDb.add(new TreeNode("postgres", "3.2.1.3", false));
+
+ TreeNode objectDb = new TreeNode("object", "3.2.2");
+ databases.add(objectDb);
+ objectDb.add(new TreeNode("db4o.html", "3.2.2.1", false));
return root;
}
Modified: click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/tree/TreeNode.java Fri Dec 24 06:36:24 2010
@@ -133,6 +133,9 @@ public class TreeNode implements Seriali
}
/**
+ * @deprecated use {@link #TreeNode(java.lang.Object, java.lang.String)}
+ * instead and add to parent node through {@link #add(org.apache.click.extras.tree.TreeNode)}.
+ *
* Creates a node and sets the value, id and parent to the specified arguments.
*
* @param value the nodes value
@@ -146,6 +149,24 @@ public class TreeNode implements Seriali
}
/**
+ * Creates a node and sets the value, id and childrenSupported to the
+ * specified arguments.
+ *
+ * @param value the nodes value
+ * @param id the nodes id
+ * @param childrenSupported indicates if the treeNode supports child nodes
+ * or not.
+ */
+ public TreeNode(Object value, String id, boolean childrenSupported) {
+ setValue(value);
+ setId(id);
+ setChildrenSupported(childrenSupported);
+ }
+
+ /**
+ * @deprecated use {@link #TreeNode(java.lang.Object, java.lang.String, boolean)}
+ * instead and add to parent node through {@link #add(org.apache.click.extras.tree.TreeNode)}.
+ *
* Creates a node and sets the value, id and parent to the specified arguments.
*
* @param value the nodes value
@@ -206,7 +227,7 @@ public class TreeNode implements Seriali
* @return true if this node is a leaf node, false otherwise.
*/
public boolean isLeaf() {
- return getChildren().size() == 0;
+ return getChildren().isEmpty();
}
/**
@@ -512,8 +533,8 @@ public class TreeNode implements Seriali
*/
public int getLevel() {
int level = 0;
- TreeNode parent = this;
- while ((parent = parent.getParent()) != null) {
+ TreeNode parentObj = this;
+ while ((parentObj = parentObj.getParent()) != null) {
level++;
}
return level;
@@ -562,7 +583,7 @@ public class TreeNode implements Seriali
*/
@Override
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("TreeNode -> [");
buffer.append("id=").append(getId()).append(", ");
buffer.append("value=").append(getValue()).append(", ");
Modified: click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java?rev=1052454&r1=1052453&r2=1052454&view=diff
==============================================================================
--- click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java (original)
+++ click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java Fri Dec 24 06:36:24 2010
@@ -92,15 +92,15 @@ public class TreeTest extends TestCase {
result = tree.getSelectedNodes(includeInvisibleNodes);
assertEquals(3, result.size());
}
-
+
/**
* Test that getExpandedNodes return only visible nodes.
*/
public void testGetExpandedNodes() {
//ensure the testIds are expanded
- String[] testIds = new String[] {"root", "three", "3.1", "3.1.1"};
- for(int i = 0; i < testIds.length; i++) {
- tree.expand(testIds[i]);
+ String[] testIdArray = new String[] {"root", "three", "3.1", "3.1.1"};
+ for(int i = 0; i < testIdArray.length; i++) {
+ tree.expand(testIdArray[i]);
}
tree.collapse("3.1");
@@ -133,22 +133,27 @@ public class TreeTest extends TestCase {
return tree;
}
TreeNode node = new TreeNode("root", "root");
- TreeNode node1 = new TreeNode("one", "one", node);
- new TreeNode("1.1", "1.1", node1);
- new TreeNode("1.2", "1.2", node1);
- new TreeNode("2.1", "2.1", node1);
- TreeNode node3 = new TreeNode("three","three", node);
- TreeNode node4 = new TreeNode("four", "four", node);
- TreeNode node31 = new TreeNode("3.1", "3.1", node3);
- new TreeNode("3.2", "3.2", node3);
- new TreeNode("3.3", "3.3", node3);
- new TreeNode("3.1.1", "3.1.1", node31);
- new TreeNode("3.1.2", "3.1.2", node31);
- new TreeNode("3.1.3", "3.1.3", node31);
+ TreeNode node1 = new TreeNode("one", "one");
+ node.add(node1);
+ node1.add(new TreeNode("1.1", "1.1"));
+ node1.add(new TreeNode("1.2", "1.2"));
+ node1.add(new TreeNode("2.1", "2.1"));
+ TreeNode node3 = new TreeNode("three","three");
+ node.add(node3);
+ TreeNode node4 = new TreeNode("four", "four");
+ node.add(node4);
+ TreeNode node31 = new TreeNode("3.1", "3.1");
+ node3.add(node31);
+ node3.add(new TreeNode("3.2", "3.2"));
+ node3.add(new TreeNode("3.3", "3.3"));
+ node31.add(new TreeNode("3.1.1", "3.1.1"));
+ node31.add(new TreeNode("3.1.2", "3.1.2"));
+ node31.add(new TreeNode("3.1.3", "3.1.3"));
- TreeNode node41 = new TreeNode("4.1", "4.1", node4);
- new TreeNode("4.1.1", "4.1.1", node41);
- new TreeNode("4.2.1", "4.2.1", node41);
+ TreeNode node41 = new TreeNode("4.1", "4.1");
+ node4.add(node41);
+ node41.add(new TreeNode("4.1.1", "4.1.1"));
+ node41.add(new TreeNode("4.2.1", "4.2.1"));
tree.setRootNode(node);
tree.expand(node);