royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject [royale-asjs] branch develop updated: Add DynamicRemoveAllByNullItemRendererForArrayListData
Date Sat, 16 Dec 2017 12:30:37 GMT
This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new eb358af  Add DynamicRemoveAllByNullItemRendererForArrayListData
eb358af is described below

commit eb358afc0fdc33f398ff9733b9b21ebbba2c6e6b
Author: Piotr Zarzycki <piotrzarzycki21@gmail.com>
AuthorDate: Sat Dec 16 13:30:28 2017 +0100

    Add DynamicRemoveAllByNullItemRendererForArrayListData
    
    Add DynamicRemoveAllByNullItemRendererForArrayListData  which allows to remove all rows
from the list when dataProvider is being set to null
---
 .../MDLDynamicTableExample/src/MainView.mxml       |  9 +++++
 .../Basic/src/main/resources/basic-manifest.xml    |  1 +
 ...RemoveAllByNullItemRendererForArrayListData.as} | 44 +++++++---------------
 ...DynamicRemoveAllItemRendererForArrayListData.as |  6 +--
 4 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/examples/royale/MDLDynamicTableExample/src/MainView.mxml b/examples/royale/MDLDynamicTableExample/src/MainView.mxml
index e484cac..c450cc6 100644
--- a/examples/royale/MDLDynamicTableExample/src/MainView.mxml
+++ b/examples/royale/MDLDynamicTableExample/src/MainView.mxml
@@ -40,6 +40,11 @@ limitations under the License.
 			usersListModel.users.removeAll();	
 		}		
 		
+		private function onRemoveAllByNullClick(event:MouseEvent):void
+		{
+			tblUsers.dataProvider = null;	
+		}		
+		
 		private function onTblChange(event:Event):void
 		{
 			var selIndex:int = tblUsers.selectedIndex;
@@ -69,6 +74,7 @@ limitations under the License.
 				<js:DynamicItemsRendererFactoryForArrayListData />
 				<js:DynamicRemoveItemRendererForArrayListData />
 				<js:DynamicRemoveAllItemRendererForArrayListData />
+				<js:DynamicRemoveAllByNullItemRendererForArrayListData />
 			</mdl:beads>
 		</mdl:Table>
 	</mdl:GridCell>
@@ -81,4 +87,7 @@ limitations under the License.
 	<mdl:GridCell>
 		<mdl:Button text="Remove All" width="130" click="onRemoveAllClick(event)"/>
 	</mdl:GridCell>
+	<mdl:GridCell>
+		<mdl:Button text="Remove All by Null" width="150" click="onRemoveAllByNullClick(event)"/>
+	</mdl:GridCell>
 </mdl:Grid>
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index d0bf629..0aba42a 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -154,6 +154,7 @@
     <component id="DynamicRemoveItemRendererForArrayListData" class="org.apache.royale.html.beads.DynamicRemoveItemRendererForArrayListData"
/>
     <component id="DataItemRendererFactoryForHierarchicalData" class="org.apache.royale.html.beads.DataItemRendererFactoryForHierarchicalData"
/>
     <component id="DynamicRemoveAllItemRendererForArrayListData" class="org.apache.royale.html.beads.DynamicRemoveAllItemRendererForArrayListData"
/>
+    <component id="DynamicRemoveAllByNullItemRendererForArrayListData" class="org.apache.royale.html.beads.DynamicRemoveAllByNullItemRendererForArrayListData"
/>
     <component id="TextItemRendererFactoryForArrayData" class="org.apache.royale.html.beads.TextItemRendererFactoryForArrayData"
/>
     <component id="TextItemRendererFactoryForStringVectorData" class="org.apache.royale.html.beads.TextItemRendererFactoryForStringVectorData"
/>
 
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllByNullItemRendererForArrayListData.as
similarity index 78%
copy from frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
copy to frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllByNullItemRendererForArrayListData.as
index 5111037..8215562 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllByNullItemRendererForArrayListData.as
@@ -24,21 +24,19 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IList;
 	import org.apache.royale.core.ISelectionModel;
 	import org.apache.royale.core.IStrand;
-	import org.apache.royale.core.UIBase;
 	import org.apache.royale.events.CollectionEvent;
 	import org.apache.royale.events.Event;
 	import org.apache.royale.events.IEventDispatcher;
 
 	/**
-	 * Handles the removal of all itemRenderers once the corresponding datum has been removed
-	 * from the IDataProviderModel.
+	 * Handles the removal of all itemRenderers once data source is being set to null.
 	 *
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.9.0
 	 */
-	public class DynamicRemoveAllItemRendererForArrayListData implements IBead
+	public class DynamicRemoveAllByNullItemRendererForArrayListData implements IBead
 	{
 		/**
 		 * Constructor
@@ -48,7 +46,7 @@ package org.apache.royale.html.beads
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.0
 		 */
-		public function DynamicRemoveAllItemRendererForArrayListData()
+		public function DynamicRemoveAllByNullItemRendererForArrayListData()
 		{
 		}
 
@@ -93,33 +91,19 @@ package org.apache.royale.html.beads
 		protected function dataProviderChangeHandler(event:Event):void
 		{
 			var dp:IEventDispatcher = dataProviderModel.dataProvider as IEventDispatcher;
-			if (!dp)
-				return;
-			
-			// listen for all items being removed in the future.
-			dp.addEventListener(CollectionEvent.ALL_ITEMS_REMOVED, handleAllItemsRemoved);
-		}
 
-		/**
-		 * Handles the itemRemoved event by removing the item.
-		 *
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.9.0
-		 */
-		protected function handleAllItemsRemoved(event:CollectionEvent):void
-		{
-			if (dataProviderModel is ISelectionModel)
-			{
-				var model:ISelectionModel = dataProviderModel as ISelectionModel;
-				model.selectedIndex = -1;
-				model.selectedItem = null;
-			}
-			var parent:UIBase = itemRendererParent as UIBase;
-			itemRendererParent.removeAllItemRenderers();
+			if (!dp)
+            {
+                if (dataProviderModel is ISelectionModel)
+                {
+                    var model:ISelectionModel = dataProviderModel as ISelectionModel;
+                    model.selectedIndex = -1;
+                    model.selectedItem = null;
+                }
 
-			(_strand as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));
+                itemRendererParent.removeAllItemRenderers();
+                (_strand as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));
+            }
 		}
 
 		private var _dataProviderModel: IDataProviderModel;
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
index 5111037..558cf0a 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicRemoveAllItemRendererForArrayListData.as
@@ -24,13 +24,12 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IList;
 	import org.apache.royale.core.ISelectionModel;
 	import org.apache.royale.core.IStrand;
-	import org.apache.royale.core.UIBase;
 	import org.apache.royale.events.CollectionEvent;
 	import org.apache.royale.events.Event;
 	import org.apache.royale.events.IEventDispatcher;
 
 	/**
-	 * Handles the removal of all itemRenderers once the corresponding datum has been removed
+	 * Handles the removal of all itemRenderers once the all items has been removed
 	 * from the IDataProviderModel.
 	 *
 	 *  @langversion 3.0
@@ -116,9 +115,8 @@ package org.apache.royale.html.beads
 				model.selectedIndex = -1;
 				model.selectedItem = null;
 			}
-			var parent:UIBase = itemRendererParent as UIBase;
-			itemRendererParent.removeAllItemRenderers();
 
+			itemRendererParent.removeAllItemRenderers();
 			(_strand as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));
 		}
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@royale.apache.org" <commits@royale.apache.org>'].

Mime
View raw message