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 beads related to List item renderers
Date Fri, 22 Dec 2017 13:47:55 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 24b09c7  Add beads related to List item renderers
24b09c7 is described below

commit 24b09c787fc1da2d0a19895a2b2d4a440e26c597
Author: Piotr Zarzycki <piotrzarzycki21@gmail.com>
AuthorDate: Fri Dec 22 14:46:23 2017 +0100

    Add beads related to List item renderers
    
    - Add beads related to List item renderers: DynamicUpdateItemRendererForArrayListData
    and DynamicAddItemRendererForArrayListData
    - Fix MDL Tabs and MDLDynamicTabsExample
    - Update MDLDynamicTableExample with newly added beads
---
 .../MDLDynamicTableExample/src/MainView.mxml       |   2 +-
 .../itemRenderers/CustomTableRowItemRenderer.mxml  |   4 +-
 .../src/main/resources/mdl-styles.css              |   2 +-
 .../src/main/royale/views/InitialView.mxml         |   5 +-
 .../Basic/src/main/resources/basic-manifest.xml    |   2 +
 .../projects/Basic/src/main/royale/BasicClasses.as |   1 -
 .../beads/DataItemRendererFactoryForArrayList.as   |  11 +-
 .../DynamicAddItemRendererForArrayListData.as      | 225 +++++++++++++++++++++
 .../DynamicUpdateItemRendererForArrayListData.as   | 172 ++++++++++++++++
 .../src/main/resources/defaults.css                |   4 +-
 .../src/main/resources/mdl-manifest.xml            |   1 +
 .../src/main/royale/MDLClasses.as                  |   2 +-
 ... DynamicTabsAddItemRendererForArrayListData.as} |  69 ++-----
 ...TabsDataItemRendererFactoryForArrayListData.as} |  60 +++---
 .../org/apache/royale/mdl/beads/views/TabsView.as  |  26 ++-
 15 files changed, 477 insertions(+), 109 deletions(-)

diff --git a/examples/royale/MDLDynamicTableExample/src/MainView.mxml b/examples/royale/MDLDynamicTableExample/src/MainView.mxml
index c450cc6..d18f583 100644
--- a/examples/royale/MDLDynamicTableExample/src/MainView.mxml
+++ b/examples/royale/MDLDynamicTableExample/src/MainView.mxml
@@ -71,7 +71,7 @@ limitations under the License.
 				<mdl:TableColumn headerText="Email"/>
 			</mdl:columns>
 			<mdl:beads>
-				<js:DynamicItemsRendererFactoryForArrayListData />
+				<js:DynamicAddItemRendererForArrayListData/>
 				<js:DynamicRemoveItemRendererForArrayListData />
 				<js:DynamicRemoveAllItemRendererForArrayListData />
 				<js:DynamicRemoveAllByNullItemRendererForArrayListData />
diff --git a/examples/royale/MDLDynamicTableExample/src/itemRenderers/CustomTableRowItemRenderer.mxml
b/examples/royale/MDLDynamicTableExample/src/itemRenderers/CustomTableRowItemRenderer.mxml
index 6763508..c1dc7dc 100644
--- a/examples/royale/MDLDynamicTableExample/src/itemRenderers/CustomTableRowItemRenderer.mxml
+++ b/examples/royale/MDLDynamicTableExample/src/itemRenderers/CustomTableRowItemRenderer.mxml
@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 
 -->
-<mdl:TableRowItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
+<mdl:TableRowItemSingleSelectionMouseRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:js="library://ns.apache.org/royale/basic"
                        xmlns:mdl="library://ns.apache.org/royale/mdl"
                        xmlns="http://www.w3.org/1999/xhtml">
@@ -43,4 +43,4 @@ limitations under the License.
     <mdl:TableCell text="{userVO.lastName}"/>
     <mdl:TableCell text="{userVO.email}"/>
     
-</mdl:TableRowItemRenderer>
+</mdl:TableRowItemSingleSelectionMouseRenderer>
diff --git a/examples/royale/MDLDynamicTabsExample/src/main/resources/mdl-styles.css b/examples/royale/MDLDynamicTabsExample/src/main/resources/mdl-styles.css
index 2e0e5f3..ad4c8ff 100644
--- a/examples/royale/MDLDynamicTabsExample/src/main/resources/mdl-styles.css
+++ b/examples/royale/MDLDynamicTabsExample/src/main/resources/mdl-styles.css
@@ -27,5 +27,5 @@
 {
   IItemRenderer: ClassReference("itemRenderers.CustomTabBarPanelItemRenderer");
   IBeadModel: ClassReference("org.apache.royale.mdl.beads.models.TabArrayListModel");
-  IDataProviderItemRendererMapper: ClassReference("org.apache.royale.mdl.beads.TabsDynamicItemsRendererFactoryForArrayListData");
+  IDataProviderItemRendererMapper: ClassReference("org.apache.royale.mdl.beads.TabsDataItemRendererFactoryForArrayListData");
 }
diff --git a/examples/royale/MDLDynamicTabsExample/src/main/royale/views/InitialView.mxml
b/examples/royale/MDLDynamicTabsExample/src/main/royale/views/InitialView.mxml
index 7418cd3..3c9382c 100644
--- a/examples/royale/MDLDynamicTabsExample/src/main/royale/views/InitialView.mxml
+++ b/examples/royale/MDLDynamicTabsExample/src/main/royale/views/InitialView.mxml
@@ -43,10 +43,7 @@ limitations under the License.
 		<mdl:Tabs id="myTabs" selectedIndex="1" tabIdField="tabId" labelField="label" className="customTabs"
 				  dataProvider="{tabsModel.tabs}" width="500">
 			<mdl:beads>
-				<js:DataProviderCollectionChangeNotifier sourceID="tabsModel" propertyName="tabs"
-														 destinationPropertyName="dataProvider" changeEventName="dataProviderChanged"
 />
-				<js:DataProviderItemsChangeNotifier sourceID="tabsModel" propertyName="tabs"
-													destinationPropertyName="dataProvider" changeEventName="dataProviderChanged"
 />
+				<mdl:DynamicTabsAddItemRendererForArrayListData/>
 			</mdl:beads>
 		</mdl:Tabs>
 	</mdl:GridCell>
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index ad0ac29..0a57697 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -153,7 +153,9 @@
     <component id="DataItemRendererFactoryForArrayData" class="org.apache.royale.html.beads.DataItemRendererFactoryForArrayData"
/>
     <component id="DataItemRendererFactoryForArrayList" class="org.apache.royale.html.beads.DataItemRendererFactoryForArrayList"
/>
     <component id="DynamicItemsRendererFactoryForArrayListData" class="org.apache.royale.html.beads.DynamicItemsRendererFactoryForArrayListData"
/>
+    <component id="DynamicAddItemRendererForArrayListData" class="org.apache.royale.html.beads.DynamicAddItemRendererForArrayListData"/>
     <component id="DynamicRemoveItemRendererForArrayListData" class="org.apache.royale.html.beads.DynamicRemoveItemRendererForArrayListData"
/>
+    <component id="DynamicUpdateItemRendererForArrayListData" class="org.apache.royale.html.beads.DynamicUpdateItemRendererForArrayListData"/>
     <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"
/>
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index b4d0627..6ba89fc 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -166,7 +166,6 @@ internal class BasicClasses
     import org.apache.royale.html.beads.TextItemRendererFactoryForArrayData; TextItemRendererFactoryForArrayData;
 	import org.apache.royale.html.beads.DataItemRendererFactoryForArrayData; DataItemRendererFactoryForArrayData;
     import org.apache.royale.html.beads.DynamicItemsRendererFactoryForArrayListData; DynamicItemsRendererFactoryForArrayListData;
-    import org.apache.royale.html.beads.DynamicRemoveItemRendererForArrayListData; DynamicRemoveItemRendererForArrayListData;
 	import org.apache.royale.html.beads.DataItemRendererFactoryForArrayList; DataItemRendererFactoryForArrayList;
 	import org.apache.royale.html.beads.DataItemRendererFactoryForHierarchicalData; DataItemRendererFactoryForHierarchicalData;
 	import org.apache.royale.html.supportClasses.DataGroup; DataGroup;
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataItemRendererFactoryForArrayList.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataItemRendererFactoryForArrayList.as
index 946a4d6..3060417 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataItemRendererFactoryForArrayList.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataItemRendererFactoryForArrayList.as
@@ -27,10 +27,8 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.ISelectableItemRenderer;
 	import org.apache.royale.core.IDataProviderModel;
 	import org.apache.royale.core.IStrand;
-	import org.apache.royale.core.IUIBase;
 	import org.apache.royale.core.SimpleCSSStyles;
 	import org.apache.royale.core.UIBase;
-	import org.apache.royale.core.ValuesManager;
 	import org.apache.royale.events.Event;
 	import org.apache.royale.events.IEventDispatcher;
 	import org.apache.royale.events.EventDispatcher;
@@ -38,7 +36,6 @@ package org.apache.royale.html.beads
     import org.apache.royale.html.supportClasses.DataItemRenderer;
 	import org.apache.royale.utils.loadBeadFromValuesManager;
 
-    //import org.apache.royale.html.List;
 	import org.apache.royale.core.IList;
 	
 	[Event(name="itemRendererCreated",type="org.apache.royale.events.ItemRendererEvent")]
@@ -76,7 +73,7 @@ package org.apache.royale.html.beads
 		protected var labelField:String;
 		protected var dataField:String;
 
-		private var _strand:IStrand;
+		protected var _strand:IStrand;
 		
         /**
          *  @copy org.apache.royale.core.IBead#strand
@@ -89,10 +86,10 @@ package org.apache.royale.html.beads
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
-			IEventDispatcher(_strand).addEventListener("initComplete", finishSetup);
+			IEventDispatcher(_strand).addEventListener("initComplete", initComplete);
 		}
 		
-		private function finishSetup(event:Event):void
+		protected function initComplete(event:Event):void
 		{			
 			dataProviderModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
 			dataProviderModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
@@ -193,7 +190,7 @@ package org.apache.royale.html.beads
 				newEvent.itemRenderer = ir;
 				dispatchEvent(newEvent);
 			}
-			
+
 			IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
 		}
 	}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicAddItemRendererForArrayListData.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicAddItemRendererForArrayListData.as
new file mode 100644
index 0000000..d5a2185
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicAddItemRendererForArrayListData.as
@@ -0,0 +1,225 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.royale.html.beads
+{
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IDataProviderModel;
+    import org.apache.royale.core.IItemRendererClassFactory;
+    import org.apache.royale.core.IItemRendererParent;
+	import org.apache.royale.core.IList;
+	import org.apache.royale.core.ISelectableItemRenderer;
+	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;
+    import org.apache.royale.core.IListPresentationModel;
+    import org.apache.royale.utils.loadBeadFromValuesManager;
+    import org.apache.royale.core.SimpleCSSStyles;
+
+    /**
+	 * Handles the adding of an itemRenderer once the corresponding datum has been added
+	 * from the IDataProviderModel.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.0
+	 */
+	public class DynamicAddItemRendererForArrayListData implements IBead
+	{
+		/**
+		 * Constructor
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function DynamicAddItemRendererForArrayListData()
+		{
+		}
+
+		protected var _strand:IStrand;
+
+        protected var labelField:String;
+
+		/**
+		 * @copy org.apache.royale.core.IStrand
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			IEventDispatcher(value).addEventListener("initComplete", initComplete);
+		}
+		
+		/**
+		 *  finish setup
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.8
+		 */
+		protected function initComplete(event:Event):void
+		{
+			IEventDispatcher(_strand).removeEventListener("initComplete", initComplete);
+			
+			_dataProviderModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
+			labelField = _dataProviderModel.labelField;
+
+			dataProviderModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);

+
+			// invoke now in case "dataProviderChanged" has already been dispatched.
+			dataProviderChangeHandler(null);
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function dataProviderChangeHandler(event:Event):void
+		{
+			var dp:IEventDispatcher = dataProviderModel.dataProvider as IEventDispatcher;
+			if (!dp)
+				return;
+			
+			// listen for individual items being added in the future.
+			dp.addEventListener(CollectionEvent.ITEM_ADDED, handleItemAdded);
+		}
+
+		/**
+		 * 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 handleItemAdded(event:CollectionEvent):void
+		{
+			if (dataProviderModel is ISelectionModel) {
+				var model:ISelectionModel = dataProviderModel as ISelectionModel;
+				model.selectedIndex = -1;
+			}
+
+            var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel)
as IListPresentationModel;
+            var ir:ISelectableItemRenderer = itemRendererFactory.createItemRenderer(itemRendererParent)
as ISelectableItemRenderer;
+
+            fillRenderer(event.index, event.item, ir, presentationModel);
+
+			(_strand as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));
+		}
+
+		private var _dataProviderModel: IDataProviderModel;
+
+		/**
+		 *  The org.apache.royale.core.IDataProviderModel that contains the
+		 *  data source.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function get dataProviderModel(): IDataProviderModel
+		{
+			if (_dataProviderModel == null) {
+				_dataProviderModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
+			}
+			return _dataProviderModel;
+		}
+
+		private var _itemRendererParent: IItemRendererParent;
+
+		/**
+		 *  The org.apache.royale.core.IItemRendererParent used
+		 *  to generate instances of item renderers.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function get itemRendererParent():IItemRendererParent
+		{
+			if (_itemRendererParent == null) {
+				var list:IList = _strand as IList;
+				_itemRendererParent = list.dataGroup;
+			}
+			return _itemRendererParent;
+		}
+
+        private var _itemRendererFactory:IItemRendererClassFactory;
+
+        /**
+         *  The org.apache.royale.core.IItemRendererClassFactory used
+         *  to generate instances of item renderers.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.8
+         */
+        public function get itemRendererFactory():IItemRendererClassFactory
+        {
+            if(!_itemRendererFactory)
+                _itemRendererFactory = loadBeadFromValuesManager(IItemRendererClassFactory,
"iItemRendererClassFactory", _strand) as IItemRendererClassFactory;
+
+            return _itemRendererFactory;
+        }
+
+        /**
+         * @private
+         */
+        protected function fillRenderer(index:int,
+                                        item:Object,
+                                        itemRenderer:ISelectableItemRenderer,
+                                        presentationModel:IListPresentationModel):void
+        {
+            itemRendererParent.addItemRendererAt(itemRenderer, index);
+
+            itemRenderer.labelField = labelField;
+
+            if (presentationModel) {
+                var style:SimpleCSSStyles = new SimpleCSSStyles();
+                style.marginBottom = presentationModel.separatorThickness;
+                UIBase(itemRenderer).style = style;
+                UIBase(itemRenderer).height = presentationModel.rowHeight;
+                UIBase(itemRenderer).percentWidth = 100;
+            }
+
+            setData(itemRenderer, item, index);
+        }
+
+        /**
+         * @private
+         */
+        protected function setData(itemRenderer:ISelectableItemRenderer, data:Object, index:int):void
+        {
+            itemRenderer.index = index;
+            itemRenderer.data = data;
+        }
+	}
+}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicUpdateItemRendererForArrayListData.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicUpdateItemRendererForArrayListData.as
new file mode 100644
index 0000000..d939f9f
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DynamicUpdateItemRendererForArrayListData.as
@@ -0,0 +1,172 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.royale.html.beads
+{
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IDataProviderModel;
+    import org.apache.royale.core.IItemRendererParent;
+	import org.apache.royale.core.IList;
+	import org.apache.royale.core.ISelectableItemRenderer;
+	import org.apache.royale.core.ISelectionModel;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.events.CollectionEvent;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.events.IEventDispatcher;
+
+    /**
+	 * Handles the update of an itemRenderer once the corresponding datum has been updated
+	 * from the IDataProviderModel.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.0
+	 */
+	public class DynamicUpdateItemRendererForArrayListData implements IBead
+	{
+		/**
+		 * Constructor
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function DynamicUpdateItemRendererForArrayListData()
+		{
+		}
+
+		protected var _strand:IStrand;
+
+        protected var labelField:String;
+
+		/**
+		 * @copy org.apache.royale.core.IStrand
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			IEventDispatcher(value).addEventListener("initComplete", initComplete);
+		}
+		
+		/**
+		 *  finish setup
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.8
+		 */
+		protected function initComplete(event:Event):void
+		{
+			IEventDispatcher(_strand).removeEventListener("initComplete", initComplete);
+			
+			_dataProviderModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
+			labelField = _dataProviderModel.labelField;
+
+			dataProviderModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);

+
+			// invoke now in case "dataProviderChanged" has already been dispatched.
+			dataProviderChangeHandler(null);
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function dataProviderChangeHandler(event:Event):void
+		{
+			var dp:IEventDispatcher = dataProviderModel.dataProvider as IEventDispatcher;
+			if (!dp)
+				return;
+			
+			// listen for individual items being added in the future.
+			dp.addEventListener(CollectionEvent.ITEM_UPDATED, handleItemAdded);
+		}
+
+		/**
+		 * 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 handleItemAdded(event:CollectionEvent):void
+		{
+            var ir:ISelectableItemRenderer = itemRendererParent.getItemRendererForIndex(event.index)
as ISelectableItemRenderer;
+
+            setData(ir, event.item, event.index);
+
+			(_strand as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));
+		}
+
+		private var _dataProviderModel: IDataProviderModel;
+
+		/**
+		 *  The org.apache.royale.core.IDataProviderModel that contains the
+		 *  data source.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function get dataProviderModel(): IDataProviderModel
+		{
+			if (_dataProviderModel == null) {
+				_dataProviderModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
+			}
+			return _dataProviderModel;
+		}
+
+		private var _itemRendererParent: IItemRendererParent;
+
+		/**
+		 *  The org.apache.royale.core.IItemRendererParent used
+		 *  to generate instances of item renderers.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.0
+		 */
+		public function get itemRendererParent():IItemRendererParent
+		{
+			if (_itemRendererParent == null) {
+				var list:IList = _strand as IList;
+				_itemRendererParent = list.dataGroup;
+			}
+			return _itemRendererParent;
+		}
+
+        /**
+         * @private
+         */
+        protected function setData(itemRenderer:ISelectableItemRenderer, data:Object, index:int):void
+        {
+            itemRenderer.index = index;
+            itemRenderer.data = data;
+        }
+	}
+}
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
index 399d44c..1c64ef6 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
@@ -122,7 +122,7 @@ Tabs
     IBeadView: ClassReference("org.apache.royale.mdl.beads.views.TabsView");
     IBeadModel: ClassReference("org.apache.royale.mdl.beads.models.TabArrayModel");
     IBeadLayout: ClassReference(null);
-    IDataProviderItemRendererMapper: ClassReference("org.apache.royale.mdl.beads.TabsDynamicItemsRendererFactoryForArrayListData");
+    IDataProviderItemRendererMapper: ClassReference("org.apache.royale.mdl.beads.TabsDataItemRendererFactoryForArrayListData");
     IItemRendererClassFactory: ClassReference("org.apache.royale.core.ItemRendererClassFactory");
     IItemRenderer: ClassReference("org.apache.royale.mdl.itemRenderers.TabBarPanelItemRenderer");
 }
@@ -132,7 +132,7 @@ TabBar
     IBeadView: ClassReference("org.apache.royale.mdl.beads.views.TabBarView");
     IBeadModel: ClassReference("org.apache.royale.mdl.beads.models.TabArrayModel");
     IBeadLayout: ClassReference(null);
-    IDataProviderItemRendererMapper: ClassReference("org.apache.royale.mdl.beads.TabsDynamicItemsRendererFactoryForArrayListData");
+    IDataProviderItemRendererMapper: ClassReference("org.apache.royale.mdl.beads.TabsDataItemRendererFactoryForArrayListData");
     IItemRendererClassFactory: ClassReference("org.apache.royale.core.ItemRendererClassFactory");
     IItemRenderer: ClassReference("org.apache.royale.mdl.itemRenderers.TabBarButtonTabsItemRenderer");
 }
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
index a0a6136..afbf8f9 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
@@ -106,6 +106,7 @@
     <component id="TabBarPanel" class="org.apache.royale.mdl.TabBarPanel"/>
     <component id="TabsView" class="org.apache.royale.mdl.beads.views.TabsView"/>
     <component id="Tabs" class="org.apache.royale.mdl.Tabs"/>
+    <component id="DynamicTabsAddItemRendererForArrayListData" class="org.apache.royale.mdl.beads.DynamicTabsAddItemRendererForArrayListData"/>
     <component id="MaterialIcon" class="org.apache.royale.mdl.materialIcons.MaterialIcon"/>
     <component id="Footer" class="org.apache.royale.mdl.Footer"/>
     <component id="FooterMiddleSection" class="org.apache.royale.mdl.FooterMiddleSection"/>
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as b/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as
index 0827a68..e98aa02 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/MDLClasses.as
@@ -28,7 +28,7 @@ package
 	internal class MDLClasses
 	{
 		import org.apache.royale.mdl.beads.TabsItemRendererFactoryForArrayData; TabsItemRendererFactoryForArrayData;
-		import org.apache.royale.mdl.beads.TabsDynamicItemsRendererFactoryForArrayListData; TabsDynamicItemsRendererFactoryForArrayListData;
+        import org.apache.royale.mdl.beads.TabsDataItemRendererFactoryForArrayListData; TabsDataItemRendererFactoryForArrayListData;
 		import org.apache.royale.mdl.beads.models.TabArrayModel; TabArrayModel;
 		import org.apache.royale.mdl.beads.models.TabArrayListModel; TabArrayListModel;
 		import org.apache.royale.mdl.beads.models.ToastModel; ToastModel;
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDynamicItemsRendererFactoryForArrayListData.as
b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/DynamicTabsAddItemRendererForArrayListData.as
similarity index 51%
copy from frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDynamicItemsRendererFactoryForArrayListData.as
copy to frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/DynamicTabsAddItemRendererForArrayListData.as
index 2225687..70341e9 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDynamicItemsRendererFactoryForArrayListData.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/DynamicTabsAddItemRendererForArrayListData.as
@@ -18,36 +18,27 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.mdl.beads
 {
-    import org.apache.royale.collections.IArrayList;
-    import org.apache.royale.core.IListPresentationModel;
+	import org.apache.royale.collections.IArrayList;
+	import org.apache.royale.core.IListPresentationModel;
+    import org.apache.royale.core.ISelectionModel;
     import org.apache.royale.events.CollectionEvent;
-
-    import org.apache.royale.events.IEventDispatcher;
-    import org.apache.royale.html.beads.DynamicItemsRendererFactoryForArrayListData;
+    import org.apache.royale.events.Event;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.html.beads.DynamicAddItemRendererForArrayListData;
     import org.apache.royale.mdl.beads.models.ITabModel;
     import org.apache.royale.mdl.supportClasses.ITabItemRenderer;
-    import org.apache.royale.events.Event;
-
-    [Event(name="itemRendererCreated",type="org.apache.royale.events.ItemRendererEvent")]
 
     /**
-     *  The TabsDynamicItemsRendererFactoryForArrayListData class reads an
-     *  array of data and creates an item renderer for every
-     *  ITabItemRenderer in the array.
-     *
+     *  @copy org.apache.royale.html.beads.DynamicAddItemRendererForArrayListData
+     *  
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
-     *  @productversion Royale 0.8
+     *  @productversion Royale 0.0
      */
-    public class TabsDynamicItemsRendererFactoryForArrayListData extends DynamicItemsRendererFactoryForArrayListData
-    {
-        public function TabsDynamicItemsRendererFactoryForArrayListData(target:Object = null)
-        {
-            super(target);
-        }
-
-        protected var tabsIdField:String;
+	public class DynamicTabsAddItemRendererForArrayListData extends DynamicAddItemRendererForArrayListData
+	{
+		protected var tabsIdField:String;
 
         /**
          *  finish setup
@@ -65,44 +56,24 @@ package org.apache.royale.mdl.beads
             super.initComplete(event);
         }
 
-        override protected function dataProviderChangeHandler(event:Event):void
+        override protected function handleItemAdded(event:CollectionEvent):void
         {
             var dp:IArrayList = dataProviderModel.dataProvider as IArrayList;
             if (!dp)
                 return;
 
-            dataGroup.removeAllItemRenderers();
-
-            var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel)
as IListPresentationModel;
-
-            var n:int = dp.length;
-            for (var i:int = 0; i < n; i++)
-            {
-                var ir:ITabItemRenderer = itemRendererFactory.createItemRenderer(dataGroup)
as ITabItemRenderer;
-                ir.tabIdField = tabsIdField;
-
-                var item:Object = dp.getItemAt(i);
-                fillRenderer(i, item, ir, presentationModel);
+            if (dataProviderModel is ISelectionModel) {
+                var model:ISelectionModel = dataProviderModel as ISelectionModel;
+                model.selectedIndex = -1;
             }
 
-            IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
-        }
-
-        override protected function itemAddedHandler(event:CollectionEvent):void
-        {
-            var dp:IArrayList = dataProviderModel.dataProvider as IArrayList;
-            if (!dp)
-                return;
-
             var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel)
as IListPresentationModel;
-
-            var ir:ITabItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as
ITabItemRenderer;
+            var ir:ITabItemRenderer = itemRendererFactory.createItemRenderer(itemRendererParent)
as ITabItemRenderer;
             ir.tabIdField = tabsIdField;
 
-            var index:int = dp.length - 1;
-            fillRenderer(index, event.item, ir, presentationModel);
+            fillRenderer(event.index, event.item, ir, presentationModel);
 
-            IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
+            (_strand as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));
         }
-    }
+	}
 }
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDynamicItemsRendererFactoryForArrayListData.as
b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDataItemRendererFactoryForArrayListData.as
similarity index 65%
rename from frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDynamicItemsRendererFactoryForArrayListData.as
rename to frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDataItemRendererFactoryForArrayListData.as
index 2225687..4c9a3ad 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDynamicItemsRendererFactoryForArrayListData.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsDataItemRendererFactoryForArrayListData.as
@@ -19,19 +19,21 @@
 package org.apache.royale.mdl.beads
 {
     import org.apache.royale.collections.IArrayList;
+    import org.apache.royale.core.IItemRendererParent;
+    import org.apache.royale.core.IList;
     import org.apache.royale.core.IListPresentationModel;
-    import org.apache.royale.events.CollectionEvent;
+    import org.apache.royale.core.SimpleCSSStyles;
+    import org.apache.royale.core.UIBase;
 
     import org.apache.royale.events.IEventDispatcher;
-    import org.apache.royale.html.beads.DynamicItemsRendererFactoryForArrayListData;
+    import org.apache.royale.html.beads.DataItemRendererFactoryForArrayList;
+    import org.apache.royale.html.supportClasses.DataItemRenderer;
     import org.apache.royale.mdl.beads.models.ITabModel;
     import org.apache.royale.mdl.supportClasses.ITabItemRenderer;
     import org.apache.royale.events.Event;
 
-    [Event(name="itemRendererCreated",type="org.apache.royale.events.ItemRendererEvent")]
-
     /**
-     *  The TabsDynamicItemsRendererFactoryForArrayListData class reads an
+     *  The TabsDataItemRendererFactoryForArrayListData class reads an
      *  array of data and creates an item renderer for every
      *  ITabItemRenderer in the array.
      *
@@ -40,9 +42,9 @@ package org.apache.royale.mdl.beads
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.8
      */
-    public class TabsDynamicItemsRendererFactoryForArrayListData extends DynamicItemsRendererFactoryForArrayListData
+    public class TabsDataItemRendererFactoryForArrayListData extends DataItemRendererFactoryForArrayList
     {
-        public function TabsDynamicItemsRendererFactoryForArrayListData(target:Object = null)
+        public function TabsDataItemRendererFactoryForArrayListData(target:Object = null)
         {
             super(target);
         }
@@ -71,6 +73,9 @@ package org.apache.royale.mdl.beads
             if (!dp)
                 return;
 
+            var list:IList = _strand as IList;
+            var dataGroup:IItemRendererParent = list.dataGroup;
+
             dataGroup.removeAllItemRenderers();
 
             var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel)
as IListPresentationModel;
@@ -80,29 +85,30 @@ package org.apache.royale.mdl.beads
             {
                 var ir:ITabItemRenderer = itemRendererFactory.createItemRenderer(dataGroup)
as ITabItemRenderer;
                 ir.tabIdField = tabsIdField;
-
-                var item:Object = dp.getItemAt(i);
-                fillRenderer(i, item, ir, presentationModel);
+                var dataItemRenderer:DataItemRenderer = ir as DataItemRenderer;
+
+                dataGroup.addItemRenderer(ir);
+
+                if (presentationModel) {
+                    var style:SimpleCSSStyles = new SimpleCSSStyles();
+                    style.marginBottom = presentationModel.separatorThickness;
+                    UIBase(ir).style = style;
+                    UIBase(ir).height = presentationModel.rowHeight;
+                    UIBase(ir).percentWidth = 100;
+                }
+
+                var data:Object = dp.getItemAt(i);
+                ir.index = i;
+                ir.labelField = labelField;
+                if (dataItemRenderer)
+                {
+                    dataItemRenderer.dataField = dataField;
+                }
+
+                setData(ir, data, i);
             }
 
             IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
         }
-
-        override protected function itemAddedHandler(event:CollectionEvent):void
-        {
-            var dp:IArrayList = dataProviderModel.dataProvider as IArrayList;
-            if (!dp)
-                return;
-
-            var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel)
as IListPresentationModel;
-
-            var ir:ITabItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as
ITabItemRenderer;
-            ir.tabIdField = tabsIdField;
-
-            var index:int = dp.length - 1;
-            fillRenderer(index, event.item, ir, presentationModel);
-
-            IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
-        }
     }
 }
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TabsView.as
b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TabsView.as
index 82a7cf3..446f14b 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TabsView.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TabsView.as
@@ -18,15 +18,16 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.mdl.beads.views
 {
+    import org.apache.royale.core.IBead;
     import org.apache.royale.core.IContentViewHost;
-    import org.apache.royale.core.IDataProviderItemRendererMapper;
     import org.apache.royale.core.IParent;
     import org.apache.royale.core.IStrandWithModel;
     import org.apache.royale.events.Event;
     import org.apache.royale.core.IStrand;
     import org.apache.royale.mdl.TabBar;
     import org.apache.royale.mdl.TabBarPanel;
-    import org.apache.royale.mdl.beads.TabsDynamicItemsRendererFactoryForArrayListData;
+    import org.apache.royale.mdl.beads.DynamicTabsAddItemRendererForArrayListData;
+    import org.apache.royale.mdl.beads.DynamicTabsAddItemRendererForArrayListData;
     import org.apache.royale.mdl.supportClasses.ITabItemRenderer;
 
     /**
@@ -94,10 +95,13 @@ package org.apache.royale.mdl.beads.views
             }
 
             _tabBar.model = (value as IStrandWithModel).model;
-            
-            if (!isTabsDynamic())
+
+            var dynamicTabsAddBead:DynamicTabsAddItemRendererForArrayListData = _strand.getBeadByType(DynamicTabsAddItemRendererForArrayListData)
as DynamicTabsAddItemRendererForArrayListData;
+            if (dynamicTabsAddBead)
             {
-                _tabBar.addEventListener("itemsCreated", tabBarItemsCreatedHandler);
+                
+                _tabBar.addBead(new DynamicTabsAddItemRendererForArrayListData() as IBead);
+                _tabBar.addEventListener("layoutNeeded", tabBarLayoutNeededHandler);
             }
         }
 
@@ -108,7 +112,7 @@ package org.apache.royale.mdl.beads.views
             completeTabBarSetup();
         }
 
-        private function tabBarItemsCreatedHandler(event:Event):void
+        private function tabBarLayoutNeededHandler(event:Event):void
         {
             forceUpgradeTabs();
         }
@@ -149,7 +153,8 @@ package org.apache.royale.mdl.beads.views
 
         private function forceUpgradeTabs():void
         {
-            if (!isTabsDynamic()) return;
+            var dynamicTabsAddBead:DynamicTabsAddItemRendererForArrayListData = _strand.getBeadByType(DynamicTabsAddItemRendererForArrayListData)
as DynamicTabsAddItemRendererForArrayListData;
+            if (!dynamicTabsAddBead) return;
             
             COMPILE::JS
             {
@@ -163,12 +168,5 @@ package org.apache.royale.mdl.beads.views
                 }
             }
         }
-
-        public function isTabsDynamic():Boolean
-        {
-            var arrayListMapper:TabsDynamicItemsRendererFactoryForArrayListData =
-                    _strand.getBeadByType(IDataProviderItemRendererMapper) as TabsDynamicItemsRendererFactoryForArrayListData;
-            return arrayListMapper != null;
-        }
     }
 }

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

Mime
View raw message