Updated DataProviderChangeNotifier to listen for replacement of the 
dataProvider itself.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/e0ac88c5
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/e0ac88c5
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/e0ac88c5

Branch: refs/heads/develop
Commit: e0ac88c5a8efed5c26b4d3a08d772714617b9988
Parents: f9c4a01
Author: Peter Ent <p...@apache.org>
Authored: Mon Sep 19 15:38:24 2016 -0400
Committer: Peter Ent <p...@apache.org>
Committed: Mon Sep 19 15:38:24 2016 -0400

----------------------------------------------------------------------
 .../html/beads/DataProviderChangeNotifier.as    | 42 +++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e0ac88c5/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as
index c639b90..a24810b 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataProviderChangeNotifier.as
@@ -19,9 +19,12 @@
 package org.apache.flex.html.beads
 {
        import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IBeadModel;
        import org.apache.flex.core.IDocument;
        import org.apache.flex.core.ISelectionModel;
        import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.events.IEventDispatcher;
        import org.apache.flex.events.Event;
        import org.apache.flex.collections.ArrayList;
        
@@ -64,15 +67,30 @@ package org.apache.flex.html.beads
                {
                        _strand = value;
                        
+                       if (_strand[destinationPropertyName] == null) {
+                               var model:IBeadModel = UIBase(_strand).model as 
IBeadModel;
+                               
IEventDispatcher(model).addEventListener(changeEventName, 
destinationChangedHandler);
+                       }
+                       else {
+                               destinationChangedHandler(null);
+                       }
+               }
+               
+               private function destinationChangedHandler(event:Event):void
+               {
                        if (_dataProvider == null) {
                                var object:Object = document[sourceID];
                                _dataProvider = object[propertyName] as 
ArrayList;
                        }
+                       else {
+                               _dataProvider.removeEventListener("itemAdded", 
handleItemAdded);
+                               
_dataProvider.removeEventListener("itemRemoved", handleItemRemoved);
+                               
_dataProvider.removeEventListener("itemUpdated", handleItemUpdated);
+                       }
                        
                        _dataProvider.addEventListener("itemAdded", 
handleItemAdded);
                        _dataProvider.addEventListener("itemRemoved", 
handleItemRemoved);
                        _dataProvider.addEventListener("itemUpdated", 
handleItemUpdated);
-
                }
                
                protected var document:Object;
@@ -85,6 +103,28 @@ package org.apache.flex.html.beads
                        this.document = document;
                }
                
+               private var _destinationPropertyName:String;
+               
+               public function get destinationPropertyName():String
+               {
+                       return _destinationPropertyName;
+               }
+               public function set destinationPropertyName(value:String):void
+               {
+                       _destinationPropertyName = value;
+               }
+               
+               private var _changeEventName:String;
+               
+               public function get changeEventName():String
+               {
+                       return _changeEventName;
+               }
+               public function set changeEventName(value:String):void
+               {
+                       _changeEventName = value;
+               }
+               
                private var _sourceID:String;
                
                /**

Reply via email to