Repository: flex-asjs
Updated Branches:
  refs/heads/develop 2b2c10092 -> e830366e4


Fixed SimpleDataProviderChangeNotifier and renamed it to 
EasyDataProviderChangeNotifier


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

Branch: refs/heads/develop
Commit: e830366e44f9643c30e62a2edcf998e8d36ac6cf
Parents: 2b2c100
Author: Harbs <ha...@in-tools.com>
Authored: Wed Aug 9 13:42:37 2017 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Wed Aug 9 13:42:37 2017 +0300

----------------------------------------------------------------------
 .../beads/EasyDataProviderChangeNotifier.as     | 108 +++++++++++++++++++
 .../beads/SimpleDataProviderChangeNotifier.as   |  90 ----------------
 .../Basic/src/main/resources/basic-manifest.xml |   2 +-
 3 files changed, 109 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e830366e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/EasyDataProviderChangeNotifier.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/EasyDataProviderChangeNotifier.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/EasyDataProviderChangeNotifier.as
new file mode 100644
index 0000000..0832581
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/EasyDataProviderChangeNotifier.as
@@ -0,0 +1,108 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.beads
+{
+       import org.apache.flex.collections.ArrayList;
+       import org.apache.flex.core.ISelectionModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.events.IEventDispatcher;
+
+    /**
+        *  The EasyDataProviderChangeNotifier is similar to 
DataProviderChangeNotifier
+        *  but allows the user to populate the data provider after it's been 
added.
+        *  Also, no attributes are required. Just add 
<EasyDataProviderChangeNotifier/>.
+        *  The dataProvider is assumed to be an ArrayList.
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.0
+        */
+       public class EasyDataProviderChangeNotifier extends 
DataProviderChangeNotifier
+       {
+               /**
+                *  constructor.
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.0
+                */
+               public function EasyDataProviderChangeNotifier()
+               {
+                       super();
+                       changeEventName = "dataProviderChanged";
+               }
+               
+               override public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       if(changeEventName)
+                               
selectionModel.addEventListener(changeEventName, destinationChangedHandler);
+                       
+                       destinationChangedHandler(null);
+               }
+               
+               override protected function 
destinationChangedHandler(event:Event):void
+               {
+                       if (!dataProvider)
+                       {
+                               setDataProvider();
+                               if (!dataProvider && !changeEventName)
+                                       
selectionModel.addEventListener("dataProviderChanged", setFirstDataProvider);
+                               
+                       } else
+                       {
+                               if(dataProvider == selectionModel.dataProvider)
+                                       return;
+                               detachEventListeners();
+                               setDataProvider();
+                               attachEventListeners();
+                       }
+               }
+               
+               private function setFirstDataProvider(e:Event):void
+               {
+                       setDataProvider();
+                       
selectionModel.removeEventListener("dataProviderChanged", setFirstDataProvider);
+               }
+               
+               /**
+                * @flexjsignorecoercion org.apache.flex.collections.ArrayList
+                */
+               private function setDataProvider():void
+               {
+                       dataProvider = selectionModel.dataProvider as ArrayList;
+                       if(dataProvider)
+                               attachEventListeners();
+               }
+               
+               /**
+                * @flexjsignorecoercion org.apache.flex.core.UIBase
+                * @flexjsignorecoercion org.apache.flex.core.ISelectionModel
+                */
+               private function get selectionModel():ISelectionModel
+               {
+                       return (_strand as UIBase).model as ISelectionModel;
+               }
+               
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e830366e/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as
deleted file mode 100644
index 1d55c76..0000000
--- 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as
+++ /dev/null
@@ -1,90 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You 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
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.flex.html.beads
-{
-       import org.apache.flex.collections.ArrayList;
-       import org.apache.flex.core.ISelectionModel;
-       import org.apache.flex.core.IStrand;
-       import org.apache.flex.events.Event;
-
-    /**
-        *  The SimpleDataProviderChangeNotifier is similar to 
DataProviderChangeNotifier
-        *  but allows the user to populate the data provider after it's been 
added.
-        *  Also, no attributes are required. Just add 
<SimpleDataProviderChangeNotifier/>.
-        *  The dataProvider is assumed to be an ArrayList.
-        *  
-        *  @langversion 3.0
-        *  @playerversion Flash 10.2
-        *  @playerversion AIR 2.6
-        *  @productversion FlexJS 0.0
-        */
-       public class SimpleDataProviderChangeNotifier extends 
DataProviderChangeNotifier
-       {
-               /**
-                *  constructor.
-                *  
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion FlexJS 0.0
-                */
-               public function SimpleDataProviderChangeNotifier()
-               {
-                       super();
-               }
-               
-               override public function set strand(value:IStrand):void
-               {
-                       _strand = value;
-                       destinationChangedHandler(null);
-               }
-               
-               override protected function 
destinationChangedHandler(event:Event):void
-               {
-                       if (!dataProvider)
-                       {
-                               setDataProvider();
-                               if (!dataProvider)
-                                       
selectionModel.addEventListener("dataProviderChanged", setFirstDataProvider);
-                       } else
-                       {
-                               detachEventListeners();
-                               attachEventListeners();
-                       }
-               }
-               
-               private function setFirstDataProvider(e:Event):void
-               {
-                       setDataProvider();
-                       
selectionModel.removeEventListener("dataProviderChanged", setFirstDataProvider);
-                       destinationChangedHandler(null);
-               }
-               
-               private function setDataProvider():void
-               {
-                       dataProvider = selectionModel.dataProvider as ArrayList;
-               }
-               
-               private function get selectionModel():ISelectionModel
-               {
-                       return _strand.getBeadByType(ISelectionModel) as 
ISelectionModel;
-               }
-               
-       }
-}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e830366e/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 43206f7..9df3370 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -129,7 +129,7 @@
 
     <component id="DataGrid" class="org.apache.flex.html.DataGrid"/>
     <component id="DataProviderChangeNotifier" 
class="org.apache.flex.html.beads.DataProviderChangeNotifier"/>
-    <component id="SimpleDataProviderChangeNotifier" 
class="org.apache.flex.html.beads.SimpleDataProviderChangeNotifier"/>
+    <component id="EasyDataProviderChangeNotifier" 
class="org.apache.flex.html.beads.EasyDataProviderChangeNotifier"/>
     <component id="DataProviderCollectionChangeNotifier" 
class="org.apache.flex.html.beads.DataProviderCollectionChangeNotifier"/>
     <component id="DataProviderItemsChangeNotifier" 
class="org.apache.flex.html.beads.DataProviderItemsChangeNotifier"/>
     <component id="DataGridButtonBar" 
class="org.apache.flex.html.DataGridButtonBar"/>

Reply via email to