You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Adrian Crum <ad...@hlmksw.com> on 2008/07/25 17:08:27 UTC
Re: svn commit: r679798 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget:
html/HtmlTreeRenderer.java tree/ModelTree.java tree/TreeStringRenderer.java
Jacopo,
Thank you very much for all your work on this. It was something I have
always wanted to do but I didn't have the time.
-Adrian
jacopoc@apache.org wrote:
> Author: jacopoc
> Date: Fri Jul 25 06:22:46 2008
> New Revision: 679798
>
> URL: http://svn.apache.org/viewvc?rev=679798&view=rev
> Log:
> Misc cleanups to the widget tree code, still a lot to do to improve the readability of the code but this is hopefully a small step in that direction.
> Most of all, I have fixed a small issue that was preventing to work the first click (after visiting the page) for the expansion of a node.
>
> Modified:
> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.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=679798&r1=679797&r2=679798&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 Fri Jul 25 06:22:46 2008
> @@ -47,10 +47,9 @@
>
> public HtmlTreeRenderer() {}
>
> - public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth, boolean isLast) throws IOException {
> + public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth) throws IOException {
> String currentNodeTrailPiped = null;
> List<String> currentNodeTrail = UtilGenerics.toList(context.get("currentNodeTrail"));
> - String initialNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
> if (node.isRootNode()) {
> appendWhitespace(writer);
> renderBeginningBoundaryComment(writer, "Tree Widget", node.getModelTree());
> @@ -88,7 +87,7 @@
> 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, "|");
> @@ -102,7 +101,6 @@
> target += "&";
> }
> target += trailName + "=" + currentNodeTrailPiped;
> - target += "#" + initialNodeTrailPiped;
> expandCollapseLink.setTarget(target);
> }
> } else {
> @@ -123,12 +121,11 @@
> target += "&";
> }
> target += trailName + "=" + currentNodeTrailPiped;
> - target += "#" + initialNodeTrailPiped;
> expandCollapseLink.setTarget(target);
> // add it so it can be remove in renderNodeEnd
> currentNodeTrail.add(lastContentId);
> }
> - renderLink( writer, context, expandCollapseLink);
> + renderLink(writer, context, expandCollapseLink);
> } else if (!hasChildren){
> context.put("processChildren", Boolean.FALSE);
> }
>
> 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=679798&r1=679797&r2=679798&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 Fri Jul 25 06:22:46 2008
> @@ -57,8 +57,6 @@
> import org.w3c.dom.Element;
> import org.xml.sax.SAXException;
>
> -//import com.clarkware.profiler.Profiler;
> -
> /**
> * Widget Library - Tree model class
> */
> @@ -238,7 +236,7 @@
> context.put("currentNodeTrail", FastList.newInstance());
> StringWriter writer = new StringWriter();
> try {
> - node.renderNodeString(writer, context, treeStringRenderer, 0, true);
> + node.renderNodeString(writer, context, treeStringRenderer, 0);
> buf.append(writer.toString());
> } catch (IOException e2) {
> String errMsg = "Error rendering included label with name [" + name + "] : " + e2.toString();
> @@ -354,7 +352,7 @@
> }
>
> public void renderNodeString(Appendable writer, Map<String, Object> context,
> - TreeStringRenderer treeStringRenderer, int depth, boolean isLast)
> + TreeStringRenderer treeStringRenderer, int depth)
> throws IOException, GeneralException {
> boolean passed = true;
> if (this.condition != null) {
> @@ -376,10 +374,8 @@
> } else {
> id = (String) context.get(pkName);
> }
> - if (id != null) {
> - currentNodeTrail.add(id);
> - }
> - treeStringRenderer.renderNodeBegin(writer, context, this, depth, isLast);
> + currentNodeTrail.add(id);
> + treeStringRenderer.renderNodeBegin(writer, context, this, depth);
> //if (Debug.infoOn()) Debug.logInfo(" context:" +
> // context.entrySet(), module);
> try {
> @@ -430,9 +426,7 @@
> targetEntityId = (String) targetNodeTrail.get(newDepth);
> }
> if ((targetEntityId != null && targetEntityId.equals(thisEntityId)) || this.showPeers(newDepth, context)) {
> - boolean lastNode = !nodeIter.hasNext();
> - newContext.put("lastNode", Boolean.valueOf(lastNode));
> - node.renderNodeString(writer, newContext, treeStringRenderer, newDepth, lastNode);
> + node.renderNodeString(writer, newContext, treeStringRenderer, newDepth);
> }
> }
> }
>
> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java?rev=679798&r1=679797&r2=679798&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java Fri Jul 25 06:22:46 2008
> @@ -28,7 +28,7 @@
> */
> public interface TreeStringRenderer {
>
> - public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth, boolean isLast) throws IOException;
> + public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth) throws IOException;
> public void renderNodeEnd(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException;
> public void renderLabel(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Label label) throws IOException;
> public void renderLink(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Link link) throws IOException;
>
>
>
Re: svn commit: r679798 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget: html/HtmlTreeRenderer.java tree/ModelTree.java tree/TreeStringRenderer.java
Posted by Ashish Vijaywargiya <vi...@gmail.com>.
Jacopo,
Thanks for doing this.
On Fri, Jul 25, 2008 at 8:38 PM, Adrian Crum <ad...@hlmksw.com> wrote:
> Jacopo,
>
> Thank you very much for all your work on this. It was something I have
> always wanted to do but I didn't have the time.
>
> -Adrian
>
>
> jacopoc@apache.org wrote:
>
>> Author: jacopoc
>> Date: Fri Jul 25 06:22:46 2008
>> New Revision: 679798
>>
>> URL: http://svn.apache.org/viewvc?rev=679798&view=rev
>> Log:
>> Misc cleanups to the widget tree code, still a lot to do to improve the
>> readability of the code but this is hopefully a small step in that
>> direction.
>> Most of all, I have fixed a small issue that was preventing to work the
>> first click (after visiting the page) for the expansion of a node.
>>
>> Modified:
>>
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
>>
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.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=679798&r1=679797&r2=679798&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
>> Fri Jul 25 06:22:46 2008
>> @@ -47,10 +47,9 @@
>> public HtmlTreeRenderer() {}
>> - public void renderNodeBegin(Appendable writer, Map<String, Object>
>> context, ModelTree.ModelNode node, int depth, boolean isLast) throws
>> IOException {
>> + public void renderNodeBegin(Appendable writer, Map<String, Object>
>> context, ModelTree.ModelNode node, int depth) throws IOException {
>> String currentNodeTrailPiped = null;
>> List<String> currentNodeTrail =
>> UtilGenerics.toList(context.get("currentNodeTrail"));
>> - String initialNodeTrailPiped = StringUtil.join(currentNodeTrail,
>> "|");
>> if (node.isRootNode()) {
>> appendWhitespace(writer);
>> renderBeginningBoundaryComment(writer, "Tree Widget",
>> node.getModelTree());
>> @@ -88,7 +87,7 @@
>> 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, "|");
>> @@ -102,7 +101,6 @@
>> target += "&";
>> }
>> target += trailName + "=" + currentNodeTrailPiped;
>> - target += "#" + initialNodeTrailPiped;
>> expandCollapseLink.setTarget(target);
>> }
>> } else {
>> @@ -123,12 +121,11 @@
>> target += "&";
>> }
>> target += trailName + "=" + currentNodeTrailPiped;
>> - target += "#" + initialNodeTrailPiped;
>> expandCollapseLink.setTarget(target);
>> // add it so it can be remove in renderNodeEnd
>> currentNodeTrail.add(lastContentId);
>> }
>> - renderLink( writer, context, expandCollapseLink);
>> + renderLink(writer, context, expandCollapseLink);
>> } else if (!hasChildren){
>> context.put("processChildren", Boolean.FALSE);
>> }
>>
>> 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=679798&r1=679797&r2=679798&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
>> Fri Jul 25 06:22:46 2008
>> @@ -57,8 +57,6 @@
>> import org.w3c.dom.Element;
>> import org.xml.sax.SAXException;
>> -//import com.clarkware.profiler.Profiler;
>> -
>> /**
>> * Widget Library - Tree model class
>> */
>> @@ -238,7 +236,7 @@
>> context.put("currentNodeTrail", FastList.newInstance());
>> StringWriter writer = new StringWriter();
>> try {
>> - node.renderNodeString(writer, context, treeStringRenderer, 0,
>> true);
>> + node.renderNodeString(writer, context, treeStringRenderer,
>> 0);
>> buf.append(writer.toString());
>> } catch (IOException e2) {
>> String errMsg = "Error rendering included label with name [" +
>> name + "] : " + e2.toString();
>> @@ -354,7 +352,7 @@
>> }
>> public void renderNodeString(Appendable writer, Map<String,
>> Object> context,
>> - TreeStringRenderer treeStringRenderer, int depth, boolean
>> isLast)
>> + TreeStringRenderer treeStringRenderer, int depth)
>> throws IOException, GeneralException {
>> boolean passed = true;
>> if (this.condition != null) {
>> @@ -376,10 +374,8 @@
>> } else {
>> id = (String) context.get(pkName);
>> }
>> - if (id != null) { -
>> currentNodeTrail.add(id);
>> - }
>> - treeStringRenderer.renderNodeBegin(writer, context, this,
>> depth, isLast);
>> + currentNodeTrail.add(id);
>> + treeStringRenderer.renderNodeBegin(writer, context, this,
>> depth);
>> //if (Debug.infoOn()) Debug.logInfo(" context:" +
>> // context.entrySet(), module);
>> try {
>> @@ -430,9 +426,7 @@
>> targetEntityId = (String)
>> targetNodeTrail.get(newDepth);
>> }
>> if ((targetEntityId != null &&
>> targetEntityId.equals(thisEntityId)) || this.showPeers(newDepth, context)) {
>> - boolean lastNode = !nodeIter.hasNext();
>> - newContext.put("lastNode",
>> Boolean.valueOf(lastNode));
>> - node.renderNodeString(writer, newContext,
>> treeStringRenderer, newDepth, lastNode);
>> + node.renderNodeString(writer, newContext,
>> treeStringRenderer, newDepth);
>> }
>> }
>> }
>>
>> Modified:
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java?rev=679798&r1=679797&r2=679798&view=diff
>>
>> ==============================================================================
>> ---
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java
>> (original)
>> +++
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java
>> Fri Jul 25 06:22:46 2008
>> @@ -28,7 +28,7 @@
>> */
>> public interface TreeStringRenderer {
>> - public void renderNodeBegin(Appendable writer, Map<String, Object>
>> context, ModelTree.ModelNode node, int depth, boolean isLast) throws
>> IOException;
>> + public void renderNodeBegin(Appendable writer, Map<String, Object>
>> context, ModelTree.ModelNode node, int depth) throws IOException;
>> public void renderNodeEnd(Appendable writer, Map<String, Object>
>> context, ModelTree.ModelNode node) throws IOException;
>> public void renderLabel(Appendable writer, Map<String, Object>
>> context, ModelTree.ModelNode.Label label) throws IOException;
>> public void renderLink(Appendable writer, Map<String, Object> context,
>> ModelTree.ModelNode.Link link) throws IOException;
>>
>>
>>
>>
--
Ashish Vijaywargiya
Indore (M.P), India
http://en.wikipedia.org/wiki/Indore