You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2020/08/31 22:02:57 UTC

[royale-asjs] branch develop updated: jewel-presentationmodels: fix issue where adding PM via mxml beads was causing not use the custom bead since it was initialized during component constructor

This is an automated email from the ASF dual-hosted git repository.

carlosrovira 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 79ce41d  jewel-presentationmodels: fix issue where adding PM via mxml beads was causing not use the custom bead since it was initialized during component constructor
79ce41d is described below

commit 79ce41dfa69a494e3bca83b6e8a3fc91b9596823
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Tue Sep 1 00:02:45 2020 +0200

    jewel-presentationmodels: fix issue where adding PM via mxml beads was causing not use the custom bead since it was initialized during component constructor
---
 .../Jewel/src/main/resources/jewel-manifest.xml    |  2 +
 .../main/royale/org/apache/royale/jewel/List.as    | 21 +++++----
 .../main/royale/org/apache/royale/jewel/TabBar.as  | 34 +++++++++-----
 .../models/DataGridColumnListPresentationModel.as  | 48 ++++++++++++++++++++
 .../jewel/beads/models/ListPresentationModel.as    |  3 +-
 .../jewel/beads/models/TabBarPresentationModel.as  | 52 ++++++++++++++++++++++
 .../supportClasses/datagrid/DataGridColumnList.as  | 25 +++++++++--
 7 files changed, 161 insertions(+), 24 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 80f662b..5a09f2e 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -233,6 +233,8 @@
     <component id="DropDownListItemRenderer" class="org.apache.royale.jewel.itemRenderers.DropDownListItemRenderer"/>
 
     <component id="ListPresentationModel" class="org.apache.royale.jewel.beads.models.ListPresentationModel"/>
+    <component id="TabBarPresentationModel" class="org.apache.royale.jewel.beads.models.TabBarPresentationModel"/>
+    <component id="DataGridColumnListPresentationModel" class="org.apache.royale.jewel.beads.models.DataGridColumnListPresentationModel"/>
 
     <component id="Viewport" class="org.apache.royale.jewel.supportClasses.Viewport"/>
     <component id="ScrollingViewport" class="org.apache.royale.jewel.supportClasses.scrollbar.ScrollingViewport"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as
index 5eeb104..acba7e1 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as
@@ -83,9 +83,6 @@ package org.apache.royale.jewel
 		{
 			super();
             typeNames = "jewel list";
-			// rowHeight is not set by default, so set it to NaN
-			rowHeight = NaN;
-
 			tabIndex = 0;
 		}
 
@@ -218,12 +215,18 @@ package org.apache.royale.jewel
 		}
 
 		/**
-		 * @private
-		 */
-		override public function addedToParent():void
-		{
-			super.addedToParent();
-
+         *  load necesary beads. This method can be override in subclasses to
+         *  add other custom beads needed, so all requested beads be loaded before
+         *  signal the "beadsAdded" event.
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.10.0
+         */
+        override protected function loadBeads():void
+        {
+			super.loadBeads();
 			loadBeadFromValuesManager(IBeadKeyController, "iBeadKeyController", this);
 		}
    	}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/TabBar.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/TabBar.as
index e9e28c9..a271183 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/TabBar.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/TabBar.as
@@ -18,8 +18,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.jewel
 {
-	import org.apache.royale.events.MouseEvent;
+	import org.apache.royale.core.IBead;
 	import org.apache.royale.core.ISelectionModel;
+	import org.apache.royale.events.MouseEvent;
+	import org.apache.royale.jewel.beads.models.TabBarPresentationModel;
+	import org.apache.royale.jewel.supportClasses.list.IListPresentationModel;
 
 	/**
 	 *  The TabBar class is a List used for navigate other organized content
@@ -45,18 +48,9 @@ package org.apache.royale.jewel
 		public function TabBar()
 		{
 			super();
-
             typeNames = "jewel tabbar";
-
 			//TabBar is always selected, so selectedIndex can't be -1, at least it will default to 0
 			ISelectionModel(model).selectedIndex = 0;
-
-			// rowHeight is not set by default, so set it to NaN
-			rowHeight = NaN;
-
-			// by default the row height (if set) rules
-			variableRowHeight = false;
-
 			addEventListener(MouseEvent.CLICK, internalMouseHandler);
 		}
 
@@ -96,6 +90,26 @@ package org.apache.royale.jewel
 			}
 		}
 
+
+		/**
+		 *  The presentation model for the tabbar.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.10.0
+		 *  @royaleignorecoercion org.apache.royale.jewel.supportClasses.list.IListPresentationModel
+		 */
+		override public function get presentationModel():IBead
+		{
+			var presModel:IListPresentationModel = getBeadByType(IListPresentationModel) as IListPresentationModel;
+			if (presModel == null) {
+				presModel = new TabBarPresentationModel();
+				addBead(presModel);
+			}
+			return presModel;
+		}
+
 		/**
 		 * Load the layout bead if it hasn't already been loaded.
          * 
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/DataGridColumnListPresentationModel.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/DataGridColumnListPresentationModel.as
new file mode 100644
index 0000000..3a584ec
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/DataGridColumnListPresentationModel.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.jewel.beads.models
+{	
+	/**
+	 *  The DataGridColumnListPresentationModel holds values used by column list controls for presenting
+	 *  their user interfaces.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.10.0
+	 */
+	public class DataGridColumnListPresentationModel extends ListPresentationModel
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.10.0
+		 */
+		public function DataGridColumnListPresentationModel()
+		{
+			super();
+
+			// rowHeight need to be set to a default value to avoid potential different column heights
+			rowHeight = DEFAULT_ROW_HEIGHT;
+		}
+	}
+}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ListPresentationModel.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ListPresentationModel.as
index 295228c..b381176 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ListPresentationModel.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ListPresentationModel.as
@@ -50,9 +50,8 @@ package org.apache.royale.jewel.beads.models
 		{
 			super();
 		}
-
 		
-		private var _rowHeight:Number = DEFAULT_ROW_HEIGHT;
+		private var _rowHeight:Number = NaN;
 		/**
 		 *  The height of each row.
 		 *
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/TabBarPresentationModel.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/TabBarPresentationModel.as
new file mode 100644
index 0000000..6f5988f
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/TabBarPresentationModel.as
@@ -0,0 +1,52 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.jewel.beads.models
+{	
+	/**
+	 *  The TabBarPresentationModel holds values used by tabbar controls for presenting
+	 *  their user interfaces.
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.10.0
+	 */
+	public class TabBarPresentationModel extends ListPresentationModel
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.10.0
+		 */
+		public function TabBarPresentationModel()
+		{
+			super();
+
+			// (ListPresentationModel) rowHeight is not set by default, so set it to NaN
+			//rowHeight = NaN;
+
+			// by default the row height (if set) rules
+			variableRowHeight = false;
+
+		}
+	}
+}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as
index 0fc28db..7bf34b6 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/datagrid/DataGridColumnList.as
@@ -18,10 +18,12 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.jewel.supportClasses.datagrid
 {
+    import org.apache.royale.core.IBead;
     import org.apache.royale.jewel.DataGrid;
     import org.apache.royale.jewel.List;
-    import org.apache.royale.jewel.beads.models.ListPresentationModel;
+    import org.apache.royale.jewel.beads.models.DataGridColumnListPresentationModel;
     import org.apache.royale.jewel.supportClasses.datagrid.IDataGridColumnList;
+    import org.apache.royale.jewel.supportClasses.list.IListPresentationModel;
     
     //--------------------------------------
     //  Events
@@ -60,8 +62,6 @@ package org.apache.royale.jewel.supportClasses.datagrid
 		{
 			super();
 			typeNames = "jewel list column";
-            // rowHeight need to be set to a default value to avoid potential different column heights
-			rowHeight = ListPresentationModel.DEFAULT_ROW_HEIGHT;
 		}
 		
         /**
@@ -93,5 +93,24 @@ package org.apache.royale.jewel.supportClasses.datagrid
 		public function set datagrid(value:DataGrid):void {
             _datagrid = value;
         }
+
+        /**
+		 *  The presentation model for the list.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9
+		 *  @royaleignorecoercion org.apache.royale.jewel.supportClasses.list.IListPresentationModel
+		 */
+		override public function get presentationModel():IBead
+		{
+			var presModel:IListPresentationModel = getBeadByType(IListPresentationModel) as IListPresentationModel;
+			if (presModel == null) {
+				presModel = new DataGridColumnListPresentationModel();
+				addBead(presModel);
+			}
+			return presModel;
+		}
 	}
 }