flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - List extends SimpleList
Date Tue, 22 Nov 2016 18:34:59 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop b8046c55b -> b43f82b35


List extends SimpleList


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

Branch: refs/heads/develop
Commit: b43f82b35d04429092b00f1c7ff4addc1c3adad6
Parents: b8046c5
Author: Carlos Rovira <carlosrovira@apache.org>
Authored: Tue Nov 22 19:34:53 2016 +0100
Committer: Carlos Rovira <carlosrovira@apache.org>
Committed: Tue Nov 22 19:34:53 2016 +0100

----------------------------------------------------------------------
 .../src/main/flex/org/apache/flex/mdl/List.as   |  78 ++-----
 .../flex/org/apache/flex/mdl/beads/ListView.as  | 213 +++++++++++++++++++
 .../src/main/resources/defaults.css             |   4 +-
 .../src/main/resources/mdl-manifest.xml         |   1 +
 4 files changed, 239 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b43f82b3/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/List.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/List.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/List.as
index a081d12..067ee8e 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/List.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/List.as
@@ -18,53 +18,24 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mdl
 {
-	import org.apache.flex.html.List;
-	
+    import org.apache.flex.html.List;
     COMPILE::JS
     {
-        import org.apache.flex.core.WrappedHTMLElement;
-        import org.apache.flex.html.beads.ListView;
-        import org.apache.flex.html.supportClasses.DataGroup;
+        import goog.events;
+        import org.apache.flex.core.WrappedHTMLElement;            
     }
-	
+        
 	/**
-	 *  Indicates that the initialization of the list is complete.
+	 *  The SimpleList class is a component that displays data in a vertical column. This
+	 *  component differs from org.apache.flex.html.List in that it displays 
+	 *  only string values and maps to the &lt;select&gt; HTML element.
 	 *  
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	[Event(name="initComplete", type="org.apache.flex.events.Event")]
-	
-	/**
-	 * The change event is dispatched whenever the list's selection changes.
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10.2
-	 *  @playerversion AIR 2.6
-	 *  @productversion FlexJS 0.0
-	 */
-    [Event(name="change", type="org.apache.flex.events.Event")]
-    
-	/**
-	 *  The List class is a component that displays multiple data items. The List uses
-	 *  the following bead types:
-	 * 
-	 *  org.apache.flex.core.IBeadModel: the data model, which includes the dataProvider, selectedItem,
and
-	 *  so forth.
-	 *  org.apache.flex.core.IBeadView:  the bead that constructs the visual parts of the list.
-	 *  org.apache.flex.core.IBeadController: the bead that handles input and output.
-	 *  org.apache.flex.core.IBeadLayout: the bead responsible for the size and position of
the itemRenderers.
-	 *  org.apache.flex.core.IDataProviderItemRendererMapper: the bead responsible for creating
the itemRenders.
-	 *  org.apache.flex.core.IItemRenderer: the class or factory used to display an item in
the list.
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10.2
-	 *  @playerversion AIR 2.6
-	 *  @productversion FlexJS 0.0
-	 */
-	public class List extends org.apache.flex.html.List
+	public class List extends org.apache.flex.html.SimpleList
 	{
 		/**
 		 *  constructor.
@@ -80,38 +51,35 @@ package org.apache.flex.mdl
 
             className = ""; //set to empty string avoid 'undefined' output when no class
selector is assigned by user;
 		}
-		
-		
-        /**
-         * @flexjsignorecoercion org.apache.flex.html.beads.ListView 
-         * @flexjsignorecoercion org.apache.flex.html.supportClasses.DataGroup 
-         */
-        /*COMPILE::JS
-        override public function internalChildren():Array
-        {
-            var listView:ListView = getBeadByType(ListView) as ListView;
-            var dg:DataGroup = listView.dataGroup as DataGroup;
-            var renderers:Array = dg.internalChildren();
-            return renderers;
-        };*/
-
+        
         /**
-         * @return The actual element to be parented.
          * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+         * @flexjsignorecoercion HTMLSelectElement
          */
-		COMPILE::JS
+        COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
             typeNames = "mdl-list";
             
             element = document.createElement('ul') as WrappedHTMLElement;
             element.className = typeNames;
+            //(element as HTMLSelectElement).size = 5;
+            //goog.events.listen(element, 'change',changeHandler);
             
             positioner = element;
             
             element.flexjs_wrapper = this;
             
             return positioner;
+        }   
+        
+        /**
+         * @flexjsignorecoercion HTMLSelectElement
+         */
+        COMPILE::JS
+        override protected function changeHandler(event:Event):void
+        {
+            model.selectedIndex = (element as HTMLSelectElement).selectedIndex;
         }
-   	}
+	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b43f82b3/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ListView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ListView.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ListView.as
new file mode 100644
index 0000000..dd65596
--- /dev/null
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ListView.as
@@ -0,0 +1,213 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.mdl.beads
+{	
+    import org.apache.flex.html.beads.IListView;
+    import org.apache.flex.html.beads.ContainerView;
+	import org.apache.flex.core.BeadViewBase;
+	import org.apache.flex.core.ContainerBase;
+	import org.apache.flex.core.IBead;
+	import org.apache.flex.core.IBeadLayout;
+	import org.apache.flex.core.IBeadModel;
+	import org.apache.flex.core.IBeadView;
+	import org.apache.flex.core.ISelectableItemRenderer;
+	import org.apache.flex.core.IItemRenderer;
+	import org.apache.flex.core.IItemRendererParent;
+	import org.apache.flex.core.IParent;
+    import org.apache.flex.core.IParentIUIBase;
+	import org.apache.flex.core.IRollOverModel;
+	import org.apache.flex.core.ISelectionModel;
+	import org.apache.flex.core.IStrand;
+    import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.Strand;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.ValuesManager;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.html.beads.models.ArraySelectionModel;
+	import org.apache.flex.html.beads.models.ScrollBarModel;
+	import org.apache.flex.html.beads.models.SingleLineBorderModel;
+	import org.apache.flex.html.supportClasses.Border;
+	import org.apache.flex.html.supportClasses.DataGroup;
+	import org.apache.flex.html.supportClasses.ScrollBar;
+
+	/**
+	 *  The List class creates the visual elements of the org.apache.flex.html.List 
+	 *  component. A List consists of the area to display the data (in the dataGroup), any 
+	 *  scrollbars, and so forth.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class ListView extends ContainerView implements IListView
+	{
+		public function ListView()
+		{
+		}
+						
+		protected var listModel:ISelectionModel;
+		
+		private var _border:Border;
+		
+		/**
+		 *  The border surrounding the org.apache.flex.html.List.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+        public function get border():Border
+        {
+            return _border;
+        }
+		
+		/**
+		 *  The area holding the itemRenderers.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get dataGroup():IItemRendererParent
+		{
+			//(contentView as UIBase).className = "ListDataGroup";
+			return contentView as IItemRendererParent;
+		}
+				
+		/**
+		 * @private
+		 */
+		override public function get resizableView():IUIBase
+		{
+			return _strand as IUIBase;
+		}
+        
+        /**
+         * @private
+         */
+        override public function get host():IUIBase
+        {
+            return _strand as IUIBase;
+        }
+        		
+		/**
+		 *  @copy org.apache.flex.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		override public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			super.strand = value;
+		}
+		
+		override protected function completeSetup():void
+		{
+			super.completeSetup();
+			
+			// list is not interested in UI children, it wants to know when new items
+			// have been added or the dataProvider has changed.
+			
+			host.removeEventListener("childrenAdded", childrenChangedHandler);
+			host.removeEventListener("childrenAdded", performLayout);
+			host.addEventListener("itemsCreated", itemsCreatedHandler);
+			
+			listModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
+			listModel.addEventListener("selectedIndexChanged", selectionChangeHandler);
+			listModel.addEventListener("rollOverIndexChanged", rollOverIndexChangeHandler);
+			listModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
+		}
+		
+		protected var lastSelectedIndex:int = -1;
+		
+		/**
+		 * @private
+		 */
+		protected function itemsCreatedHandler(event:Event):void
+		{
+			performLayout(event);
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function dataProviderChangeHandler(event:Event):void
+		{
+			performLayout(event);
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function selectionChangeHandler(event:Event):void
+		{
+			if (lastSelectedIndex != -1)
+			{
+				var ir:ISelectableItemRenderer = dataGroup.getItemRendererForIndex(lastSelectedIndex)
as ISelectableItemRenderer;
+                if (ir != null) ir.selected = false;
+			}
+			if (listModel.selectedIndex != -1)
+			{
+	            ir = dataGroup.getItemRendererForIndex(listModel.selectedIndex) as ISelectableItemRenderer;
+	            if (ir != null) ir.selected = true;
+			}
+            lastSelectedIndex = listModel.selectedIndex;
+		}
+		
+		protected var lastRollOverIndex:int = -1;
+		
+		/**
+		 * @private
+		 */
+		protected function rollOverIndexChangeHandler(event:Event):void
+		{
+			if (lastRollOverIndex != -1)
+			{
+				var ir:ISelectableItemRenderer = dataGroup.getItemRendererForIndex(lastRollOverIndex)
as ISelectableItemRenderer;
+                ir.hovered = false;
+			}
+			if (IRollOverModel(listModel).rollOverIndex != -1)
+			{
+	            ir = dataGroup.getItemRendererForIndex(IRollOverModel(listModel).rollOverIndex)
as ISelectableItemRenderer;
+	            ir.hovered = true;
+			}
+			lastRollOverIndex = IRollOverModel(listModel).rollOverIndex;
+		}
+        
+        /**
+         *  respond to a change in size or request to re-layout everything
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		override protected function resizeHandler(event:Event):void
+		{
+			super.resizeHandler(event);
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b43f82b3/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
index bfeee42..6b3ad2a 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/defaults.css
@@ -33,11 +33,11 @@ Slider
 List
 {
     IBeadModel: ClassReference("org.apache.flex.html.beads.models.ArraySelectionModel");
-    IBeadView:  ClassReference("org.apache.flex.html.beads.ListView");			
+    IBeadView:  ClassReference("org.apache.flex.mdl.beads.ListView");
     IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController");
     IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.VerticalLayout");
     IContentView: ClassReference("org.apache.flex.html.supportClasses.DataGroup");
-    IDataProviderItemRendererMapper: ClassReference("org.apache.flex.html.beads.DataItemRendererFactoryForArrayData");
+    IDataProviderItemRendererMapper: ClassReference("org.apache.flex.html.beads.TextItemRendererFactoryForArrayData");
     IItemRendererClassFactory: ClassReference("org.apache.flex.core.ItemRendererClassFactory");
     IItemRenderer: ClassReference("org.apache.flex.html.supportClasses.StringItemRenderer");
 	IViewport: ClassReference("org.apache.flex.html.supportClasses.ScrollingViewport");

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b43f82b3/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
index 94443ce..31452d1 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
@@ -41,6 +41,7 @@
     <component id="CardMenu" class="org.apache.flex.mdl.CardMenu"/>
     <component id="Spacer" class="org.apache.flex.mdl.Spacer"/>
     <component id="List" class="org.apache.flex.mdl.List"/>
+    <component id="ListView" class="org.apache.flex.mdl.beads.ListView"/>
     <component id="NavigationLayout" class="org.apache.flex.mdl.NavigationLayout"/>
     <component id="LayoutTitle" class="org.apache.flex.mdl.LayoutTitle"/>
     <component id="Navigation" class="org.apache.flex.mdl.Navigation"/>


Mime
View raw message