risks: small - isolated to dataselectionmanager
rewards: big - fixes longstanding annoying bugs, recently submitted by contributor
--
Regards,
Max Carlson
OpenLaszlo.org
--- Begin Message ---
Author: max
Date: 2007-04-06 22:50:00 -0700 (Fri, 06 Apr 2007)
New Revision: 4605

Modified:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/helpers/LzSelectionManager.lzs
Log:
Change 20070406-maxcarlson-R by [EMAIL PROTECTED] on 2007-04-06 09:13:46 PDT
    in /Users/maxcarlson/openlaszlo/legals-clean
    for http://svn.openlaszlo.org/openlaszlo/branches/legals

Summary: Fix DataselectionManager

New Features:

Bugs Fixed: LPP-414 - data selection manager doesn't update selection
LPP-1203 - Dataselectionmanager only works with a lazy replicated list
LPP-1644 - datalistselector fails to call setSelected() method if view was 
previously selected and was the only replicated view.

Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzSelectionManager.lzs - Add checking for clone manager, and paths 
with a single clone.  Submitted by Andre Bargull on laszlo-dev, subj 
'[Laszlo-dev] Basic approach to fix "LPP-414", "LPP-1203", "LPP-1644"':
Sometime time ago, I put together this little class to overcome several 
problems with "dataselectionmanager".
This quite basic fix would resolve these JIRA-Tasks. Comments?

Andre Bargull

Tests: Ran tests listed under LPP-414, LPP-1203, LPP-1644

Files:
M      WEB-INF/lps/lfc/helpers/LzSelectionManager.lzs

Changeset: 
http://svn.openlaszlo.org/openlaszlo/patches/20070406-maxcarlson-R.tar


Modified: 
openlaszlo/branches/legals/WEB-INF/lps/lfc/helpers/LzSelectionManager.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/helpers/LzSelectionManager.lzs   
2007-04-07 05:00:03 UTC (rev 4604)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/helpers/LzSelectionManager.lzs   
2007-04-07 05:50:00 UTC (rev 4605)
@@ -289,11 +289,16 @@
   */
 function makeSelected ( o ){
     var so = o.datapath.p;
-    if ( this.manager == null ) this.manager = o.cloneManager;
+    if ( this.manager == null ) this.manager = o.cloneManager; 
     if ( so.sel ) return; 
     so.sel = true;
     this.selected.push( so );
-    o.datapath[ this.sel ](true);
+    o.datapath[ this.sel ]( true );    
+    
+    if ( this.manager == null ){
+        //just one "clone", mark it!
+        this.singleClone = o;
+    }
 }
 
 /**
@@ -301,15 +306,19 @@
   * @param LzView o: The view to be unselected
   */
 function unselect ( o ){
+    if ( this.manager == null ) this.manager = o.cloneManager;//try to get a 
cloneManager  
+
     var so = o.datapath.p;
     so.sel = false;
-    for ( var i= this.selected.length-1 ; i >= 0; i-- ){
+    for ( var i = this.selected.length-1 ; i >= 0; i-- ){
         if ( this.selected[ i ] == so ) {
             this.selected.splice( i , 1 );
             break;
         }
-    }
-    o.datapath[ this.sel ](false);
+    }      
+    o.datapath[ this.sel ]( false );
+    
+    if ( o == this.singleClone ) this.singleClone = null;//clear "singleClone"
 }
 
 /**
@@ -320,6 +329,20 @@
   * @param LzView e: The newly selected view
   */
 function selectRange ( s , e ){
+    if ( this.manager == null ){        
+        this.manager = e.cloneManager;
+        
+        //maybe we've got now clones
+        if ( this.manager == null ){
+        //still no clones?          
+        //so it's nothing to do, just hope so...
+        if ( $debug ){
+            Debug.write( "selectRange failed, no clones" );
+        }
+        return;
+        }
+    }
+    
     var nodes = this.manager.nodes;
 
     var st = -1;
@@ -387,6 +410,8 @@
   * @param LzView o: The view to test for selectedness
   */
 function isSelected ( o){
+    if ( this.manager == null ) this.manager = o.cloneManager;//try to get a 
cloneManager
+
     return o.datapath.p.sel;
 }
 
@@ -398,11 +423,24 @@
   * @access private
   */
 function __LZsetSelected ( p, val ){
-    var cl = this.manager.getCloneForNode( p, true );
-    if (cl) {
-        cl.datapath[this.sel](val);
-    } else { // no clone on screen
-        p.sel = val;
+    if ( this.manager != null ){
+        var cl = this.manager.getCloneForNode( p, true );
+        if ( cl ){
+            cl.datapath[this.sel]( val );
+        } else { // no clone on screen
+            p.sel = val;
+        }
+    } else {//no clones
+        //if caller is selectRange, then "this.manager" won't be "null"
+        //but if caller is clearSelection, "this.manager" could be "null", but 
then "val" is definitely "false"
+        if ( !val ){
+            if ( this.singleClone != null && this.singleClone.datapath.p == p 
){
+                this.singleClone.datapath[this.sel]( false );
+                this.singleClone = null;
+                return;//job is done...
+            }
+        }
+        p.sel = val;//default action
     }
 }
 


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

--- End Message ---

Reply via email to