Author: nbelaevski
Date: 2010-10-31 10:54:14 -0400 (Sun, 31 Oct 2010)
New Revision: 19796
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml
sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml
Log:
https://jira.jboss.org/browse/RF-9315
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-10-31
14:01:38 UTC (rev 19795)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-10-31
14:54:14 UTC (rev 19796)
@@ -29,6 +29,7 @@
import javax.faces.context.ResponseWriter;
import org.richfaces.component.AbstractTree;
+import org.richfaces.component.SwitchType;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.renderkit.TreeRendererBase.NodeState;
import org.richfaces.renderkit.TreeRendererBase.QueuedData;
@@ -49,6 +50,8 @@
protected final AbstractTree tree;
+ private boolean traverseCollapsedNode;
+
private LinkedList<QueuedData> queuedData = new
LinkedList<QueuedData>();
public TreeEncoderBase(FacesContext context, AbstractTree tree) {
@@ -56,6 +59,8 @@
this.context = context;
this.responseWriter = context.getResponseWriter();
this.tree = tree;
+
+ this.traverseCollapsedNode = SwitchType.client.equals(tree.getToggleMode());
}
protected void encodeTree(Iterator<Object> childrenIterator) throws IOException
{
@@ -85,18 +90,19 @@
if (!data.isEncoded()) {
tree.setRowKey(context, data.getRowKey());
- writeTreeNodeStartElement(NodeState.expanded, data.isLastNode());
+ writeTreeNodeStartElement(data.isExpanded() ? NodeState.expanded :
NodeState.collapsed, data.isLastNode());
data.setEncoded(true);
}
}
-
- queuedData.add(new QueuedData(rowKey, isLastNode));
tree.setRowKey(context, rowKey);
- boolean iterateChildren = tree.isExpanded();
+ boolean expanded = tree.isExpanded();
+ queuedData.add(new QueuedData(rowKey, isLastNode, expanded));
+ boolean iterateChildren = traverseCollapsedNode || expanded;
+
if (iterateChildren) {
encodeTree(tree.getChildrenIterator(context, rowKey));
}
@@ -116,7 +122,7 @@
responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses("tree_node", isLast ?
"tree_node_last" : null),
+ HtmlUtil.concatClasses("rf-tr-nd", isLast ?
"rf-tr-nd-last" : null, nodeState.getNodeClass()),
null);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
tree.getClientId(context), null);
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-31
14:01:38 UTC (rev 19795)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-10-31
14:54:14 UTC (rev 19796)
@@ -63,24 +63,34 @@
private static final String NEW_STATE_PARAM =
"org.richfaces.Tree.NEW_STATE";
enum NodeState {
- expanded("tree_handle_expanded", "tree_icon_node"),
- collapsed("tree_handle_collapsed", "tree_icon_node"),
- leaf("tree_handle_leaf", "tree_icon_leaf");
+ expanded("rf-tr-nd-exp", "rf-trn-hnd-exp",
"rf-trn-ico-nd"),
+ collapsed("rf-tr-nd-colps", "rf-trn-hnd-colps",
"rf-trn-ico-nd"),
+ leaf("rf-tr-nd-lf", "rf-trn-hnd-lf",
"rf-trn-ico-lf");
+ private String nodeClass;
+
private String handleClass;
private String iconClass;
- private NodeState(String handleClass, String iconClass) {
+ private NodeState(String nodeClass, String handleClass, String iconClass) {
+ this.nodeClass = nodeClass;
this.handleClass = handleClass;
this.iconClass = iconClass;
}
+
+ public String getNodeClass() {
+ return nodeClass;
+ }
+
public String getHandleClass() {
return handleClass;
}
+
public String getIconClass() {
return iconClass;
}
+
}
static final class QueuedData {
@@ -89,11 +99,14 @@
private boolean lastNode;
+ private boolean expanded;
+
private boolean encoded;
- public QueuedData(Object rowKey, boolean lastNode) {
+ public QueuedData(Object rowKey, boolean lastNode, boolean expanded) {
this.rowKey = rowKey;
this.lastNode = lastNode;
+ this.expanded = expanded;
}
public void setEncoded(boolean encoded) {
@@ -111,6 +124,10 @@
public boolean isLastNode() {
return lastNode;
}
+
+ public boolean isExpanded() {
+ return expanded;
+ }
}
public void encodeTree(FacesContext context, UIComponent component) throws
IOException {
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-10-31
14:01:38 UTC (rev 19795)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-10-31
14:54:14 UTC (rev 19796)
@@ -1,4 +1,4 @@
-.tree_item {
+.rf-trn {
background: "url(#{resource['org.richfaces.images:last.gif']}) no-repeat
center left";
cursor: default;
font-size: '#{richSkin.generalSizeFont}';
@@ -10,34 +10,34 @@
white-space: nowrap;
}
-.tree_item_label {
+.rf-trn-lbl {
padding: 0px 4px 0px 2px;
vertical-align: middle;
cursor: pointer;
display: inline-block;
}
-.tree_selarea {
+.rf-trn-cnt {
display: inline-block;
}
-.tree_selected {
+.rf-tr-nd-sel {
background: '#{richSkin.additionalBackgroundColor}';
}
-.tree_node {
+.rf-tr-nd {
background: "url(#{resource['org.richfaces.images:line.gif']})
repeat-y";
}
-.tree_node_last {
+.rf-tr-nd-last {
background: none;
}
-.tree_node .tree_node {
+.rf-tr-nd .rf-tr-nd {
margin-left: 16px;
}
-.tree_icon, .tree_handle {
+.rf-trn-ico, .rf-trn-hnd {
vertical-align: middle;
margin: 0px;
cursor: pointer;
@@ -46,26 +46,26 @@
display: inline-block;
}
-.tree_handle_leaf {
+.rf-trn-hnd-lf {
cursor: default;
}
-.tree_handle_collapsed {
+.rf-trn-hnd-colps {
background: "url(#{resource['org.richfaces.images:plus.gif']}) no-repeat
center";
}
-.tree_handle_expanded {
+.rf-trn-hnd-exp {
background: "url(#{resource['org.richfaces.images:minus.gif']}) no-repeat
center";
}
-.tree_icon_node {
+.rf-trn-ico-nd {
background: "url(#{resource['org.richfaces.images:node_icon.gif']})
no-repeat center";
}
-.tree_icon_leaf {
+.rf-trn-ico-lf {
background: "url(#{resource['org.richfaces.images:leaf_icon.gif']})
no-repeat center";
}
-.tree_node.tree_collapse .tree_node {
+.rf-tr-nd.rf-tr-nd-colps .rf-tr-nd {
display: none;
}
Modified:
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
---
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-31
14:01:38 UTC (rev 19795)
+++
sandbox/trunk/ui/tree-actual/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-10-31
14:54:14 UTC (rev 19796)
@@ -23,7 +23,7 @@
var __initializeChildNodes = function(elt) {
var _this = this;
- $(elt).children(".tree_node").each(function() {
+ $(elt).children(".rf-tr-nd").each(function() {
_this.addChild(new richfaces.ui.TreeNode(this));
});
}
@@ -34,9 +34,9 @@
var TOGGLE_NEW_STATE_PARAM = "org.richfaces.Tree.NEW_STATE";
- var TREE_HANDLE_CLASSES = ["tree_collapse", "tree_expand"];
+ var TREE_CLASSES = ["rf-tr-nd-colps", "rf-tr-nd-exp"];
- var TREE_CLASSES = ["tree_handle_collapsed",
"tree_handle_expanded"];
+ var TREE_HANDLE_CLASSES = ["rf-trn-hnd-colps", "rf-trn-hnd-exp"];
richfaces.ui = richfaces.ui || {};
@@ -51,7 +51,7 @@
this.elt = $(this.attachToDom());
- this.handler = this.elt.find(" > .tree_item:first >
.tree_handle:first");
+ this.handler = this.elt.find(" > .rf-trn:first > .rf-trn-hnd:first");
this.handler.click($.proxy(this.toggle, this));
__initializeChildNodes.call(this, this.elt[0]);
@@ -100,15 +100,15 @@
},
isExpanded: function() {
- return !this.isLeaf() && !this.isCollapsed();
+ return !this.isLeaf() && this.handler.hasClass("rf-trn-hnd-exp");
},
isCollapsed: function() {
- return !this.isLeaf() &&
this.handler.hasClass("tree_handle_collapsed");
+ return !this.isLeaf() && this.handler.hasClass("rf-trn-hnd-colps");
},
isLeaf: function() {
- return this.handler.hasClass("tree_handle_leaf");
+ return this.handler.hasClass("rf-trn-hnd-lf");
},
toggle: function() {
@@ -129,8 +129,8 @@
switch (tree.getToggleMode()) {
case 'client':
- this.elt.addClass(TREE_HANDLE_CLASSES[newState ? 1 :
0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
- this.handler.addClass(TREE_CLASSES[newState ? 1 :
0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
+ this.elt.addClass(TREE_CLASSES[newState ? 1 :
0]).removeClass(TREE_CLASSES[!newState ? 1 : 0]);
+ this.handler.addClass(TREE_HANDLE_CLASSES[newState ? 1 :
0]).removeClass(TREE_HANDLE_CLASSES[!newState ? 1 : 0]);
break;
case 'ajax':
@@ -177,13 +177,13 @@
richfaces.ui.TreeNode.initNodeByAjax = function(nodeId) {
var node = $(document.getElementById(nodeId));
- if (node.nextAll(".tree_node:first").length != 0) {
- node.removeClass("tree_node_last");
+ if (node.nextAll(".rf-tr-nd:first").length != 0) {
+ node.removeClass("rf-tr-nd-last");
}
- var parent = node.parent(".tree_node, .rf-tree");
+ var parent = node.parent(".rf-tr-nd, .rf-tr");
- var idx = node.prevAll(".tree_node").length;
+ var idx = node.prevAll(".rf-tr-nd").length;
var parentNode = richfaces.$(parent[0]);
parentNode.addChild(new richfaces.ui.TreeNode(node[0]), idx);
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml 2010-10-31
14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/templates/tree.template.xml 2010-10-31
14:54:14 UTC (rev 19796)
@@ -19,7 +19,7 @@
</cc:interface>
<cc:implementation>
- <div id="#{clientId}" class="#{concatClasses('rf-tree',
component.attributes['styleClass'])}"
+ <div id="#{clientId}" class="#{concatClasses('rf-tr',
component.attributes['styleClass'])}"
cdk:passThroughWithExclusions="">
<cdk:body>
<cdk:call expression="encodeTree(facesContext, component)"
/>
Modified: sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml
===================================================================
--- sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml 2010-10-31
14:01:38 UTC (rev 19795)
+++ sandbox/trunk/ui/tree-actual/ui/src/main/templates/treeNode.template.xml 2010-10-31
14:54:14 UTC (rev 19796)
@@ -16,11 +16,11 @@
</cc:interface>
<cc:implementation>
- <div class="tree_item">
- <div class="tree_handle
#{facesContext.attributes['__treeNodeHandleClass']}"></div>
- <div class="tree_selarea">
- <div class="tree_icon
#{facesContext.attributes['__treeNodeIconClass']}"></div>
- <span class="tree_item_label">
+ <div class="rf-trn">
+ <div class="rf-trn-hnd
#{facesContext.attributes['__treeNodeHandleClass']}"></div>
+ <div class="rf-trn-cnt">
+ <div class="rf-trn-ico
#{facesContext.attributes['__treeNodeIconClass']}"></div>
+ <span class="rf-trn-lbl">
<cdk:body />
</span>
</div>