You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2008/07/23 18:42:32 UTC
svn commit: r679126 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget:
html/HtmlTreeRenderer.java tree/ModelTree.java
Author: jacopoc
Date: Wed Jul 23 09:42:32 2008
New Revision: 679126
URL: http://svn.apache.org/viewvc?rev=679126&view=rev
Log:
Misc code cleanups: formatting fixes, renamed some variables, removed useless code.
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java?rev=679126&r1=679125&r2=679126&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java Wed Jul 23 09:42:32 2008
@@ -46,23 +46,11 @@
public static final String module = HtmlTreeRenderer.class.getName();
public HtmlTreeRenderer() {}
-
- public static String buildPathString(ModelTree modelTree, int depth) {
- StringBuffer buf = new StringBuffer();
- for (int i=1; i <= depth; i++) {
- int idx = modelTree.getNodeIndexAtDepth(i);
- buf.append(".");
- buf.append(Integer.toString(idx + 1));
- }
- return buf.toString();
- }
public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth, boolean isLast) throws IOException {
-
- String pathString = buildPathString(node.getModelTree(), depth);
String currentNodeTrailPiped = null;
List<String> currentNodeTrail = UtilGenerics.toList(context.get("currentNodeTrail"));
- String staticNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
+ String initialNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
if (node.isRootNode()) {
appendWhitespace(writer);
renderBeginningBoundaryComment(writer, "Tree Widget", node.getModelTree());
@@ -96,17 +84,14 @@
ModelTree.ModelNode.Image expandCollapseImage = new ModelTree.ModelNode.Image();
expandCollapseImage.setBorder("0");
ModelTree.ModelNode.Link expandCollapseLink = new ModelTree.ModelNode.Link();
- //String currentNodeTrailCsv = (String)context.get("currentNodeTrailCsv");
int openDepth = node.getModelTree().getOpenDepth();
if (depth >= openDepth && (targetEntityId == null || !targetEntityId.equals(entityId))) {
// Not on the trail
- if( node.showPeers(depth, context)) {
+ if(node.showPeers(depth, context)) {
context.put("processChildren", Boolean.FALSE);
//expandCollapseLink.setText(" + ");
currentNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
- context.put("currentNodeTrailPiped", currentNodeTrailPiped);
- //context.put("currentNodeTrailCsv", currentNodeTrailCsv);
expandCollapseLink.setStyle("collapsed");
expandCollapseLink.setText(" ");
String target = node.getModelTree().getExpandCollapseRequest(context);
@@ -117,8 +102,7 @@
target += "&";
}
target += trailName + "=" + currentNodeTrailPiped;
- target += "#" + staticNodeTrailPiped;
- //expandCollapseLink.setTarget("/ViewOutline?docRootContentId=${docRootContentId}&targetNodeTrailCsv=${currentNodeTrailCsv}");
+ target += "#" + initialNodeTrailPiped;
expandCollapseLink.setTarget(target);
}
} else {
@@ -129,30 +113,24 @@
if (currentNodeTrailPiped == null) {
currentNodeTrailPiped = "";
}
- context.put("currentNodeTrailPiped", currentNodeTrailPiped);
- //context.put("currentNodeTrailCsv", currentNodeTrailCsv);
expandCollapseLink.setStyle("expanded");
expandCollapseLink.setText(" ");
String target = node.getModelTree().getExpandCollapseRequest(context);
String trailName = node.getModelTree().getTrailName(context);
- if (target.indexOf("?") < 0) target += "?";
- else target += "&";
+ if (target.indexOf("?") < 0) {
+ target += "?";
+ } else {
+ target += "&";
+ }
target += trailName + "=" + currentNodeTrailPiped;
- target += "#" + staticNodeTrailPiped;
+ target += "#" + initialNodeTrailPiped;
expandCollapseLink.setTarget(target);
// add it so it can be remove in renderNodeEnd
currentNodeTrail.add(lastContentId);
- currentNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
- if (currentNodeTrailPiped == null) {
- currentNodeTrailPiped = "";
- }
- context.put("currentNodeTrailPiped", currentNodeTrailPiped);
}
renderLink( writer, context, expandCollapseLink);
} else if (!hasChildren){
- //writer.append(" ");
context.put("processChildren", Boolean.FALSE);
- //currentNodeTrail.add(contentId);
}
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=679126&r1=679125&r2=679126&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Wed Jul 23 09:42:32 2008
@@ -79,7 +79,6 @@
protected FlexibleStringExpander trailNameExdr;
protected int openDepth;
protected int postTrailOpenDepth;
- protected int [] nodeIndices = new int[20];
protected String defaultEntityName;
protected String defaultPkName;
protected boolean forceChildCheck;
@@ -172,14 +171,6 @@
return postTrailOpenDepth;
}
- public int getNodeIndexAtDepth(int i) {
- return nodeIndices[i];
- }
-
- public void setNodeIndexAtDepth(int i, int val) {
- nodeIndices[i] = val;
- }
-
public String getExpandCollapseRequest(Map<String, Object> context) {
String expColReq = this.expandCollapseRequestExdr.expandString(context);
if (UtilValidate.isEmpty(expColReq)) {
@@ -388,8 +379,6 @@
if (id != null) {
currentNodeTrail.add(id);
}
- String currentNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
- context.put("currentNodeTrailPiped", currentNodeTrailPiped);
treeStringRenderer.renderNodeBegin(writer, context, this, depth, isLast);
//if (Debug.infoOn()) Debug.logInfo(" context:" +
// context.entrySet(), module);
@@ -417,11 +406,8 @@
if (processChildren.booleanValue()) {
getChildren(context);
Iterator nodeIter = this.subNodeValues.iterator();
- int nodeIndex = -1;
int newDepth = depth + 1;
while (nodeIter.hasNext()) {
- nodeIndex++;
- modelTree.setNodeIndexAtDepth(newDepth, nodeIndex);
Object[] arr = (Object[]) nodeIter.next();
ModelNode node = (ModelNode) arr[0];
Map<String, Object> val = UtilGenerics.checkMap(arr[1]);
@@ -438,7 +424,6 @@
} else {
newContext.putAll(val);
}
- newContext.put("currentNodeIndex", Integer.valueOf(nodeIndex));
String targetEntityId = null;
List targetNodeTrail = UtilGenerics.checkList(context.get("targetNodeTrail"));
if (newDepth < targetNodeTrail.size()) {