|
From: <ssk...@vh...> - 2006-06-22 14:10:45
|
Author: sskracic
Date: 2006-06-22 16:05:49 +0200 (Thu, 22 Jun 2006)
New Revision: 1233
Modified:
trunk/ccm-core/src/com/arsdigita/bebop/Tree.java
Log:
Closing an opened DataQuery, the hard way.
Modified: trunk/ccm-core/src/com/arsdigita/bebop/Tree.java
===================================================================
--- trunk/ccm-core/src/com/arsdigita/bebop/Tree.java 2006-06-22 13:00:58 UTC (rev 1232)
+++ trunk/ccm-core/src/com/arsdigita/bebop/Tree.java 2006-06-22 14:05:49 UTC (rev 1233)
@@ -617,15 +617,19 @@
}
private boolean hasSelectedChild(TreeModel tree, TreeNode node, PageState data, Object selKey) {
- String nodeKey = (String) node.getKey();
+ String nodeKey = (String) node.getKey();
if ( (selKey != null) && (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey)) ) {
- return true;
+ return true;
}
- Iterator i = tree.getChildren(node, data);
+ Iterator i = tree.getChildren(node, data);
while (i.hasNext()) {
TreeNode child = (TreeNode) i.next();
if (hasSelectedChild(tree, child, data, selKey)) {
- return true;
+ // At this point we should close the opened DataQuery pointed to by Iterator (i).
+ // Since the data query is wrapped within DataQueryIterator, we don't have
+ // access to it directly, so this looks like the only viable option ...
+ while (i.hasNext()) { }
+ return true;
}
}
return false;
@@ -643,19 +647,18 @@
String nodeKey = (String) node.getKey();
Object selKey = getSelectedKey(data);
boolean isSelected = (selKey != null)
- && (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey));
+ && (selKey.equals(nodeKey) || selKey.toString().equals(nodeKey));
boolean hasSelectedChild = false;
boolean hasChildren = tree.hasChildren(node, data);
if (!isSelected && hasChildren) {
- hasSelectedChild = hasSelectedChild(tree, node, data, selKey);
+ hasSelectedChild = hasSelectedChild(tree, node, data, selKey);
}
t_node.addAttribute("isSelected", String.valueOf(isSelected | hasSelectedChild));
-
+
if (hasChildren) {
boolean collapsed = isCollapsed(nodeKey,data);
- data.setControlEvent(this, collapsed ? EXPAND_EVENT
- : COLLAPSE_EVENT, nodeKey);
+ data.setControlEvent(this, collapsed ? EXPAND_EVENT : COLLAPSE_EVENT, nodeKey);
try {
t_node.addAttribute("href", data.stateAsURL());
} catch (java.io.IOException ioe) {
|