flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject [16/23] git commit: [flex-asjs] [refs/heads/develop] - FLEX-35328 - Introduce IDataFieldProviderModel - bead which provides to control with item renderers "dataField" for usage by these item renderers. You can find example of usage in MDL DropDownList wh
Date Thu, 29 Jun 2017 19:22:52 GMT
FLEX-35328 - Introduce IDataFieldProviderModel - bead which provides to control with item renderers
"dataField" for usage by these item renderers. You can find example of usage in MDL DropDownList
where provided dataField is used by "value" property in HTML tag option


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

Branch: refs/heads/develop
Commit: 5eb141ecca627d806db661fca0d5629c804ef17c
Parents: e86286f
Author: piotrz <piotrz@apache.org>
Authored: Sun Jun 25 18:10:01 2017 +0200
Committer: piotrz <piotrz@apache.org>
Committed: Sun Jun 25 18:10:01 2017 +0200

----------------------------------------------------------------------
 .../Basic/src/main/flex/BasicClasses.as         |  3 +-
 .../DataItemRendererFactoryForArrayData.as      | 25 +++++-
 .../DataItemRendererFactoryForArrayList.as      | 38 ++++++--
 .../html/beads/models/DataFieldProviderModel.as | 91 ++++++++++++++++++++
 .../projects/Core/src/main/flex/CoreClasses.as  |  1 +
 .../apache/flex/core/IDataFieldProviderModel.as | 47 ++++++++++
 .../org/apache/flex/core/IDataProviderModel.as  |  9 +-
 7 files changed, 195 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Basic/src/main/flex/BasicClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/BasicClasses.as b/frameworks/projects/Basic/src/main/flex/BasicClasses.as
index fbf9a67..7203474 100644
--- a/frameworks/projects/Basic/src/main/flex/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/flex/BasicClasses.as
@@ -213,7 +213,8 @@ internal class BasicClasses
 	import org.apache.flex.svg.CompoundGraphic; CompoundGraphic;
 
     import org.apache.flex.html.beads.models.DataProviderModel; DataProviderModel;
-    import org.apache.flex.html.beads.DataContainerView; DataContainerView;
+    import org.apache.flex.html.beads.models.DataFieldProviderModel; DataFieldProviderModel;
+	import org.apache.flex.html.beads.DataContainerView; DataContainerView;
 
 	COMPILE::SWF
 	{

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as
index bcd837b..36754da 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayData.as
@@ -25,6 +25,7 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IListPresentationModel;
 	import org.apache.flex.core.ISelectableItemRenderer;
 	import org.apache.flex.core.IDataProviderModel;
+    import org.apache.flex.core.IDataFieldProviderModel;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.IUIBase;
 	import org.apache.flex.core.SimpleCSSStyles;
@@ -40,8 +41,9 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IChild;
 	import org.apache.flex.core.ILayoutHost;
 	import org.apache.flex.core.IParentIUIBase;
-	
-	[Event(name="itemRendererCreated",type="org.apache.flex.events.ItemRendererEvent")]
+    import org.apache.flex.html.supportClasses.DataItemRenderer;
+
+    [Event(name="itemRendererCreated",type="org.apache.flex.events.ItemRendererEvent")]
 	
     /**
      *  The DataItemRendererFactoryForArrayData class reads an
@@ -71,8 +73,10 @@ package org.apache.flex.html.beads
 		}
 
 		protected var dataProviderModel:IDataProviderModel;
-
+		protected var dataFieldProviderModel:IDataFieldProviderModel;
+		
 		protected var labelField:String;
+        protected var dataField:String;
 
 		private var _strand:IStrand;
 		
@@ -98,7 +102,13 @@ package org.apache.flex.html.beads
 			dataProviderModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
 			dataProviderModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
 			labelField = dataProviderModel.labelField;
-			
+
+            dataFieldProviderModel = _strand.getBeadByType(IDataFieldProviderModel) as IDataFieldProviderModel;
+			if (dataFieldProviderModel)
+            {
+                dataField = dataFieldProviderModel.dataField;
+            }
+
 			// if the host component inherits from DataContainerBase, the itemRendererClassFactory
will 
 			// already have been loaded by DataContainerBase.addedToParent function.
 			_itemRendererFactory = _strand.getBeadByType(IItemRendererClassFactory) as IItemRendererClassFactory;
@@ -160,9 +170,16 @@ package org.apache.flex.html.beads
 			for (var i:int = 0; i < n; i++)
 			{				
 				var ir:ISelectableItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as
ISelectableItemRenderer;
+                var dataItemRenderer:DataItemRenderer = ir as DataItemRenderer;
+
 				dataGroup.addItemRenderer(ir);
 				ir.index = i;
 				ir.labelField = labelField;
+                if (dataItemRenderer)
+                {
+                    dataItemRenderer.dataField = dataField;
+                }
+
 				if (presentationModel) {
 					var style:SimpleCSSStyles = new SimpleCSSStyles();
 					style.marginBottom = presentationModel.separatorThickness;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
index c35f07f..b55571b 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
@@ -25,6 +25,7 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IItemRendererParent;
 	import org.apache.flex.core.IListPresentationModel;
 	import org.apache.flex.core.ISelectableItemRenderer;
+    import org.apache.flex.core.IDataFieldProviderModel;
 	import org.apache.flex.core.IDataProviderModel;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.core.IUIBase;
@@ -35,7 +36,9 @@ package org.apache.flex.html.beads
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.events.EventDispatcher;
 	import org.apache.flex.events.ItemRendererEvent;
-	//import org.apache.flex.html.List;
+    import org.apache.flex.html.supportClasses.DataItemRenderer;
+
+    //import org.apache.flex.html.List;
 	import org.apache.flex.core.IList;
 	
 	[Event(name="itemRendererCreated",type="org.apache.flex.events.ItemRendererEvent")]
@@ -68,9 +71,11 @@ package org.apache.flex.html.beads
 		}
 		
 		protected var dataProviderModel:IDataProviderModel;
-		
+        protected var dataFieldProviderModel:IDataFieldProviderModel;
+
 		protected var labelField:String;
-		
+		protected var dataField:String;
+
 		private var _strand:IStrand;
 		
         /**
@@ -92,7 +97,13 @@ package org.apache.flex.html.beads
 			dataProviderModel = _strand.getBeadByType(IDataProviderModel) as IDataProviderModel;
 			dataProviderModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
 			labelField = dataProviderModel.labelField;
-			
+
+            dataFieldProviderModel = _strand.getBeadByType(IDataFieldProviderModel) as IDataFieldProviderModel;
+            if (dataFieldProviderModel)
+            {
+                dataField = dataFieldProviderModel.dataField;
+            }
+
 			// if the host component inherits from DataContainerBase, the itemRendererClassFactory
will 
 			// already have been loaded by DataContainerBase.addedToParent function.
 			_itemRendererFactory = _strand.getBeadByType(IItemRendererClassFactory) as IItemRendererClassFactory;
@@ -133,9 +144,7 @@ package org.apache.flex.html.beads
 		 */
 		protected function setData(ir:ISelectableItemRenderer, data:Object, index:int):void
 		{
-			ir.index = index;
-			ir.labelField = labelField;
-			ir.data = data;
+
 		}
 		
 		/**
@@ -158,6 +167,8 @@ package org.apache.flex.html.beads
 			for (var i:int = 0; i < n; i++)
 			{				
 				var ir:ISelectableItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as
ISelectableItemRenderer;
+				var dataItemRenderer:DataItemRenderer = ir as DataItemRenderer;
+
 				dataGroup.addItemRenderer(ir);
 				if (presentationModel) {
 					var style:SimpleCSSStyles = new SimpleCSSStyles();
@@ -166,8 +177,17 @@ package org.apache.flex.html.beads
 					UIBase(ir).height = presentationModel.rowHeight;
 					UIBase(ir).percentWidth = 100;
 				}
-				setData(ir, dp.getItemAt(i), i);
-				
+
+				var data:Object = dp.getItemAt(i);
+                ir.index = i;
+                ir.labelField = labelField;
+				if (dataItemRenderer)
+				{
+					dataItemRenderer.dataField = dataField;
+				}
+
+                ir.data = data;
+
 				var newEvent:ItemRendererEvent = new ItemRendererEvent(ItemRendererEvent.CREATED);
 				newEvent.itemRenderer = ir;
 				dispatchEvent(newEvent);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/DataFieldProviderModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/DataFieldProviderModel.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/DataFieldProviderModel.as
new file mode 100644
index 0000000..8a33273
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/DataFieldProviderModel.as
@@ -0,0 +1,91 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.models
+{
+	import org.apache.flex.core.IDataFieldProviderModel;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.EventDispatcher;
+			
+    /**
+     *  The DataFieldProviderModel class is a model that holds dataField used mostly
+	 *  in item renderers for retrieve some value from dataProvider items.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.9
+     */
+	public class DataFieldProviderModel extends EventDispatcher implements IDataFieldProviderModel
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.9
+         */
+		public function DataFieldProviderModel()
+		{
+		}
+
+		private var _strand:IStrand;
+		
+        /**
+         *  @copy org.apache.flex.core.IBead#strand
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.9
+         */
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+		}
+
+		private var _dataField:String = null;
+		
+        /**
+         *  @copy org.apache.flex.core.IDataFieldProviderModel#dataField
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.9
+         */
+		public function get dataField():String
+		{
+			return _dataField;
+		}
+
+        /**
+         *  @private
+         */
+		public function set dataField(value:String):void
+		{
+			if (value != _dataField)
+			{
+                _dataField = value;
+				dispatchEvent(new Event("labelFieldChanged"));
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Core/src/main/flex/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as
index 11b8b8b..2ac3b49 100644
--- a/frameworks/projects/Core/src/main/flex/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as
@@ -96,6 +96,7 @@ internal class CoreClasses
 	}
     import org.apache.flex.core.ISelectableItemRenderer; ISelectableItemRenderer;
     import org.apache.flex.core.ISelectionModel; ISelectionModel;
+	import org.apache.flex.core.IDataFieldProviderModel; IDataFieldProviderModel;
     import org.apache.flex.core.IStrand; IStrand;
 	import org.apache.flex.core.IStrandPrivate; IStrandPrivate;
     import org.apache.flex.core.IStrandWithModel; IStrandWithModel;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataFieldProviderModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataFieldProviderModel.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataFieldProviderModel.as
new file mode 100644
index 0000000..deed144
--- /dev/null
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataFieldProviderModel.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.core
+{
+	import org.apache.flex.events.IEventDispatcher;
+
+    /**
+     *  The IDataFieldProviderModel interface describes the minimum set of properties
+     *  available to control that let the user choose "dataField" from within a
+     *  set of items in a dataProvider.
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.9
+     */
+	public interface IDataFieldProviderModel extends IEventDispatcher, IBeadModel
+	{
+        /**
+         *  The property on the data item that the item renderer
+         *  should renderer.
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.9
+         */
+		function get dataField():String;
+		function set dataField(value:String):void;
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5eb141ec/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataProviderModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataProviderModel.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataProviderModel.as
index 8e154f9..3e5df9d 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataProviderModel.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IDataProviderModel.as
@@ -21,11 +21,10 @@ package org.apache.flex.core
 	import org.apache.flex.events.IEventDispatcher;
 
     /**
-     *  The ISelectionModel interface describes the minimum set of properties
-     *  available to control that let the user select from within a
-     *  set of items in a dataProvider.  A more sophisticated model would
-     *  support multiple selection.
-     * 
+     *  The IDataProviderModel interface describes the minimum set of properties
+     *  available to control that let the user choose within a
+     *  set of items in a dataProvider.
+	 *
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6


Mime
View raw message