flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [26/50] git commit: [flex-asjs] [refs/heads/master] - Updated DataGrid and MobileTrader examples to use ArrayList as dataProvider to DataGrid components.
Date Wed, 16 Dec 2015 21:36:12 GMT
Updated DataGrid and MobileTrader examples to use ArrayList as dataProvider to DataGrid components.


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

Branch: refs/heads/master
Commit: 848f245dbb8730170193f2c2f7405cf74738d347
Parents: c472807
Author: Peter Ent <pent@apache.org>
Authored: Wed Oct 7 15:58:13 2015 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Wed Oct 7 15:58:13 2015 -0400

----------------------------------------------------------------------
 .../DataGridExample/src/models/ProductsModel.as | 10 ++++--
 .../src/controller/AlertsViewController.as      |  5 +--
 .../src/controller/WatchListController.as       |  5 +--
 .../MobileTrader/src/models/AssetsModel.as      | 14 +++++++--
 .../MobileTrader/src/models/ProductsModel.as    | 32 +++++++++++---------
 .../MobileTrader/src/views/AlertsView.mxml      |  3 +-
 .../MobileTrader/src/views/AssetsView.mxml      |  4 +--
 .../MobileTrader/src/views/WatchListView.mxml   |  1 +
 8 files changed, 49 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/DataGridExample/src/models/ProductsModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataGridExample/src/models/ProductsModel.as b/examples/flexjs/DataGridExample/src/models/ProductsModel.as
index e3a42a9..8eab2fe 100644
--- a/examples/flexjs/DataGridExample/src/models/ProductsModel.as
+++ b/examples/flexjs/DataGridExample/src/models/ProductsModel.as
@@ -19,6 +19,7 @@
 package models
 {
 	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.collections.ArrayList;
 	
 	import products.Product;
 	
@@ -26,16 +27,21 @@ package models
 	{
 		public function ProductsModel()
 		{
+			_productList = new ArrayList();
+			_productList.source = source;
 		}
 
-		private var _productList:Array = [
+		private var source:Array = [
 			new Product("ps100","Widgets",44,200,"assets/smallbluerect.jpg"),
 			new Product("tx200","Thingys",5,285,"assets/smallgreenrect.jpg"),
 			new Product("rz300","Sprockets",80,105,"assets/smallyellowrect.jpg"),
 			new Product("dh440","Doohickies",10,340,"assets/smallredrect.jpg"),
 			new Product("ps220","Weejets",35,190,"assets/smallorangerect.jpg")
 			];
-		public function get productList():Array
+			
+		private var _productList:ArrayList;
+		
+		public function get productList():ArrayList
 		{
 			return _productList;
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/controller/AlertsViewController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/controller/AlertsViewController.as b/examples/flexjs/MobileTrader/src/controller/AlertsViewController.as
index 716264d..254cd18 100644
--- a/examples/flexjs/MobileTrader/src/controller/AlertsViewController.as
+++ b/examples/flexjs/MobileTrader/src/controller/AlertsViewController.as
@@ -28,6 +28,7 @@ package controller
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.EventDispatcher;
 	import org.apache.flex.utils.Timer;
+	import org.apache.flex.collections.ArrayList;
 	
 	import views.AlertsView;
 	
@@ -111,13 +112,13 @@ package controller
 		 */
 		protected function timerHandler(event:*):void
 		{
-			var alerts:Array = (model as ProductsModel).alerts;
+			var alerts:ArrayList = (model as ProductsModel).alerts;
 			
 			if (alerts.length == 0) return;
 			
 			for (var i:int=0; i < alerts.length; i++)
 			{
-				var alert:Alert = alerts[i] as Alert;
+				var alert:Alert = alerts.getItemAt(i) as Alert;
 				alert.message = "";
 				
 				if (alert.greaterThan) {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/controller/WatchListController.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/controller/WatchListController.as b/examples/flexjs/MobileTrader/src/controller/WatchListController.as
index 367b24f..5da5b70 100644
--- a/examples/flexjs/MobileTrader/src/controller/WatchListController.as
+++ b/examples/flexjs/MobileTrader/src/controller/WatchListController.as
@@ -27,6 +27,7 @@ package controller
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.EventDispatcher;
 	import org.apache.flex.utils.Timer;
+	import org.apache.flex.collections.ArrayList;
 	
 	import views.StockView;
 	import views.WatchListView;
@@ -121,13 +122,13 @@ package controller
 		 */
 		protected function timerHandler(event:*):void
 		{
-			var stockList:Array = (model as ProductsModel).watchList;
+			var stockList:ArrayList = (model as ProductsModel).watchList;
 			
 			if (stockList.length == 0) return;
 			
 			if (index >= stockList.length) index = 0;
 			
-			(model as ProductsModel).updateStockData(stockList[index] as Stock);
+			(model as ProductsModel).updateStockData(stockList.getItemAt(index) as Stock);
 			index++;
 			
 			var newEvent:Event = new Event("update");

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/models/AssetsModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/models/AssetsModel.as b/examples/flexjs/MobileTrader/src/models/AssetsModel.as
index 8824bc5..674adfe 100755
--- a/examples/flexjs/MobileTrader/src/models/AssetsModel.as
+++ b/examples/flexjs/MobileTrader/src/models/AssetsModel.as
@@ -21,24 +21,34 @@ package models
 	import org.apache.flex.core.IBeadModel;
 	import org.apache.flex.core.IStrand;
 	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.collections.ArrayList;
 	
 	public class AssetsModel extends EventDispatcher implements IBeadModel
 	{
 		public function AssetsModel()
 		{
 			super();
+			_assetsData = new ArrayList();
+			_assetsData.source = source;
 		}
-		private var _assetsData:Array = [
+		private var source:Array = [
 			{label:"Net Worth:",    value:161984, netChange:-2.37},
 			{label:"Last Month:",   value:165915, netChange:10.98},
 			{label:"6 Months Ago:", value:145962, netChange:16.56},
 			{label:"Last Year:",    value:138972, netChange:8.36}
 		];
-		public function get assetsData():Array
+		private var _assetsData:ArrayList;
+		
+		public function get assetsData():ArrayList
 		{
 			return _assetsData;
 		}
 		
+		public function get assetsDataAsArray():Array
+		{
+		    return source;
+		}
+		
 		public function set strand(value:IStrand):void
 		{
 			// not used

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/models/ProductsModel.as
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/models/ProductsModel.as b/examples/flexjs/MobileTrader/src/models/ProductsModel.as
index 7fb7a22..b6f91ad 100755
--- a/examples/flexjs/MobileTrader/src/models/ProductsModel.as
+++ b/examples/flexjs/MobileTrader/src/models/ProductsModel.as
@@ -25,6 +25,7 @@ package models
 	import org.apache.flex.net.HTTPService;
 	import org.apache.flex.collections.parsers.JSONInputParser;
 	import org.apache.flex.collections.LazyCollection;
+	import org.apache.flex.collections.ArrayList;
 		
 	public class ProductsModel extends EventDispatcher implements IBeadModel
 	{
@@ -36,6 +37,9 @@ package models
 			collection = new LazyCollection;
 			collection.inputParser = new JSONInputParser();
 			collection.itemConverter = new StockDataJSONItemConverter();
+			
+			_watchList = new ArrayList();
+			_alerts = new ArrayList();
 		}
 		
 		private var service:HTTPService;
@@ -64,16 +68,16 @@ package models
 			return _labelFields;
 		}
 		
-		private var _watchList:Array = [];
+		private var _watchList:ArrayList;
 		
-		public function get watchList():Array
+		public function get watchList():ArrayList
 		{
 			return _watchList;
 		}
 		
-		private var _alerts:Array = [];
+		private var _alerts:ArrayList;
 		
-		public function get alerts():Array
+		public function get alerts():ArrayList
 		{
 			return _alerts;
 		}
@@ -82,14 +86,14 @@ package models
 		{
 			for (var i:int =0; i < _alerts.length; i++)
 			{
-				var alert:Alert = _alerts[i] as Alert;
+				var alert:Alert = _alerts.getItemAt(i) as Alert;
 				if (alert.symbol == value.symbol) {
-					_alerts[i] = value;
+				    _alerts.setItemAt(value, i);
 					return;
 				}
 			}
 			
-			_alerts.push(value);
+			_alerts.addItem(value);
 			dispatchEvent(new Event("alertsUpdate"));
 		}
 		
@@ -97,13 +101,13 @@ package models
 		{
 			for (var i:int=0; i < _watchList.length; i++)
 			{
-				var stock:Stock = _watchList[i];
+				var stock:Stock = _watchList.getItemAt(i) as Stock;
 				if (stock.symbol == symbol) return stock;
 			}
 			
 			stock = new Stock(symbol);
 			
-			_watchList.push(stock);
+			_watchList.addItem(stock);
 			dispatchEvent(new Event("update"));
 			
 			updateStockData(stock);
@@ -122,18 +126,18 @@ package models
 		{
 			for (var i:int=0; i < alerts.length; i++)
 			{
-				var alert:Alert = alerts[i] as Alert;
+				var alert:Alert = alerts.getItemAt(i) as Alert;
 				if (stock.symbol == alert.symbol) {
-					alerts.splice(i,1);
+					alerts.removeItemAt(i);
 					break;
 				}
 			}
 			
 			for (i=0; i < _watchList.length; i++)
 			{
-				var s:Stock = _watchList[i] as Stock;
+				var s:Stock = _watchList.getItemAt(i) as Stock;
 				if (stock.symbol == s.symbol) {
-					_watchList.splice(i,1);
+					_watchList.removeItemAt(i);
 					break;
 				}
 			}
@@ -149,7 +153,7 @@ package models
 			var sym:String = responseData["Symbol"];
 			for (var i:int=0; i < _watchList.length; i++)
 			{
-				var stock:Stock = _watchList[i];
+				var stock:Stock = _watchList.getItemAt(i) as Stock;
 				if (stock.symbol == sym) {
 					stock.updateFromData(responseData);
 					break;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/views/AlertsView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/views/AlertsView.mxml b/examples/flexjs/MobileTrader/src/views/AlertsView.mxml
index 2c112df..96c9b86 100755
--- a/examples/flexjs/MobileTrader/src/views/AlertsView.mxml
+++ b/examples/flexjs/MobileTrader/src/views/AlertsView.mxml
@@ -48,6 +48,7 @@ limitations under the License.
 			private function onAlertSet():void
 			{
 				dispatchEvent(new org.apache.flex.events.Event("alertSet"));
+				dataGrid.model.dispatchEvent(new org.apache.flex.events.Event("dataProviderChanged"));
 			}
 		]]>
 	</fx:Script>
@@ -64,7 +65,7 @@ limitations under the License.
 		<js:TextButton text="Set" click="onAlertSet()" />
 	</js:Container>
 	
-	<js:DataGrid x="0" y="40" width="100%" height="200">
+	<js:DataGrid id="dataGrid" x="0" y="40" width="100%" height="200">
 		<js:beads>
 			<js:SimpleBinding
 				eventName="alertsUpdate"

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/views/AssetsView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/views/AssetsView.mxml b/examples/flexjs/MobileTrader/src/views/AssetsView.mxml
index 98e57e5..c71e257 100755
--- a/examples/flexjs/MobileTrader/src/views/AssetsView.mxml
+++ b/examples/flexjs/MobileTrader/src/views/AssetsView.mxml
@@ -43,7 +43,7 @@ limitations under the License.
 
 	<js:Label text="Summary" height="10%" />
 	
-	<js:DataGrid height="40%" width="100%">
+	<js:DataGrid height="150" width="100%">
 		<js:style>
 			<js:SimpleCSSStyles top="0" left="0" right="0" />
 		</js:style>
@@ -66,7 +66,7 @@ limitations under the License.
 		<js:beads>
 			<js:ConstantBinding
 				sourceID="model"
-				sourcePropertyName="assetsData"
+				sourcePropertyName="assetsDataAsArray"
 				destinationPropertyName="dataProvider" />
 			<js:VerticalCategoryAxisBead categoryField="label" />
 			<js:HorizontalLinearAxisBead valueField="netChange" />

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/848f245d/examples/flexjs/MobileTrader/src/views/WatchListView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/MobileTrader/src/views/WatchListView.mxml b/examples/flexjs/MobileTrader/src/views/WatchListView.mxml
index 8591aec..ec70e59 100755
--- a/examples/flexjs/MobileTrader/src/views/WatchListView.mxml
+++ b/examples/flexjs/MobileTrader/src/views/WatchListView.mxml
@@ -60,6 +60,7 @@ limitations under the License.
 			private function addSymbol():void
 			{
 				dispatchEvent(new org.apache.flex.events.Event("addSymbol"));
+				dataGrid.model.dispatchEvent(new org.apache.flex.events.Event("dataProviderChanged"));
 			}
 			
 			public var selectedStockIndex:Number;


Mime
View raw message