You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2014/08/27 00:51:55 UTC

git commit: TAP5-2020: Tree label block should be rendered inside an heartbeat

Repository: tapestry-5
Updated Branches:
  refs/heads/master 462de6418 -> 898364269


TAP5-2020: Tree label block should be rendered inside an heartbeat


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/89836426
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/89836426
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/89836426

Branch: refs/heads/master
Commit: 89836426940a91bb140627743407326fbebee143
Parents: 462de64
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Aug 26 15:51:46 2014 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Aug 26 15:51:46 2014 -0700

----------------------------------------------------------------------
 .../tapestry5/corelib/components/Tree.java      | 31 +++++++++++++++++---
 1 file changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/89836426/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java
index 97de13f..f44b2f0 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Tree.java
@@ -1,5 +1,3 @@
-// Copyright 2011-2013 The Apache Software Foundation
-//
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
@@ -25,6 +23,7 @@ import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.json.JSONObject;
 import org.apache.tapestry5.runtime.RenderCommand;
 import org.apache.tapestry5.runtime.RenderQueue;
+import org.apache.tapestry5.services.Heartbeat;
 import org.apache.tapestry5.services.javascript.JavaScriptSupport;
 import org.apache.tapestry5.tree.*;
 
@@ -37,7 +36,7 @@ import java.util.List;
  * implemented, only leaf nodes may be selected).
  * <p/>
  * Tree is <em>not</em> a form control component; all changes made to the tree on the client
- * (expansions, collapsing, and selections) are propogated immediately back to the server.
+ * (expansions, collapsing, and selections) are propagated immediately back to the server.
  * <p/>
  * The Tree component uses special tricks to support recursive rendering of the Tree as necessary.
  *
@@ -141,10 +140,14 @@ public class Tree
         }
     };
 
+    @Environmental
+    private Heartbeat heartbeat;
+
     /**
      * Renders a single node (which may be the last within its containing node).
      * This is a mix of immediate rendering, and queuing up various Blocks and Render commands
-     * to do the rest. May recursively render child nodes of the active node.
+     * to do the rest. May recursively render child nodes of the active node. The label part
+     * of the node is rendered inside a {@linkplain org.apache.tapestry5.services.Heartbeat heartbeat}.
      *
      * @param node
      *         to render
@@ -209,8 +212,28 @@ public class Tree
                 }
 
                 queue.push(RENDER_CLOSE_TAG);
+                final RenderCommand startHeartbeat = new RenderCommand() {
+
+                    @Override
+                    public void render(MarkupWriter writer, RenderQueue queue) {
+                        heartbeat.begin();
+                    }
+                };
+
+                final RenderCommand endHeartbeat = new RenderCommand() {
+
+                    @Override
+                    public void render(MarkupWriter writer, RenderQueue queue) {
+                        heartbeat.end();
+                    }
+                };
+
+                queue.push(endHeartbeat);
+
                 queue.push(label);
 
+                queue.push(startHeartbeat);
+
                 if (isLeaf && selectionModel != null && selectionModel.isSelected(node))
                 {
                     queue.push(MARK_SELECTED);