Author: dolander Date: Tue Jan 18 07:59:20 2005 New Revision: 125513 URL: http://svn.apache.org/viewcvs?view=rev&rev=125513 Log: Add interface to the Tree package to represent the RootElement in a tree. A root element is not required, but does allow for certain optimizations. The concrete class TreeRootElement now implements the new interface.
Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/ITreeRootElement.java Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/ITreeRootElement.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/ITreeRootElement.java?view=auto&rev=125513 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/ITreeRootElement.java Tue Jan 18 07:59:20 2005 @@ -0,0 +1,34 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.tree; + +/** + * This interface provides additional behavior on the root node in a tree. There + * are certain optimizations that may be done if state is tracked in the root. + */ +public interface ITreeRootElement + { + /** + * Change the node that is selected. This is an optimization were the + * root node can track which node is currently selected so it can unselect + * that node instead of searching the whole tree to find the selected node. + * + * @param selectNode + */ + void changeSelected(String selectNode); +} Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java?view=diff&rev=125513&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r1=125512&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r2=125513 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java Tue Jan 18 07:59:20 2005 @@ -380,6 +380,7 @@ public void setRunAtClient(boolean runAtClient) { _runAtClient = runAtClient; + System.err.println("RunAtClient:" + _runAtClient); } /** Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java?view=diff&rev=125513&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java&r1=125512&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java&r2=125513 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeHelpers.java Tue Jan 18 07:59:20 2005 @@ -42,8 +42,8 @@ // of the tree to select the node. String selectNode = request.getParameter(TreeElement.SELECTED_NODE); if (selectNode != null) { - if (treeRoot instanceof TreeRootElement) { - TreeRootElement root = (TreeRootElement) treeRoot; + if (treeRoot instanceof ITreeRootElement) { + ITreeRootElement root = (ITreeRootElement) treeRoot; root.changeSelected(selectNode); } else { Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java?view=diff&rev=125513&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java&r1=125512&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java&r2=125513 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/TreeRootElement.java Tue Jan 18 07:59:20 2005 @@ -45,6 +45,12 @@ super(label, expanded); } + /** + * Change the node that is selected. This is an optimization were the + * root node can track which node is currently selected so it can unselect + * that node instead of searching the whole tree to find the selected node. + * @param selectNode + */ public void changeSelected(String selectNode) { // if there is a selectedNode then we need to raise the onSelect Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf?view=diff&rev=125513&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf&r1=125512&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf&r2=125513 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/Controller.jpf Tue Jan 18 07:59:20 2005 @@ -770,7 +770,7 @@ private TreeElement _tree18; private TreeElement _tree19; private TreeElement _tree20; - + private TreeElement _tree21; private String _expand = " "; private String _node = " "; @@ -933,6 +933,14 @@ public void setTree20(TreeElement tn) { _tree20 = tn; } + + public TreeElement getTree21() { + return _tree21; + } + + public void setTree21(TreeElement tn) { + _tree21 = tn; + } //************************************************************************ @@ -1065,6 +1073,26 @@ _tree5.addChild(tree1); } + // Build Tree Twenty + { + _tree21 = new TreeElement("Tree 0",true); + _tree21.setAction("postback"); + TreeElement t1 = new TreeElement("Node: 0.0",true); + _tree21.addChild(t1); + TreeElement t2 = new TreeElement("Node: 0.0.0",true); + t1.addChild(t2); + + TreeElement tree = new TreeElement("Node 0.1",true); + t1 = new TreeElement("Node: 0.1.0",true); + tree.addChild(t1); + t2 = new TreeElement("Node: 0.1.0.0",true); + t1.addChild(t2); + t2 = new TreeElement("Node: 0.1.0.1",true); + t1.addChild(t2); + _tree21.addChild(tree); + t1 = new TreeElement("Node: 0.2",true); + _tree21.addChild(t1); + } } @@ -1164,6 +1192,7 @@ _tree18 = null; _tree19 = null; _tree20 = null; + _tree21 = null; buildTrees(); return forward; @@ -1360,6 +1389,15 @@ @Jpf.Forward(name = "success", path = "encodeContent.jsp") }) protected Forward goEncodeContent() { + Forward success = new Forward("success"); + clearExpand(); + return success; + } + + @Jpf.Action(forwards = { + @Jpf.Forward(name = "success", path = "noRoot.jsp") +}) + protected Forward goNoRoot() { Forward success = new Forward("success"); clearExpand(); return success; Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp?view=diff&rev=125513&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp&r1=125512&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp&r2=125513 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/richTree/index.jsp Tue Jan 18 07:59:20 2005 @@ -23,7 +23,8 @@ <li><netui:anchor action="goOverride">Override tree attributes</netui:anchor> -- [tree17] Override tree attributes</li> <li><netui:anchor action="goOverrideTwo">Override tree attributes two</netui:anchor> -- [tree18] Override the whole tree actions from the root</li> <li><netui:anchor action="goHref">Verify Href</netui:anchor> -- [tree19] Verify that HRefs and target work</li> - <li><netui:anchor action="goEncodeContent">Encode Content</netui:anchor> -- [tree20] Verify that HRefs and target work</li> + <li><netui:anchor action="goEncodeContent">Encode Content</netui:anchor> -- [tree20] Verify escape for HTML works on labels and content</li> + <li><netui:anchor action="goNoRoot">No Root</netui:anchor> -- [tree21] Verify expand on client on a rootless tree</li> </ul> <h4>Client Side Support</h4> <ul>
