You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/02/26 21:41:52 UTC
svn commit: r1450399 - in
/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag:
TreeMenuNodeRenderer.java TreeNodeRenderer.java
Author: lofwyr
Date: Tue Feb 26 20:41:52 2013
New Revision: 1450399
URL: http://svn.apache.org/r1450399
Log:
TOBAGO-1232: Tree: grandchildren of non-expanded nodes are rendered regardless
Modified:
myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java
myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java?rev=1450399&r1=1450398&r2=1450399&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeMenuNodeRenderer.java Tue Feb 26 20:41:52 2013
@@ -125,14 +125,16 @@ public class TreeMenuNodeRenderer extend
// XXX todo: find a better way to determine the parentId
final String clientId = node.getClientId(facesContext);
- final int colon = clientId.lastIndexOf(":");
- final int underscore = clientId.substring(0, colon).lastIndexOf("_");
- final String parentId = root ? null : clientId.substring(0, underscore) + clientId.substring(colon);
+ final int colon2 = clientId.lastIndexOf(":");
+ final int colon1 = clientId.substring(0, colon2 - 1).lastIndexOf(":");
+ final String structure = clientId.substring(colon1 + 1, colon2);
+ String parentStructure = getParentStructure(structure);
+ final String parentId = root ? null : clientId.substring(0, colon1 + 1) + parentStructure + clientId.substring(colon2);
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
if (expanded) {
- tree.getExpandedCache().add(id);
+ tree.getExpandedCache().add(structure);
}
if (showRoot || !root) {
@@ -142,10 +144,16 @@ public class TreeMenuNodeRenderer extend
writer.writeAttribute(DataAttributes.TREEPARENT, parentId, false);
HtmlRendererUtils.writeDataAttributes(facesContext, writer, node);
- if (!root && !tree.getExpandedCache().contains(parentId)) {
- Style style = new Style();
- style.setDisplay(Display.NONE);
- writer.writeStyleAttribute(style);
+ if (!root) {
+ while (parentStructure != null) {
+ if (!tree.getExpandedCache().contains(parentStructure)) {
+ Style style = new Style();
+ style.setDisplay(Display.NONE);
+ writer.writeStyleAttribute(style);
+ break;
+ }
+ parentStructure = getParentStructure(parentStructure);
+ }
}
if (folder) {
@@ -173,6 +181,11 @@ public class TreeMenuNodeRenderer extend
}
+ private String getParentStructure(String structure) {
+ final int underscore = structure.lastIndexOf("_");
+ return underscore <= 0 ? null : structure.substring(0, underscore);
+ }
+
private void encodeExpandedHidden(
TobagoResponseWriter writer, UITreeNode node, String clientId, boolean expanded) throws IOException {
writer.startElement(HtmlElements.INPUT, node);
Modified: myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?rev=1450399&r1=1450398&r2=1450399&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.5.x/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Tue Feb 26 20:41:52 2013
@@ -144,14 +144,16 @@ public class TreeNodeRenderer extends La
// XXX todo: find a better way to determine the parentId
final String clientId = node.getClientId(facesContext);
- final int colon = clientId.lastIndexOf(":");
- final int underscore = clientId.substring(0, colon).lastIndexOf("_");
- final String parentId = root ? null : clientId.substring(0, underscore) + clientId.substring(colon);
+ final int colon2 = clientId.lastIndexOf(":");
+ final int colon1 = clientId.substring(0, colon2 - 1).lastIndexOf(":");
+ final String structure = clientId.substring(colon1 + 1, colon2);
+ String parentStructure = getParentStructure(structure);
+ final String parentId = root ? null : clientId.substring(0, colon1 + 1) + parentStructure + clientId.substring(colon2);
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
if (expanded) {
- tree.getExpandedCache().add(id);
+ tree.getExpandedCache().add(structure);
}
if (showRoot || !root) {
@@ -166,10 +168,16 @@ public class TreeNodeRenderer extends La
writer.writeAttribute(DataAttributes.TREEPARENT, parentId, false);
HtmlRendererUtils.writeDataAttributes(facesContext, writer, node);
- if (!root && !tree.getExpandedCache().contains(parentId)) {
- Style style = new Style();
- style.setDisplay(Display.NONE);
- writer.writeStyleAttribute(style);
+ if (!root) {
+ while (parentStructure != null) {
+ if (!tree.getExpandedCache().contains(parentStructure)) {
+ Style style = new Style();
+ style.setDisplay(Display.NONE);
+ writer.writeStyleAttribute(style);
+ break;
+ }
+ parentStructure = getParentStructure(parentStructure);
+ }
}
// div style (width)
@@ -198,6 +206,11 @@ public class TreeNodeRenderer extends La
}
+ private String getParentStructure(String structure) {
+ final int underscore = structure.lastIndexOf("_");
+ return underscore <= 0 ? null : structure.substring(0, underscore);
+ }
+
private void encodeExpandedHidden(
TobagoResponseWriter writer, UITreeNode node, String clientId, boolean expanded) throws IOException {
writer.startElement(HtmlElements.INPUT, node);