royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [royale-asjs] 01/02: Cleaned up adding beads in MDL
Date Sat, 28 Oct 2017 23:43:33 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 24f1f443263db23df9b1ebd076806933b7ab1ff8
Author: Harbs <harbs@in-tools.com>
AuthorDate: Sun Oct 29 01:13:10 2017 +0200

    Cleaned up adding beads in MDL
---
 .../beads/TabsItemRendererFactoryForArrayData.as   | 12 +++-----
 .../org/apache/royale/mdl/beads/views/TableView.as | 33 +++++++++-------------
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsItemRendererFactoryForArrayData.as
b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsItemRendererFactoryForArrayData.as
index 84e68db..c1cee24 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsItemRendererFactoryForArrayData.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsItemRendererFactoryForArrayData.as
@@ -34,6 +34,7 @@ package org.apache.royale.mdl.beads
     import org.apache.royale.mdl.beads.models.ITabModel;
     import org.apache.royale.events.Event;
     import org.apache.royale.mdl.supportClasses.ITabItemRenderer;
+	import org.apache.royale.utils.loadBeadFromValuesManager;
 
     [Event(name="itemRendererCreated",type="org.apache.royale.events.ItemRendererEvent")]
 
@@ -111,14 +112,9 @@ package org.apache.royale.mdl.beads
          */
         public function get itemRendererFactory():IItemRendererClassFactory
         {
-			if (_itemRendererFactory == null) {
-				var factory:IItemRendererClassFactory = _strand.getBeadByType(IItemRendererClassFactory)
as IItemRendererClassFactory;
-				if (factory == null) {
-					factory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory"))
as IItemRendererClassFactory;
-					_strand.addBead(factory);
-				}
-				_itemRendererFactory = factory;
-			}
+			if(!_itemRendererFactory)
+    			_itemRendererFactory = loadBeadFromValuesManager(IItemRendererClassFactory, "iItemRendererClassFactory",
_strand) as IItemRendererClassFactory;
+            
             return _itemRendererFactory;
         }
 
diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TableView.as
b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TableView.as
index 0d8a5d6..b047086 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TableView.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/views/TableView.as
@@ -25,9 +25,9 @@ package org.apache.royale.mdl.beads.views
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.ISelectionModel;
 	import org.apache.royale.core.ValuesManager;
-	import org.apache.royale.html.beads.IListView;
-
 	import org.apache.royale.events.Event;
+	import org.apache.royale.html.beads.IListView;
+	import org.apache.royale.utils.loadBeadFromValuesManager;
 
 	/**
 	 *  TableView makes sure the itemRendererFactory and the layout beads are installed.
@@ -88,15 +88,8 @@ package org.apache.royale.mdl.beads.views
 		override public function set strand(value:IStrand):void
 		{
 			super.strand = value;
-
-			var mapper:IDataProviderItemRendererMapper = _strand.getBeadByType(IDataProviderItemRendererMapper)
as IDataProviderItemRendererMapper;
-			if (mapper == null) {
-				var c:Class = ValuesManager.valuesImpl.getValue(host, "iDataProviderItemRendererMapper");
-				if (c) {
-					mapper = new c() as IDataProviderItemRendererMapper;
-					_strand.addBead(mapper);
-				}
-			}
+    		
+			loadBeadFromValuesManager(IDataProviderItemRendererMapper, "iDataProviderItemRendererMapper",
_strand);
 
 			host.addEventListener("itemsCreated", itemsCreatedHandler);
 
@@ -132,6 +125,15 @@ package org.apache.royale.mdl.beads.views
 			performLayout(event);
 		}
 
+		private var _layout:IBeadLayout;
+		private function get layout():IBeadLayout
+		{
+			if(!_layout)
+				_layout = loadBeadFromValuesManager(IBeadLayout, "iBeadLayout", _strand) as IBeadLayout;
+			
+			return _layout;
+		}
+
 		/**
 		 *  @private
 		 *
@@ -142,15 +144,6 @@ package org.apache.royale.mdl.beads.views
 		 */
 		protected function performLayout(event:Event):void
 		{
-			var layout:IBeadLayout = _strand.getBeadByType(IBeadLayout) as IBeadLayout;
-			if (layout == null) {
-				var c:Class = ValuesManager.valuesImpl.getValue(host, "iBeadLayout");
-				if (c) {
-					layout = new c() as IBeadLayout;
-					_strand.addBead(layout);
-				}
-			}
-
 			if (layout) {
 				layout.layout();
 			}

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

Mime
View raw message