Author: nbelaevski
Date: 2007-05-22 15:26:59 -0400 (Tue, 22 May 2007)
New Revision: 835
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss
trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx
Log:
RF-220 fixed
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-05-22
19:15:55 UTC (rev 834)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-05-22
19:26:59 UTC (rev 835)
@@ -47,6 +47,11 @@
*/
protected final static String DEFAULT_NODE_FACE_ATTRIBUTE_NAME =
"#defaultNodeFace";
+ private final static String LEAF_FACET_NAME = "leaf";
+ private final static String ICON_FACET_NAME = "icon";
+ private final static String ICON_EXPANDED_FACET_NAME = "iconExpanded";
+ private final static String ICON_COLLAPSED_FACET_NAME = "iconCollapsed";
+
public abstract String getType();
public abstract void setType(String type);
@@ -268,6 +273,34 @@
}
}
+ private UIComponent getTreeFacet(String facetName) {
+ UIComponent facet = getFacet(facetName);
+ if (facet == null || !facet.isRendered()) {
+ UIComponent parentFacet = getUITree().getFacet(facetName);
+ if (facet == null || parentFacet != null && parentFacet.isRendered()) {
+ facet = parentFacet;
+ }
+ }
+
+ return facet;
+ }
+
+ public UIComponent getIconFacet() {
+ return getTreeFacet(ICON_FACET_NAME);
+ }
+
+ public UIComponent getLeafFacet() {
+ return getTreeFacet(LEAF_FACET_NAME);
+ }
+
+ public UIComponent getIconExpandedFacet() {
+ return getTreeFacet(ICON_EXPANDED_FACET_NAME);
+ }
+
+ public UIComponent getIconCollapsedFacet() {
+ return getTreeFacet(ICON_COLLAPSED_FACET_NAME);
+ }
+
public Object saveState(FacesContext context) {
Object[] state = new Object[3];
state[0] = super.saveState(context);
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
---
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-05-22
19:15:55 UTC (rev 834)
+++
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-05-22
19:26:59 UTC (rev 835)
@@ -216,6 +216,22 @@
}
}
+ private String getHandleDisplayStyle(FacesContext context, UITreeNode node, boolean
expandHandle) {
+ if (node.getUITree().isExpanded() ^ expandHandle) {
+ return "display: none;";
+ }
+
+ return "";
+ }
+
+ public String getHandleCollapsedDisplayStyle(FacesContext context, UITreeNode node) {
+ return getHandleDisplayStyle(context, node, false);
+ }
+
+ public String getHandleExpandedDisplayStyle(FacesContext context, UITreeNode node) {
+ return getHandleDisplayStyle(context, node, true);
+ }
+
protected void doDecode(FacesContext context, UIComponent component) {
super.doDecode(context, component);
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
---
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-05-22
19:15:55 UTC (rev 834)
+++
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-05-22
19:26:59 UTC (rev 835)
@@ -38,6 +38,7 @@
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.ComponentVariables;
import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
+import org.ajax4jsf.framework.renderer.RendererUtils;
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.ajax4jsf.framework.util.javascript.JSReference;
import org.ajax4jsf.framework.util.javascript.ScriptUtils;
@@ -398,13 +399,15 @@
ResponseWriter writer) throws IOException {
writer.startElement("table", tree);
- getUtils().writeAttribute(writer, "border", "0");
- getUtils().writeAttribute(writer, "cellpadding", "0");
- getUtils().writeAttribute(writer, "cellspacing", "0");
- getUtils().writeAttribute(writer, "id",
tree.getNodeFacet().getClientId(context));
- getUtils().writeAttribute(writer, "style", "width: 100%;");
- getUtils().writeAttribute(writer, "rich:nodeId",
tree.getNodeFacet().getId());
-
+ UITreeNode node = tree.getNodeFacet();
+
+ RendererUtils utils = getUtils();
+ utils.writeAttribute(writer, "border", "0");
+ utils.writeAttribute(writer, "cellpadding", "0");
+ utils.writeAttribute(writer, "cellspacing", "0");
+ utils.writeAttribute(writer, "id", node.getClientId(context));
+ utils.writeAttribute(writer, "style", "width: 100%;");
+ utils.writeAttribute(writer, "rich:nodeId", node.getId());
writer.startElement("tbody", tree);
}
Modified:
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss
===================================================================
---
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss 2007-05-22
19:15:55 UTC (rev 834)
+++
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss 2007-05-22
19:26:59 UTC (rev 835)
@@ -12,17 +12,17 @@
padding : 1px
}
-.dr-tree-h-ic-div {
- width: 16px;
-}
-
.dr-tree-h-ic-img{
margin: 0px;
display: block;
- wigth : 16px;
+ width : 16px;
height : 16px;
}
+.dr-tree-h-ic-facets{
+ overflow: hidden;
+}
+
.dr-tree-h-ic-line {
background-position: center;
background-repeat: repeat-y;
Modified: trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx
===================================================================
--- trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx 2007-05-22 19:15:55 UTC (rev
834)
+++ trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx 2007-05-22 19:26:59 UTC (rev
835)
@@ -8,8 +8,7 @@
xmlns:vcp="
http://ajax4jsf.org/cdk/vcp"
class="org.richfaces.renderkit.html.TreeNodeRenderer"
baseclass="org.richfaces.renderkit.NodeRendererBase"
- component="org.richfaces.component.UITreeNode"
- xmlns:ils="urn:intralinks">
+ component="org.richfaces.component.UITreeNode">
<f:clientId var="clientId" />
@@ -35,30 +34,86 @@
<tr id="#{clientId}:mainRow" >
<f:call name="encodeAttributeParameters" />
<td class="dr-tree-h-ic #{line}">
- <div class="dr-tree-h-ic-div" >
+ <div>
<jsp:scriptlet>
+ <![CDATA[
+ if (component.getUITree().isLeaf()) {
+ ]]>
+ </jsp:scriptlet>
+ <img id="#{clientId}:handle:img" src="#{spacer}"
alt="" class="dr-tree-h-ic-img" />
+ <jsp:scriptlet>
+ <![CDATA[
+ } else {
+ ]]>
+ </jsp:scriptlet>
+ <a href="#" id="#{clientId}:handle"
+ onclick="#{this:getToggleScript(context, component)} return
false;">
+
+ <jsp:scriptlet>
<![CDATA[
- if (component.getUITree().isLeaf()) {
+ UIComponent iconCollapsedFacet = component.getIconCollapsedFacet();
+ if (iconCollapsedFacet != null && iconCollapsedFacet.isRendered()) {
+ ]]>
+ </jsp:scriptlet>
+ <span id="#{clientId}:handle:img:collapsed"
+ class="dr-tree-pointer-cursor dr-tree-h-ic-img dr-tree-h-ic-facets"
+ style="#{this:getHandleCollapsedDisplayStyle(context,
component)}">
+
+ <jsp:scriptlet>
+ <![CDATA[
+ renderChild(context, iconCollapsedFacet);
+ ]]>
+ </jsp:scriptlet>
+ </span>
+ <jsp:scriptlet>
+ <![CDATA[
+ } else {
]]>
- </jsp:scriptlet> <img id="#{clientId}:handle:img"
src="#{spacer}" alt="" class="dr-tree-h-ic-img" />
<jsp:scriptlet>
+ </jsp:scriptlet>
+
+ <img border="0" id="#{clientId}:handle:img:collapsed"
+ src="#{collapsed}" class="dr-tree-pointer-cursor
dr-tree-h-ic-img"
+ style="#{this:getHandleCollapsedDisplayStyle(context, component)}"
alt="" />
+
+ <jsp:scriptlet>
<![CDATA[
- } else {
- ]]>
- </jsp:scriptlet> <a href="#" id="#{clientId}:handle"
- onclick="#{this:getToggleScript(context, component)} return false;">
<jsp:scriptlet>
- <![CDATA[if (component.getUITree().isExpanded()) {]]>
- </jsp:scriptlet> <img border="0"
id="#{clientId}:handle:img:collapsed"
- src="#{collapsed}" class="dr-tree-pointer-cursor
dr-tree-h-ic-img" style="display: none;" alt="" />
- <img border="0" id="#{clientId}:handle:img:expanded"
src="#{expanded}"
- class="dr-tree-pointer-cursor dr-tree-h-ic-img" alt="" />
<jsp:scriptlet>
- <![CDATA[} else {]]>
- </jsp:scriptlet> <img border="0"
id="#{clientId}:handle:img:collapsed"
- src="#{collapsed}" class="dr-tree-pointer-cursor
dr-tree-h-ic-img" alt="" /> <img border="0"
- id="#{clientId}:handle:img:expanded" src="#{expanded}"
- class="dr-tree-pointer-cursor dr-tree-h-ic-img" style="display:
none;" alt="" /> <jsp:scriptlet>
- <![CDATA[}]]>
- </jsp:scriptlet> </a> <jsp:scriptlet>
+ }
+ ]]>
+ </jsp:scriptlet>
+
+
+ <jsp:scriptlet>
+ <![CDATA[
+ UIComponent iconExpandedFacet = component.getIconExpandedFacet();
+ if (iconExpandedFacet != null && iconExpandedFacet.isRendered()) {
+ ]]>
+ </jsp:scriptlet>
+ <span id="#{clientId}:handle:img:expanded"
+ style="#{this:getHandleExpandedDisplayStyle(context, component)}"
+ class="dr-tree-pointer-cursor dr-tree-h-ic-img
dr-tree-h-ic-facets">
+
+ <jsp:scriptlet>
<![CDATA[
+ renderChild(context, iconExpandedFacet);
+ ]]>
+ </jsp:scriptlet>
+ </span>
+ <jsp:scriptlet>
+ <![CDATA[
+ } else {
+ ]]>
+ </jsp:scriptlet>
+ <img border="0" id="#{clientId}:handle:img:expanded"
src="#{expanded}"
+ style="#{this:getHandleExpandedDisplayStyle(context, component)}"
+ class="dr-tree-pointer-cursor dr-tree-h-ic-img" alt=""
/>
+ <jsp:scriptlet>
+ <![CDATA[
+ }
+ ]]>
+ </jsp:scriptlet>
+ </a>
+ <jsp:scriptlet>
+ <![CDATA[
}
]]>
</jsp:scriptlet>
@@ -76,17 +131,52 @@
<jsp:scriptlet>
<![CDATA[
if (component.getUITree().isLeaf()) {
+ UIComponent leafFacet = component.getLeafFacet();
+ if (leafFacet != null && leafFacet.isRendered()) {
+
]]>
</jsp:scriptlet>
- <img src="#{leaf}" alt="" class="dr-tree-h-ic-img"
/>
+ <span class="dr-tree-h-ic-img dr-tree-h-ic-facets">
+ <jsp:scriptlet>
+ <![CDATA[
+ renderChild(context, leafFacet);
+ ]]>
+ </jsp:scriptlet>
+ </span>
<jsp:scriptlet>
<![CDATA[
+ } else {
+ ]]>
+ </jsp:scriptlet>
+ <img src="#{leaf}" alt="" class="dr-tree-h-ic-img"
/>
+ <jsp:scriptlet>
+ <![CDATA[
+ }
+ ]]>
+ </jsp:scriptlet>
+ <jsp:scriptlet>
+ <![CDATA[
} else {
+ UIComponent iconFacet = component.getIconFacet();
+ if (iconFacet != null && iconFacet.isRendered()) {
]]>
</jsp:scriptlet>
- <img src="#{folder}" alt="" class="dr-tree-h-ic-img"
/>
+ <span class="dr-tree-h-ic-img dr-tree-h-ic-facets">
+ <jsp:scriptlet>
+ <![CDATA[
+ renderChild(context, iconFacet);
+ ]]>
+ </jsp:scriptlet>
+ </span>
<jsp:scriptlet>
<![CDATA[
+ } else {
+ ]]>
+ </jsp:scriptlet>
+ <img src="#{folder}" alt=""
class="dr-tree-h-ic-img" />
+ <jsp:scriptlet>
+ <![CDATA[
+ }
}
]]>
</jsp:scriptlet>