You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2018/01/12 22:53:06 UTC

[royale-asjs] branch develop updated (77de773 -> fb2d1e6)

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

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


    from 77de773  fix versioning of release poms
     new efaf04a  Fix issue where DataGridPercentageView messed up with DataItemRendererFactoryForCollectionView. Clean up View by removing unnecessary duplicated code from DataGridView.
     new fb2d1e6  Update DataGridExample with latest fixes in DataGridPercentageView

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/royale/MyInitialView.mxml             |  12 +-
 .../royale/html/beads/DataGridPercentageView.as    | 248 +++------------------
 .../org/apache/royale/html/beads/DataGridView.as   |  67 +++---
 .../royale/html/beads/DataGridColumnReorderView.as |   4 +-
 4 files changed, 63 insertions(+), 268 deletions(-)

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

[royale-asjs] 02/02: Update DataGridExample with latest fixes in DataGridPercentageView

Posted by pi...@apache.org.
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

commit fb2d1e65c3817048544474e3454175fbe965ed0b
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Fri Jan 12 23:52:47 2018 +0100

    Update DataGridExample with latest fixes in DataGridPercentageView
---
 .../DataGridExample/src/main/royale/MyInitialView.mxml       | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/examples/royale/DataGridExample/src/main/royale/MyInitialView.mxml b/examples/royale/DataGridExample/src/main/royale/MyInitialView.mxml
index bf530b7..086cae9 100644
--- a/examples/royale/DataGridExample/src/main/royale/MyInitialView.mxml
+++ b/examples/royale/DataGridExample/src/main/royale/MyInitialView.mxml
@@ -60,6 +60,11 @@ limitations under the License.
 			border-right: solid 1px #333333;
 		}
 		
+		.DataGridStyle
+		{
+			IBeadView: ClassReference("org.apache.royale.html.beads.DataGridPercentageView");	
+		}
+		
 		.DynamicGrid {
 			IBeadModel: ClassReference("org.apache.royale.html.beads.models.DataGridModel");
 		}
@@ -83,9 +88,9 @@ limitations under the License.
 	<js:TextButton x="520" y="490" text="Remove Value" click="removeValue()" />
 	
 		
-	<js:DataGrid id="dataGrid" x="20" y="50" width="400" height="350" change="dataGridChange(dataGrid, output1)" rowHeight="40">
+	<js:DataGrid id="dataGrid" x="20" y="50" width="400" height="350" change="dataGridChange(dataGrid, output1)" 
+				 rowHeight="40" className="DataGridStyle">
 		<js:beads>
-			<js:DataGridPercentageView />
 			<js:ConstantBinding
 				sourceID="applicationModel"
 				sourcePropertyName="productList"
@@ -106,7 +111,8 @@ limitations under the License.
 				destinationPropertyName="dataProvider" />
 		</js:beads>
 		<js:columns>
-			<js:DataGridColumn label="Image" dataField="image" columnWidth="100" itemRenderer="products.ProductItemRenderer" className="DynamicGridColumn" />
+			<js:DataGridColumn label="Image" dataField="image" columnWidth="100" itemRenderer="products.ProductItemRenderer" 
+							   className="DynamicGridColumn" />
 			<js:DataGridColumn label="Title" dataField="title" columnWidth="200" className="DynamicGridColumn" />
 			<js:DataGridColumn label="Sales" dataField="sales" columnWidth="100" className="DynamicGridColumn" />
 		</js:columns>

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

[royale-asjs] 01/02: Fix issue where DataGridPercentageView messed up with DataItemRendererFactoryForCollectionView. Clean up View by removing unnecessary duplicated code from DataGridView.

Posted by pi...@apache.org.
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

commit efaf04a71baf50dc9fa1390569a4707482a57373
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Fri Jan 12 23:52:09 2018 +0100

    Fix issue where DataGridPercentageView messed up with DataItemRendererFactoryForCollectionView. Clean up View by removing unnecessary duplicated code from DataGridView.
---
 .../royale/html/beads/DataGridPercentageView.as    | 248 +++------------------
 .../org/apache/royale/html/beads/DataGridView.as   |  67 +++---
 .../royale/html/beads/DataGridColumnReorderView.as |   4 +-
 3 files changed, 54 insertions(+), 265 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridPercentageView.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridPercentageView.as
index eff121e..5cd82d5 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridPercentageView.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridPercentageView.as
@@ -18,29 +18,12 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.html.beads
 {
-	import org.apache.royale.core.IBeadModel;
-	import org.apache.royale.core.IBeadView;
 	import org.apache.royale.core.IDataGridModel;
-	import org.apache.royale.core.IDataGridPresentationModel;
-	import org.apache.royale.core.ISelectionModel;
-	import org.apache.royale.core.IStrand;
-	import org.apache.royale.core.IUIBase;
-	import org.apache.royale.core.ValuesManager;
 	import org.apache.royale.events.Event;
-	import org.apache.royale.events.IEventDispatcher;
 	import org.apache.royale.html.DataGrid;
-	import org.apache.royale.html.DataGridButtonBar;
-	import org.apache.royale.html.Container;
-	import org.apache.royale.html.beads.IDataGridView;
-	import org.apache.royale.html.beads.layouts.ButtonBarLayout;
 	import org.apache.royale.html.beads.models.ButtonBarModel;
 	import org.apache.royale.html.supportClasses.DataGridColumn;
 	import org.apache.royale.html.supportClasses.DataGridColumnList;
-	import org.apache.royale.html.supportClasses.Viewport;
-	
-	COMPILE::SWF {
-		import org.apache.royale.core.SimpleCSSStylesWithFlex;
-	}
 
 	/**
 	 *  The DataGridPercentageView class is the visual bead for the org.apache.royale.html.DataGrid.
@@ -54,7 +37,7 @@ package org.apache.royale.html.beads
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.0
 	 */
-	public class DataGridPercentageView extends GroupView implements IBeadView, IDataGridView
+	public class DataGridPercentageView extends DataGridView
 	{
 		/**
 		 *  constructor.
@@ -69,216 +52,37 @@ package org.apache.royale.html.beads
 			super();
 		}
 
-		private var _strand:IStrand;
-		private var _header:DataGridButtonBar;
-		private var _listArea:Container;
-		
-		private var _lists:Array;
-		
-		/**
-		 * An array of List objects the comprise the columns of the DataGrid.
-		 */
-		public function get columnLists():Array
-		{
-			return _lists;
-		}
-		
-		/**
-		 * The area used to hold the columns
-		 *
-		 */
-		public function get listArea():Container
-		{
-			return _listArea;
-		}
-		
-		/**
-		 * Returns the component used as the header for the DataGrid.
-		 */
-		public function get header():IUIBase
-		{
-			return _header;
-		}
-
-		/**
-		 *  @copy org.apache.royale.core.IBead#strand
-		 *
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
-		 */
-		override public function set strand(value:IStrand):void
-		{
-			super.strand = value;
-			_strand = value;
-
-			var host:DataGrid = value as DataGrid;
-
-			_header = new DataGridButtonBar();
-			_header.height = 30;
-			_header.percentWidth = 100;
-
-			_listArea = new Container();
-			_listArea.percentWidth = 100;
-			_listArea.className = "opt_org-apache.royale-html-DataGrid_ListArea";
-			
-			COMPILE::SWF {
-				_header.style = new SimpleCSSStylesWithFlex();
-				_header.style.flexGrow = 0;
-				
-				_listArea.style = new SimpleCSSStylesWithFlex();
-				_listArea.style.flexGrow = 1;
-			}
-			COMPILE::JS {
-				_header.element.style["flex-grow"] = "0";
-				_header.element.style["min-height"] = "30px";
-				_listArea.element.style["flex-grow"] = "1";
-			}
-			
-			IEventDispatcher(_strand).addEventListener("initComplete", finishSetup);
-		}
-
-		/**
-		 * @private
-		 */
-		private function finishSetup(event:Event):void
+        /**
+         * @private
+         */
+        override protected function handleInitComplete(event:Event):void
 		{
-			var host:DataGrid = _strand as DataGrid;
-			
-			if (_lists == null || _lists.length == 0) {
-				createLists();
-			}
-
-			// see if there is a presentation model already in place. if not, add one.
-			var presentationModel:IDataGridPresentationModel = host.presentationModel;
-			var sharedModel:IDataGridModel = host.model as IDataGridModel;
-			IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",handleDataProviderChanged);
-			IEventDispatcher(sharedModel).addEventListener("selectedIndexChanged", handleSelectedIndexChanged);
-
-			var columnLabels:Array = new Array();
-			var buttonWidths:Array = new Array();
-
-			for(var i:int=0; i < sharedModel.columns.length; i++) {
-				var dgc:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
-				columnLabels.push(dgc.label);
-				var colWidth:Number = dgc.columnWidth;
-				buttonWidths.push(colWidth);
-				
-				var list:DataGridColumnList = _lists[i] as DataGridColumnList;
-				if (!isNaN(colWidth)) {
-					list.percentWidth = Number(colWidth);
-				} else {
-					COMPILE::SWF {
-						list.style = new SimpleCSSStylesWithFlex();
-						list.style.flexGrow = 1;
-					}
-						COMPILE::JS {
-							list.element.style["flex-grow"] = "1";
-						}
-				}
-			}
-
-			var bblayout:ButtonBarLayout = new ButtonBarLayout();
-			_header.buttonWidths = buttonWidths
-			_header.widthType = ButtonBarModel.PERCENT_WIDTHS;
-			_header.dataProvider = columnLabels;
-			_header.addBead(bblayout);
-			_header.addBead(new Viewport());
-			host.addElement(_header);
-
-			host.addElement(_listArea);
-
-			handleDataProviderChanged(event);
-		}
-
-		/**
-		 * @private
-		 */
-		private function handleSizeChanges(event:Event):void
-		{	
-			_header.dispatchEvent(new Event("layoutChanged"));
-			_listArea.dispatchEvent(new Event("layoutChanged"));
-		}
+			super.handleInitComplete(event);
 
-		/**
-		 * @private
-		 */
-		private function handleDataProviderChanged(event:Event):void
-		{
-			host.dispatchEvent(new Event("layoutNeeded"));
-		}
-		
-		/**
-		 * @private
-		 */
-		private function handleSelectedIndexChanged(event:Event):void
-		{
-			var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
-			var newIndex:int = sharedModel.selectedIndex;
-			
-			for (var i:int=0; i < _lists.length; i++)
+            if (columnLists)
 			{
-				var list:DataGridColumnList = _lists[i] as DataGridColumnList;
-				list.selectedIndex = newIndex;
-			}
-		}
-
-		/**
-		 * @private
-		 */
-		private function handleColumnListChange(event:Event):void
-		{
-			var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
-			var list:DataGridColumnList = event.target as DataGridColumnList;
-			sharedModel.selectedIndex = list.selectedIndex;
-
-			for(var i:int=0; i < _lists.length; i++) {
-				if (list != _lists[i]) {
-					var otherList:DataGridColumnList = _lists[i] as DataGridColumnList;
-					otherList.selectedIndex = list.selectedIndex;
-				}
-			}
-
-			host.dispatchEvent(new Event('change'));
-		}
-
-		/**
-		 * @private
-		 */
-		private function createLists():void
-		{
-			var host:DataGrid = _strand as DataGrid;
-			
-			var sharedModel:IDataGridModel = host.model as IDataGridModel;
-			var presentationModel:IDataGridPresentationModel = host.presentationModel;
-
-			_lists = new Array();
-
-			for (var i:int=0; i < sharedModel.columns.length; i++) {
-				var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
-
-				var list:DataGridColumnList = new DataGridColumnList();
-				list.id = "dataGridColumn"+String(i);
-				list.addBead(sharedModel);
-				list.itemRenderer = dataGridColumn.itemRenderer;
-				list.labelField = dataGridColumn.dataField;
-				list.addEventListener('change',handleColumnListChange);
-				list.addBead(presentationModel);
-				
-				if (i == 0) {
-					list.className = "first";
-				} else if (i == sharedModel.columns.length-1) {
-					list.className = "last";
-				} else {
-					list.className = "middle";
+                var host:DataGrid = _strand as DataGrid;
+                var sharedModel:IDataGridModel = host.model as IDataGridModel;
+				var columnListCount:int = sharedModel.columns.length;
+                var buttonWidths:Array = [];
+
+				for (var i:int = 0; i < columnListCount; i++)
+				{
+                    var dgc:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
+                    var colWidth:Number = dgc.columnWidth;
+                    buttonWidths.push(colWidth);
+
+                    var list:DataGridColumnList = columnLists[i] as DataGridColumnList;
+                    if (!isNaN(dgc.columnWidth))
+                    {
+						list.width = NaN;
+                        list.percentWidth = Number(colWidth);
+                    }
 				}
 
-				_listArea.addElement(list);
-				_lists.push(list);
+                header.buttonWidths = buttonWidths;
+                header.widthType = ButtonBarModel.PERCENT_WIDTHS;
 			}
-
-			host.dispatchEvent(new Event("layoutNeeded"));
 		}
 	}
 }
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridView.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridView.as
index 5a17549..7e2f756 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridView.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/DataGridView.as
@@ -21,17 +21,14 @@ package org.apache.royale.html.beads
 	import org.apache.royale.core.IBeadModel;
 	import org.apache.royale.core.IBeadView;
 	import org.apache.royale.core.IDataGridModel;
+	import org.apache.royale.core.IChild;
 	import org.apache.royale.core.IDataGridPresentationModel;
-	import org.apache.royale.core.ISelectionModel;
-	import org.apache.royale.core.IStrand;
-	import org.apache.royale.core.IUIBase;
-	import org.apache.royale.core.ValuesManager;
 	import org.apache.royale.events.Event;
 	import org.apache.royale.events.IEventDispatcher;
+    import org.apache.royale.core.IBead;
 	import org.apache.royale.html.DataGrid;
 	import org.apache.royale.html.DataGridButtonBar;
 	import org.apache.royale.html.Container;
-	import org.apache.royale.html.beads.IDataGridView;
 	import org.apache.royale.html.beads.layouts.ButtonBarLayout;
 	import org.apache.royale.html.beads.models.ButtonBarModel;
 	import org.apache.royale.html.supportClasses.DataGridColumn;
@@ -68,7 +65,6 @@ package org.apache.royale.html.beads
 				super();
 			}
 
-			private var _strand:IStrand;
 			private var _header:DataGridButtonBar;
 			private var _listArea:Container;
 
@@ -94,41 +90,24 @@ package org.apache.royale.html.beads
 			/**
 			 * Returns the component used as the header for the DataGrid.
 			 */
-			public function get header():IUIBase
+			public function get header():DataGridButtonBar
 			{
 				return _header;
 			}
 
-			/**
-			 *  @copy org.apache.royale.core.IBead#strand
-			 *
-			 *  @langversion 3.0
-			 *  @playerversion Flash 10.2
-			 *  @playerversion AIR 2.6
-			 *  @productversion Royale 0.0
-			 */
-			override public function set strand(value:IStrand):void
-			{
-				super.strand = value;
-				_strand = value;
-
-				IEventDispatcher(_strand).addEventListener("beadsAdded", finishSetup);
-			}
-
-			public function refreshContent():void
-			{
-				finishSetup(null);
-			}
+            public function refreshContent():void
+            {
+                handleInitComplete(null);
+            }
 
 			/**
 			 * @private
 			 */
-			protected function finishSetup(event:Event):void
+			override protected function handleInitComplete(event:Event):void
 			{
 				var host:DataGrid = _strand as DataGrid;
 
 				// see if there is a presentation model already in place. if not, add one.
-				var presentationModel:IDataGridPresentationModel = host.presentationModel;
 				var sharedModel:IDataGridModel = host.model as IDataGridModel;
 				IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",handleDataProviderChanged);
 				IEventDispatcher(sharedModel).addEventListener("selectedIndexChanged", handleSelectedIndexChanged);
@@ -188,13 +167,13 @@ package org.apache.royale.html.beads
 				}
 
 				var bblayout:ButtonBarLayout = new ButtonBarLayout();
-				_header.buttonWidths = buttonWidths
+				_header.buttonWidths = buttonWidths;
 				_header.widthType = ButtonBarModel.PIXEL_WIDTHS;
-				_header.addBead(bblayout);
-				_header.addBead(new Viewport());
-				host.addElement(_header);
+				_header.addBead(bblayout as IBead);
+				_header.addBead(new Viewport() as IBead);
+				host.addElement(_header as IChild);
 
-				host.addElement(_listArea);
+				host.addElement(_listArea as IChild);
 
 				handleDataProviderChanged(event);
 
@@ -266,9 +245,10 @@ package org.apache.royale.html.beads
 				var sharedModel:IDataGridModel = host.model as IDataGridModel;
 				var presentationModel:IDataGridPresentationModel = host.presentationModel;
 
-				_lists = new Array();
+				_lists = [];
 
-				for (var i:int=0; i < sharedModel.columns.length; i++) {
+				for (var i:int=0; i < sharedModel.columns.length; i++)
+				{
 					var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
 
 					var list:DataGridColumnList = new DataGridColumnList();
@@ -278,17 +258,22 @@ package org.apache.royale.html.beads
 					list.itemRenderer = dataGridColumn.itemRenderer;
 					list.labelField = dataGridColumn.dataField;
 					list.addEventListener('change',handleColumnListChange);
-					list.addBead(presentationModel);
+					list.addBead(presentationModel as IBead);
 
-					if (i == 0) {
+					if (i == 0)
+					{
 						list.typeNames = "first";
-					} else if (i == sharedModel.columns.length-1) {
+					}
+					else if (i == sharedModel.columns.length-1)
+					{
 						list.typeNames = "last";
-					} else {
+					}
+					else
+					{
 						list.typeNames = "middle";
 					}
 
-					_listArea.addElement(list);
+					_listArea.addElement(list as IChild);
 					_lists.push(list);
 				}
 
diff --git a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridColumnReorderView.as b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridColumnReorderView.as
index 7349e0c..4776856 100644
--- a/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridColumnReorderView.as
+++ b/frameworks/projects/DragDrop/src/main/royale/org/apache/royale/html/beads/DataGridColumnReorderView.as
@@ -72,9 +72,9 @@ package org.apache.royale.html.beads
 			/**
 			 * @private
 			 */
-			override protected function finishSetup(event:Event):void
+            override protected function handleInitComplete(event:Event):void
 			{
-				super.finishSetup(event);
+				super.handleInitComplete(event);
 
 				 var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
 				IEventDispatcher(sharedModel).addEventListener("headerModelChanged", handleHeaderModelChanged);

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