incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r583633 - /incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js
Date Wed, 10 Oct 2007 22:25:36 GMT
Author: jmargaris
Date: Wed Oct 10 15:25:35 2007
New Revision: 583633

URL: http://svn.apache.org/viewvc?rev=583633&view=rev
Log:
now calling beging/end children changes efficiency hint

Modified:
    incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js

Modified: incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js?rev=583633&r1=583632&r2=583633&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js (original)
+++ incubator/xap/trunk/codebase/src/xap/data/controller/Iterator.js Wed Oct 10 15:25:35 2007
@@ -248,6 +248,7 @@
     /*int*/
     var iteratorLocationIndex = -1;
 // first remove the old iterated nodes
+
     for (var i = this._iteratedLocations.length - 1; i >= 0; i--) {
         /*Location*/
         var location = this._iteratedLocations[i];
@@ -266,8 +267,10 @@
         }
         location.remove();
     }
+
     return iteratorLocationIndex;
-//		}
+
+
 };
 /**
  * Reiterate relative to a parent iterator
@@ -294,15 +297,24 @@
 	//binding is ONLY ui for now. This will optimize the case where
 	//the bindings being added here resolve instantly and schedule
 	//their UI updates on the UI queue. If the bindings do not resolve
-	//instantly this won't have much effect. Note that the symmetrical
-	//unfreeze is scheduled at the very end of this method.
-   // this._session.getDisplayService().freezeUiUpdates(true);
+	//instantly this won't have much effect. N
     /*BindingResolver*/
     var resolver = xap.data.DataFramework.getDataService(this._session).getBindingResolver();
     /*ContextStack*/
     var oldContextStack = resolver.getContextStack();
     this._iterating = true;
     try {
+    
+            
+		// alert("iterate over data set with dataset size: " + this._dataSet.size() + " and id:
" + this._iteratorElement.getAttribute("id"));
+        // call beginChildrenChanges() in parent's peer to indicate bulk change
+		var parentHandler = this._session.getUiDocumentHandler().getHandlerForElement(this._parentElement);
+		var parentPeer = (parentHandler === undefined) ? null : parentHandler.getPeer();
+		if(parentPeer && parentPeer.beginChildrenChanges) {
+			parentPeer.beginChildrenChanges();
+		}
+    
+    
         /*int*/
         var insertIndex = this.cleanupCreation();
 				
@@ -316,10 +328,11 @@
 				//attribute resolution on each child binding that needs it
 				//as adding the clones will invoke the plug-in handling stuff
         if (this._dataSet.size() > 0) {
+
             for (var currentIndex = 0; currentIndex < this._dataSet.size(); currentIndex++)
{
                 this._contextStack.pushContext(new xap.data.controller.ContextFrame(this._dataSet,
currentIndex, this._name));
                 try {
-                    for (var childIndex = 0; childIndex < this._iteratorElement.getChildCount();
childIndex++) {
+                   for (var childIndex = 0; childIndex < this._iteratorElement.getChildCount();
childIndex++) {
                         /*Object*/
                         var child = this._iteratorElement.getChildAt(childIndex);
                         /*Location*/
@@ -348,17 +361,18 @@
                     }
                 }
                 finally {
-							//now that we are done with this iteration, pop the context
+ 					//now that we are done with this iteration, pop the context
                     this._contextStack.popContext();
                 }
-            }
-        } else {
+            } // end outer for()
+            
+       } else {
 					// No data, and we are ONE_TIME, so don't add a placeholder.
 					// if not one time, add placeholder like so:
             if (this._bindingType != xap.data.controller.BindingType.ONE_TIME) {
                 this._parentElement.insertChildAt(insertIndex, this._iteratorPlaceHolderElement);
                 /*xap.data.controller.ElementLocation*/
-                var location = new xap.data.controller.ElementLocation(this._iteratorPlaceHolderElement);
+                location = new xap.data.controller.ElementLocation(this._iteratorPlaceHolderElement);
                 this._iteratedLocations.push(location);
                 location.setLocationListener(this);
                 insertIndex++;
@@ -375,11 +389,16 @@
     }
     finally {
         this._iterating = false;
-				//now that we are done iterating return the state of the global context
+
+		//now that we are done iterating return the state of the global context
         resolver.setContextStack(oldContextStack);
-        //this._session.getUiUpdateQueue().invokeLater(new this.UiUpdatesUnfreezeTask(this._session));
+
+        // alert("iteration complete over data set with dataset size: " + this._dataSet.size()
+ " and id: " + this._iteratorElement.getAttribute("id"));
+		// call endChildrenChanges() in parent's peer to indicate end of bulk add
+		if(parentPeer && parentPeer.endChildrenChanges) {
+			parentPeer.endChildrenChanges();
+		}
     }
-//		}
 };
 /**
  * Set the binding type for the iterator.  It can be ONE_WAY or 
@@ -525,29 +544,3 @@
 xap.data.controller.Iterator.prototype.remove = function () {
     this.invalidate();
 };
-
-	
-//-----------------------------------------------------------------------
-// Private Class:
-//-----------------------------------------------------------------------
-/**
- * This task is used from iterateOverDataSet() method to schedule ui 
- * updates unfreeze. See comments in the above method for more information.
- */
-/**
- * @private
- * @constructor
- * @param aSession{xap.session.ClientSession}
-**/
-xap.data.controller.Iterator.prototype.UiUpdatesUnfreezeTask = new function (aSession) {
-    this._session = aSession;
-};
-Xap.setupClassAsSubclassOf("xap.data.controller.Iterator.prototype.UiUpdatesUnfreezeTask",
"Object");
-/**
- * @public
- * @return {void}
-**/
-xap.data.controller.Iterator.prototype.UiUpdatesUnfreezeTask.prototype.run = function ()
{
-    this._session.getDisplayService().freezeUiUpdates(false);
-};
-



Mime
View raw message