http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/MyInitialView.mxml b/examples/flexjs/MobileTrader/src/MyInitialView.mxml deleted file mode 100755 index 0c353ff..0000000 --- a/examples/flexjs/MobileTrader/src/MyInitialView.mxml +++ /dev/null @@ -1,256 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - -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. - ---> -<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:views="views.*" - xmlns:apache="org.apache.flex.html.beads.*" - xmlns:html="org.apache.flex.html.*" - xmlns:controller="controller.*" - initComplete="onInitComplete()" xmlns:models="models.*" > - - <fx:Style> - @namespace js "library://ns.apache.org/flexjs/basic"; - @namespace views "views.*"; - - js|Container { - background-color: #FFFFFF; - } - - js|StackedViewManager { - padding-top: 0px; - padding-bottom: 0px; - padding-left: 0px; - padding-right: 0px; - } - - js|TabbedViewManager { - position : absolute ; - height : 100% ; - width : 100% ; - left : 0px ; - top : 0px ; - border: solid 1px #444444; - background-color: #FFFFFF; - } - - .NavigationBar { - background-image: url("assets/background.png"); - height: 55px; - IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalLayout"); - } - - .TabBar { - background-color: #DEDEDE; - height: 55px; - vertical-align: middle; - line-height: 55px; - } - - .BackButton:hover { - background-image: url('assets/arrow_left_24.png'); - } - - .BackButton:active { - background-image: url('assets/arrow_left_24.png'); - } - - .BackButton { - background-image: url('assets/arrow_left_24.png'); - } - - .AssetsInner { - padding-top: 5px; - background-color: #FFFFFF; - } - - views|AssetsView { - width: 100%; - height: 100%; - } - - views|WatchListView { - width: 100%; - height: 100%; - IBeadController:ClassReference('controller.WatchListController'); - background-color: #FFFFFF; - } - - .WatchListInner { - height: 480px; - width: 100%; - background-color: #FFFFFF; - } - - .WatchListDataGrid { - height: 480px; - width: 100%; - } - - .WatchListInputArea { - background-color: #FFFFFF; - width: 480px; - height: 25px; - padding-top: 5px; - padding-bottom: 2px; - } - - views|StockView { - width: 100%; - height: 100%; - } - - views|AlertsView { - width: 100%; - height: 100%; - IBeadController:ClassReference('controller.AlertsViewController'); - } - - .redCell { - color: #FF0000; - } - - .greenCell { - color: #00FF00; - } - - .ViewTitle { - font-size: 18pt; - font-weight: bold; - padding: 10pt; - } - - .StockName { - font-size: 14pt; - font-weight: normal; - padding: 10pt; - } - - .StockDetailArea { - padding: 10pt; - } - - .StockLabel { - font-size: 18pt; - font-weight: normal; - color: #2255DD; - } - - .StockRemoveButton { - background-color: #FF5522; - font-size: 16pt; - font-weight: bold; - color: #FFFFFF; - width: 200px; - height: 50px; - } - - .StockRemoveButton:hover { - background-color: #DD3300; - } - - .StockValue { - font-size: 18pt; - font-weight: normal; - color: #999999; - } - - @media -flex-flash - { - .NavigationBar { - IBackgroundBead: ClassReference("org.apache.flex.html.beads.BackgroundImageBead"); - } - } - - </fx:Style> - - <fx:Script> - <![CDATA[ - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.events.Event; - import org.apache.flex.mobile.IViewManagerView; - import org.apache.flex.mobile.IViewManager; - import org.apache.flex.mobile.chrome.NavigationBar; - - private function onInitComplete():void - { - } - - private function onAssetsNext():void - { - - } - - private function tabbedViewChanged(event:org.apache.flex.events.Event):void - { - var manager:IViewManager = event.currentTarget as IViewManager; - trace("TabbedViewChanged for "+manager); - } - - private function watchListStackChanged(event:org.apache.flex.events.Event):void - { - trace("watchlist stack changed"); - var manager:StackedViewManager = event.currentTarget as StackedViewManager; - - var currentView:IViewManagerView = manager.selectedView; - backButton.visible = manager.views.length > 1; - } - - private function goBack(event:org.apache.flex.events.MouseEvent):void - { - if (navController.selectedIndex == 1) { - watchListStack.pop(); - } - } - ]]> - </fx:Script> - - <js:beads> - <js:ViewDataBinding /> - </js:beads> - - <js:TabbedViewManager id="navController" width="100%" height="100%" x="0" y="0" viewChanged="tabbedViewChanged(event)"> - <js:navigationBarItems> - <js:TextButton id="backButton" width="45" height="45" className="BackButton" visible="false" click="goBack(event)"> - <js:beads> - <apache:ImageButtonView /> - </js:beads> - </js:TextButton> - <js:Image source="assets/logo.png" width="218" height="55" /> - </js:navigationBarItems> - <js:views> - <js:StackedViewManager title="Assets"> - <js:views> - <views:AssetsView id="assetsView" title="Assets" next="onAssetsNext()" /> - </js:views> - </js:StackedViewManager> - - <js:StackedViewManager id="watchListStack" title="Watch List" viewChanged="watchListStackChanged(event)"> - <js:views> - <views:WatchListView id="watchListView" dataModel="{applicationModel}"/> - </js:views> - </js:StackedViewManager> - - <views:AlertsView id="alertsView" title="Alerts" dataModel="{applicationModel}" /> - </js:views> - </js:TabbedViewManager> - -</js:View>
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/StockDataJSONItemConverter.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/StockDataJSONItemConverter.as b/examples/flexjs/MobileTrader/src/StockDataJSONItemConverter.as deleted file mode 100755 index 5c21c26..0000000 --- a/examples/flexjs/MobileTrader/src/StockDataJSONItemConverter.as +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 -{ - import org.apache.flex.collections.converters.JSONItemConverter; - - public class StockDataJSONItemConverter extends JSONItemConverter - { - public function StockDataJSONItemConverter() - { - super(); - } - - override public function convertItem(data:String):Object - { - var obj:Object = super.convertItem(data); - if (obj["query"]["count"] == 0) - return "No Data"; - - obj = obj["query"]["results"]["quote"]; - return obj; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/assets/arrow_left_24.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/assets/arrow_left_24.png b/examples/flexjs/MobileTrader/src/assets/arrow_left_24.png deleted file mode 100755 index a3019ba..0000000 Binary files a/examples/flexjs/MobileTrader/src/assets/arrow_left_24.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/assets/background.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/assets/background.png b/examples/flexjs/MobileTrader/src/assets/background.png deleted file mode 100755 index 87bbd59..0000000 Binary files a/examples/flexjs/MobileTrader/src/assets/background.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/assets/logo.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/assets/logo.png b/examples/flexjs/MobileTrader/src/assets/logo.png deleted file mode 100755 index 0fb0f21..0000000 Binary files a/examples/flexjs/MobileTrader/src/assets/logo.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/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 deleted file mode 100644 index f8373ca..0000000 --- a/examples/flexjs/MobileTrader/src/controller/AlertsViewController.as +++ /dev/null @@ -1,141 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 controller -{ - import models.Alert; - import models.ProductsModel; - import models.Stock; - - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IStrand; - 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; - - public class AlertsViewController extends EventDispatcher implements IBeadController - { - public function AlertsViewController() - { - super(); - - timer = new Timer(updateInterval, 0); - timer.addEventListener("timer", timerHandler); - } - - public var updateInterval:Number = 5000; - - protected var timer:Timer; - - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - - var view:AlertsView = value as AlertsView; - view.addEventListener("alertSet", handleAlertSet); - } - - private var _model:IBeadModel; - public function set model(value:IBeadModel):void - { - _model = value; - } - public function get model():IBeadModel - { - return _model; - } - - private function handleAlertSet(event:Event):void - { - var view:AlertsView = _strand as AlertsView; - - var sym:String = view.symbolField.text.toUpperCase(); - var value:Number = Number(view.valueField.text); - - var alert:Alert = new Alert(); - alert.symbol = sym; - alert.value = value; - alert.greaterThan = view.higherCheck.selected; - - // add this stock to the watch list in case it isn't there already - alert.stock = (model as ProductsModel).addStock(sym); - - // set up the alert for the stock - (model as ProductsModel).addAlert(alert); - - view.symbolField.text = ""; - view.valueField.text = ""; - - subscribe(); - } - - public function subscribe():void - { - if (!timer.running) - { - timer.start(); - } - } - - public function unsubscribe():void - { - if (timer.running) - { - timer.stop(); - } - } - - /** - * When the timer goes off, verify all of the alerts against each stocks' last - * price. - */ - protected function timerHandler(event:*):void - { - 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.getItemAt(i) as Alert; - alert.message = ""; - - if (alert.greaterThan) { - if (alert.stock.last >= alert.value) { - alert.message = "Now @"+alert.stock.last; - } - } - else { - if (alert.stock.last <= alert.value) { - alert.message = "Now @"+alert.stock.last; - } - } - alerts.itemUpdatedAt(i); - } - - var newEvent:Event = new Event("alertsUpdate"); - model.dispatchEvent(newEvent); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/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 deleted file mode 100644 index 5da5b70..0000000 --- a/examples/flexjs/MobileTrader/src/controller/WatchListController.as +++ /dev/null @@ -1,138 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 controller -{ - import models.ProductsModel; - import models.Stock; - - import org.apache.flex.core.IBeadController; - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IStrand; - 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; - - public class WatchListController extends EventDispatcher implements IBeadController - { - public function WatchListController() - { - super(); - - timer = new Timer(updateInterval, 0); - timer.addEventListener("timer", timerHandler); - } - - public var updateInterval:Number = 5000; - - protected var timer:Timer; - - private var index:Number = 0; - private var selectedStock:Stock; - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - - var view:WatchListView = value as WatchListView; - view.addEventListener("addSymbol", handleAddSymbol); - view.addEventListener("stockSelected", handleGridSelection); - } - - private var _model:IBeadModel; - public function set model(value:IBeadModel):void - { - _model = value; - } - public function get model():IBeadModel - { - return _model; - } - - private function handleAddSymbol(event:Event):void - { - var view:WatchListView = _strand as WatchListView; - var symbol:String = view.symbolName.text.toUpperCase(); - - view.symbolName.text = ""; - - (model as ProductsModel).addStock(symbol); - - subscribe(); - } - - private function handleGridSelection(event:Event):void - { - var view:WatchListView = _strand as WatchListView; - selectedStock = (model as ProductsModel).watchList[view.selectedStockIndex] as Stock; - trace("Selected stock "+selectedStock.symbol); - - var stockView:StockView = view.showStockDetails(selectedStock); - stockView.addEventListener("removeFromList", handleRemoveFromList); - } - - public function handleRemoveFromList(event:Event):void - { - (model as ProductsModel).removeStock(selectedStock); - - var view:WatchListView = _strand as WatchListView; - view.popView(); - } - - public function subscribe():void - { - if (!timer.running) - { - timer.start(); - } - } - - public function unsubscribe():void - { - if (timer.running) - { - timer.stop(); - } - } - - /** - * Each time the handler goes off a different stock in the list - * is updated. This keeps the app from sending too many requests - * all at once. - */ - protected function timerHandler(event:*):void - { - var stockList:ArrayList = (model as ProductsModel).watchList; - - if (stockList.length == 0) return; - - if (index >= stockList.length) index = 0; - - (model as ProductsModel).updateStockData(stockList.getItemAt(index) as Stock); - index++; - - var newEvent:Event = new Event("update"); - model.dispatchEvent(newEvent); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/MobileTrader.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/MobileTrader.mxml b/examples/flexjs/MobileTrader/src/main/flex/MobileTrader.mxml new file mode 100755 index 0000000..c76531c --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/MobileTrader.mxml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--- +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +--> +<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:models="models.*" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:controller="controller.*" + > + + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + + <js:model> + <models:ProductsModel /> + </js:model> + + <js:initialView> + <local:MyInitialView width="100%" height="100%" /> + </js:initialView> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/MyInitialView.mxml b/examples/flexjs/MobileTrader/src/main/flex/MyInitialView.mxml new file mode 100755 index 0000000..0c353ff --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/MyInitialView.mxml @@ -0,0 +1,256 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:View xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:views="views.*" + xmlns:apache="org.apache.flex.html.beads.*" + xmlns:html="org.apache.flex.html.*" + xmlns:controller="controller.*" + initComplete="onInitComplete()" xmlns:models="models.*" > + + <fx:Style> + @namespace js "library://ns.apache.org/flexjs/basic"; + @namespace views "views.*"; + + js|Container { + background-color: #FFFFFF; + } + + js|StackedViewManager { + padding-top: 0px; + padding-bottom: 0px; + padding-left: 0px; + padding-right: 0px; + } + + js|TabbedViewManager { + position : absolute ; + height : 100% ; + width : 100% ; + left : 0px ; + top : 0px ; + border: solid 1px #444444; + background-color: #FFFFFF; + } + + .NavigationBar { + background-image: url("assets/background.png"); + height: 55px; + IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalLayout"); + } + + .TabBar { + background-color: #DEDEDE; + height: 55px; + vertical-align: middle; + line-height: 55px; + } + + .BackButton:hover { + background-image: url('assets/arrow_left_24.png'); + } + + .BackButton:active { + background-image: url('assets/arrow_left_24.png'); + } + + .BackButton { + background-image: url('assets/arrow_left_24.png'); + } + + .AssetsInner { + padding-top: 5px; + background-color: #FFFFFF; + } + + views|AssetsView { + width: 100%; + height: 100%; + } + + views|WatchListView { + width: 100%; + height: 100%; + IBeadController:ClassReference('controller.WatchListController'); + background-color: #FFFFFF; + } + + .WatchListInner { + height: 480px; + width: 100%; + background-color: #FFFFFF; + } + + .WatchListDataGrid { + height: 480px; + width: 100%; + } + + .WatchListInputArea { + background-color: #FFFFFF; + width: 480px; + height: 25px; + padding-top: 5px; + padding-bottom: 2px; + } + + views|StockView { + width: 100%; + height: 100%; + } + + views|AlertsView { + width: 100%; + height: 100%; + IBeadController:ClassReference('controller.AlertsViewController'); + } + + .redCell { + color: #FF0000; + } + + .greenCell { + color: #00FF00; + } + + .ViewTitle { + font-size: 18pt; + font-weight: bold; + padding: 10pt; + } + + .StockName { + font-size: 14pt; + font-weight: normal; + padding: 10pt; + } + + .StockDetailArea { + padding: 10pt; + } + + .StockLabel { + font-size: 18pt; + font-weight: normal; + color: #2255DD; + } + + .StockRemoveButton { + background-color: #FF5522; + font-size: 16pt; + font-weight: bold; + color: #FFFFFF; + width: 200px; + height: 50px; + } + + .StockRemoveButton:hover { + background-color: #DD3300; + } + + .StockValue { + font-size: 18pt; + font-weight: normal; + color: #999999; + } + + @media -flex-flash + { + .NavigationBar { + IBackgroundBead: ClassReference("org.apache.flex.html.beads.BackgroundImageBead"); + } + } + + </fx:Style> + + <fx:Script> + <![CDATA[ + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.events.Event; + import org.apache.flex.mobile.IViewManagerView; + import org.apache.flex.mobile.IViewManager; + import org.apache.flex.mobile.chrome.NavigationBar; + + private function onInitComplete():void + { + } + + private function onAssetsNext():void + { + + } + + private function tabbedViewChanged(event:org.apache.flex.events.Event):void + { + var manager:IViewManager = event.currentTarget as IViewManager; + trace("TabbedViewChanged for "+manager); + } + + private function watchListStackChanged(event:org.apache.flex.events.Event):void + { + trace("watchlist stack changed"); + var manager:StackedViewManager = event.currentTarget as StackedViewManager; + + var currentView:IViewManagerView = manager.selectedView; + backButton.visible = manager.views.length > 1; + } + + private function goBack(event:org.apache.flex.events.MouseEvent):void + { + if (navController.selectedIndex == 1) { + watchListStack.pop(); + } + } + ]]> + </fx:Script> + + <js:beads> + <js:ViewDataBinding /> + </js:beads> + + <js:TabbedViewManager id="navController" width="100%" height="100%" x="0" y="0" viewChanged="tabbedViewChanged(event)"> + <js:navigationBarItems> + <js:TextButton id="backButton" width="45" height="45" className="BackButton" visible="false" click="goBack(event)"> + <js:beads> + <apache:ImageButtonView /> + </js:beads> + </js:TextButton> + <js:Image source="assets/logo.png" width="218" height="55" /> + </js:navigationBarItems> + <js:views> + <js:StackedViewManager title="Assets"> + <js:views> + <views:AssetsView id="assetsView" title="Assets" next="onAssetsNext()" /> + </js:views> + </js:StackedViewManager> + + <js:StackedViewManager id="watchListStack" title="Watch List" viewChanged="watchListStackChanged(event)"> + <js:views> + <views:WatchListView id="watchListView" dataModel="{applicationModel}"/> + </js:views> + </js:StackedViewManager> + + <views:AlertsView id="alertsView" title="Alerts" dataModel="{applicationModel}" /> + </js:views> + </js:TabbedViewManager> + +</js:View> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/StockDataJSONItemConverter.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/StockDataJSONItemConverter.as b/examples/flexjs/MobileTrader/src/main/flex/StockDataJSONItemConverter.as new file mode 100755 index 0000000..5c21c26 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/StockDataJSONItemConverter.as @@ -0,0 +1,40 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.collections.converters.JSONItemConverter; + + public class StockDataJSONItemConverter extends JSONItemConverter + { + public function StockDataJSONItemConverter() + { + super(); + } + + override public function convertItem(data:String):Object + { + var obj:Object = super.convertItem(data); + if (obj["query"]["count"] == 0) + return "No Data"; + + obj = obj["query"]["results"]["quote"]; + return obj; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/assets/arrow_left_24.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/assets/arrow_left_24.png b/examples/flexjs/MobileTrader/src/main/flex/assets/arrow_left_24.png new file mode 100755 index 0000000..a3019ba Binary files /dev/null and b/examples/flexjs/MobileTrader/src/main/flex/assets/arrow_left_24.png differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/assets/background.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/assets/background.png b/examples/flexjs/MobileTrader/src/main/flex/assets/background.png new file mode 100755 index 0000000..87bbd59 Binary files /dev/null and b/examples/flexjs/MobileTrader/src/main/flex/assets/background.png differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/assets/logo.png ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/assets/logo.png b/examples/flexjs/MobileTrader/src/main/flex/assets/logo.png new file mode 100755 index 0000000..0fb0f21 Binary files /dev/null and b/examples/flexjs/MobileTrader/src/main/flex/assets/logo.png differ http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/controller/AlertsViewController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/controller/AlertsViewController.as b/examples/flexjs/MobileTrader/src/main/flex/controller/AlertsViewController.as new file mode 100644 index 0000000..f8373ca --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/controller/AlertsViewController.as @@ -0,0 +1,141 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 controller +{ + import models.Alert; + import models.ProductsModel; + import models.Stock; + + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IStrand; + 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; + + public class AlertsViewController extends EventDispatcher implements IBeadController + { + public function AlertsViewController() + { + super(); + + timer = new Timer(updateInterval, 0); + timer.addEventListener("timer", timerHandler); + } + + public var updateInterval:Number = 5000; + + protected var timer:Timer; + + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + + var view:AlertsView = value as AlertsView; + view.addEventListener("alertSet", handleAlertSet); + } + + private var _model:IBeadModel; + public function set model(value:IBeadModel):void + { + _model = value; + } + public function get model():IBeadModel + { + return _model; + } + + private function handleAlertSet(event:Event):void + { + var view:AlertsView = _strand as AlertsView; + + var sym:String = view.symbolField.text.toUpperCase(); + var value:Number = Number(view.valueField.text); + + var alert:Alert = new Alert(); + alert.symbol = sym; + alert.value = value; + alert.greaterThan = view.higherCheck.selected; + + // add this stock to the watch list in case it isn't there already + alert.stock = (model as ProductsModel).addStock(sym); + + // set up the alert for the stock + (model as ProductsModel).addAlert(alert); + + view.symbolField.text = ""; + view.valueField.text = ""; + + subscribe(); + } + + public function subscribe():void + { + if (!timer.running) + { + timer.start(); + } + } + + public function unsubscribe():void + { + if (timer.running) + { + timer.stop(); + } + } + + /** + * When the timer goes off, verify all of the alerts against each stocks' last + * price. + */ + protected function timerHandler(event:*):void + { + 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.getItemAt(i) as Alert; + alert.message = ""; + + if (alert.greaterThan) { + if (alert.stock.last >= alert.value) { + alert.message = "Now @"+alert.stock.last; + } + } + else { + if (alert.stock.last <= alert.value) { + alert.message = "Now @"+alert.stock.last; + } + } + alerts.itemUpdatedAt(i); + } + + var newEvent:Event = new Event("alertsUpdate"); + model.dispatchEvent(newEvent); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/controller/WatchListController.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/controller/WatchListController.as b/examples/flexjs/MobileTrader/src/main/flex/controller/WatchListController.as new file mode 100644 index 0000000..5da5b70 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/controller/WatchListController.as @@ -0,0 +1,138 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 controller +{ + import models.ProductsModel; + import models.Stock; + + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IStrand; + 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; + + public class WatchListController extends EventDispatcher implements IBeadController + { + public function WatchListController() + { + super(); + + timer = new Timer(updateInterval, 0); + timer.addEventListener("timer", timerHandler); + } + + public var updateInterval:Number = 5000; + + protected var timer:Timer; + + private var index:Number = 0; + private var selectedStock:Stock; + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + + var view:WatchListView = value as WatchListView; + view.addEventListener("addSymbol", handleAddSymbol); + view.addEventListener("stockSelected", handleGridSelection); + } + + private var _model:IBeadModel; + public function set model(value:IBeadModel):void + { + _model = value; + } + public function get model():IBeadModel + { + return _model; + } + + private function handleAddSymbol(event:Event):void + { + var view:WatchListView = _strand as WatchListView; + var symbol:String = view.symbolName.text.toUpperCase(); + + view.symbolName.text = ""; + + (model as ProductsModel).addStock(symbol); + + subscribe(); + } + + private function handleGridSelection(event:Event):void + { + var view:WatchListView = _strand as WatchListView; + selectedStock = (model as ProductsModel).watchList[view.selectedStockIndex] as Stock; + trace("Selected stock "+selectedStock.symbol); + + var stockView:StockView = view.showStockDetails(selectedStock); + stockView.addEventListener("removeFromList", handleRemoveFromList); + } + + public function handleRemoveFromList(event:Event):void + { + (model as ProductsModel).removeStock(selectedStock); + + var view:WatchListView = _strand as WatchListView; + view.popView(); + } + + public function subscribe():void + { + if (!timer.running) + { + timer.start(); + } + } + + public function unsubscribe():void + { + if (timer.running) + { + timer.stop(); + } + } + + /** + * Each time the handler goes off a different stock in the list + * is updated. This keeps the app from sending too many requests + * all at once. + */ + protected function timerHandler(event:*):void + { + var stockList:ArrayList = (model as ProductsModel).watchList; + + if (stockList.length == 0) return; + + if (index >= stockList.length) index = 0; + + (model as ProductsModel).updateStockData(stockList.getItemAt(index) as Stock); + index++; + + var newEvent:Event = new Event("update"); + model.dispatchEvent(newEvent); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/models/Alert.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/models/Alert.as b/examples/flexjs/MobileTrader/src/main/flex/models/Alert.as new file mode 100644 index 0000000..7b9dc8b --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/models/Alert.as @@ -0,0 +1,94 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 models +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + + public class Alert extends EventDispatcher + { + public function Alert() + { + super(); + message = ""; + } + + private var _symbol:String; + private var _value:Number; + private var _greaterThan:Boolean; + private var _message:String; + private var _stock:Stock; + + [Binding("symbolChanged")] + public function get symbol():String + { + return _symbol; + } + public function set symbol(value:String):void + { + _symbol = value; + dispatchEvent(new Event("symbolChanged")); + } + + [Binding("messageChanged")] + public function get message():String + { + return _message; + } + public function set message(value:String):void + { + _message = value; + dispatchEvent(new Event("messageChanged")); + } + + [Binding("valueChanged")] + public function get value():Number + { + return _value; + } + public function set value(newValue:Number):void + { + _value = newValue; + dispatchEvent(new Event("valueChanged")); + } + + [Binding("greaterThanChanged")] + public function get greaterThan():Boolean + { + return _greaterThan; + } + public function set greaterThan(value:Boolean):void + { + _greaterThan = value; + dispatchEvent(new Event("greaterThanChanged")); + } + + [Binding("stockChanged")] + public function get stock():Stock + { + return _stock; + } + public function set stock(value:Stock):void + { + _stock = value; + dispatchEvent(new Event("stockChanged")); + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/models/Asset.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/models/Asset.as b/examples/flexjs/MobileTrader/src/main/flex/models/Asset.as new file mode 100644 index 0000000..050e2bf --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/models/Asset.as @@ -0,0 +1,77 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 models +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + + public class Asset extends EventDispatcher + { + private var _label:String; + private var _value:Number; + private var _netChange:Number; + + public function Asset(newLabel:String, newValue:Number, newNetChange:Number) + { + _label = newLabel; + _value = newValue; + _netChange = newNetChange; + } + + [Bindable("labelChanged")] + public function get label():String + { + return _label; + } + public function set label(value:String):void + { + if (value != _label) { + _label = value; + dispatchEvent(new Event("labelChanged")); + } + } + + [Bindable("valueChanged")] + public function get value():Number + { + return _value; + } + public function set value(newValue:Number):void + { + if (_value != newValue) { + _value = newValue; + dispatchEvent(new Event("valueChanged")); + } + } + + [Bindable("netChangeChanged")] + public function get netChange():Number + { + return _netChange; + } + public function set netChange(value:Number):void + { + if (_netChange != value) { + _netChange = value; + dispatchEvent(new Event("netChangeChanged")); + } + } + } + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/models/AssetsModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/models/AssetsModel.as b/examples/flexjs/MobileTrader/src/main/flex/models/AssetsModel.as new file mode 100755 index 0000000..3d72137 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/models/AssetsModel.as @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 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 source:Array = [ + new Asset("NetWorth:", 161984, 2.36), + new Asset("Last Month:", 165915, 10.98), + new Asset("6 Months Ago:", 145962, 16.56), + new Asset("Last Year:", 138972, 8.36) + ]; + 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/e75059f7/examples/flexjs/MobileTrader/src/main/flex/models/ProductsModel.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/models/ProductsModel.as b/examples/flexjs/MobileTrader/src/main/flex/models/ProductsModel.as new file mode 100755 index 0000000..f4b2008 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/models/ProductsModel.as @@ -0,0 +1,165 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 models +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + 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 + { + public function ProductsModel() + { + super(); + + service = new HTTPService(); + collection = new LazyCollection; + collection.inputParser = new JSONInputParser(); + collection.itemConverter = new StockDataJSONItemConverter(); + + _watchList = new ArrayList(); + _alerts = new ArrayList(); + } + + private var service:HTTPService; + private var collection:LazyCollection; + private var queryBegin:String = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22"; + private var queryEnd:String = "%22)%0A%09%09&env=http%3A%2F%2Fdatatables.org%2Falltables.env&format=json"; + + private var _strand:IStrand; + public function set strand(value:IStrand):void + { + _strand = value; + + service.addBead(collection); + _strand.addBead(service); + } + + private var _tabList:Array = ["Assets", "Watch", "Alerts"]; + public function get tabList():Array + { + return _tabList; + } + + private var _labelFields:Array = [ "id", "title", "detail" ]; + public function get labelFields():Array + { + return _labelFields; + } + + private var _watchList:ArrayList; + + public function get watchList():ArrayList + { + return _watchList; + } + + private var _alerts:ArrayList; + + public function get alerts():ArrayList + { + return _alerts; + } + + public function addAlert(value:Alert):void + { + for (var i:int =0; i < _alerts.length; i++) + { + var alert:Alert = _alerts.getItemAt(i) as Alert; + if (alert.symbol == value.symbol) { + _alerts.setItemAt(value, i); + return; + } + } + + _alerts.addItem(value); + dispatchEvent(new Event("alertsUpdate")); + } + + public function addStock(symbol:String):Stock + { + for (var i:int=0; i < _watchList.length; i++) + { + var stock:Stock = _watchList.getItemAt(i) as Stock; + if (stock.symbol == symbol) return stock; + } + + stock = new Stock(symbol); + + _watchList.addItem(stock); + // dispatchEvent(new Event("update")); + + updateStockData(stock); + return stock; + } + + public function updateStockData(value:Stock):void + { + var sym:String = value.symbol; + service.url = queryBegin + sym + queryEnd; + service.send(); + service.addEventListener("complete", completeHandler); + } + + public function removeStock(stock:Stock):void + { + for (var i:int=0; i < alerts.length; i++) + { + var alert:Alert = alerts.getItemAt(i) as Alert; + if (stock.symbol == alert.symbol) { + alerts.removeItemAt(i); + break; + } + } + + for (i=0; i < _watchList.length; i++) + { + var s:Stock = _watchList.getItemAt(i) as Stock; + if (stock.symbol == s.symbol) { + _watchList.removeItemAt(i); + break; + } + } + + dispatchEvent(new Event("alertsUpdate")); + dispatchEvent(new Event("update")); + } + + private function completeHandler(event:Event):void + { + var responseData:Object = collection.getItemAt(0); + + var sym:String = responseData["Symbol"]; + for (var i:int=0; i < _watchList.length; i++) + { + var stock:Stock = _watchList.getItemAt(i) as Stock; + if (stock.symbol == sym) { + stock.updateFromData(responseData); + _watchList.itemUpdatedAt(i); + break; + } + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/models/Stock.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/models/Stock.as b/examples/flexjs/MobileTrader/src/main/flex/models/Stock.as new file mode 100755 index 0000000..c06790d --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/models/Stock.as @@ -0,0 +1,148 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 models +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + + public class Stock extends EventDispatcher + { + public var history:Array; + + public function Stock(symbol:String=null, last:Number=0) + { + this.symbol = symbol; + this.last = last; + this.low = last; + this.high = last; + this.open = last; + this.change = 0; + this.name = ""; + } + + public function updateFromData(obj:Object):void + { + name = obj["Name"]; + low = obj["DaysLow"]; + high = obj["DaysHigh"]; + open = obj["Open"]; + change = obj["Change"]; + symbol = obj["Symbol"]; + last = obj["LastTradePriceOnly"]; + } + + private var _symbol:String; + private var _name:String; + private var _low:Number; + private var _high:Number; + private var _open:Number; + private var _last:Number; + private var _change:Number; + private var _date:Date; + + [Bindable("symbolChanged")] + public function get symbol():String + { + return _symbol; + } + public function set symbol(value:String):void + { + _symbol = value; + dispatchEvent(new Event("symbolChanged")); + } + + [Bindable("nameChanged")] + public function get name():String + { + return _name; + } + public function set name(value:String):void + { + _name = value; + dispatchEvent(new Event("nameChanged")); + } + + [Bindable("lowChanged")] + public function get low():Number + { + return _low; + } + public function set low(value:Number):void + { + _low = value; + dispatchEvent(new Event("lowChanged")); + } + + [Bindable("highChanged")] + public function get high():Number + { + return _high; + } + public function set high(value:Number):void + { + _high = value; + dispatchEvent(new Event("highChanged")); + } + + [Bindable("openChanged")] + public function get open():Number + { + return _open; + } + public function set open(value:Number):void + { + _open = value; + dispatchEvent(new Event("openChanged")); + } + + [Bindable("lastChanged")] + public function get last():Number + { + return _last; + } + public function set last(value:Number):void + { + _last = value; + dispatchEvent(new Event("lastChanged")); + } + + [Bindable("changeChanged")] + public function get change():Number + { + return _change; + } + public function set change(value:Number):void + { + _change = value; + dispatchEvent(new Event("changeChanged")); + } + + [Bindable("dateChanged")] + public function get date():Date + { + return _date; + } + public function set date(value:Date):void + { + _date = value; + dispatchEvent(new Event("dateChanged")); + } + } + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/renderers/AlertRenderer.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/renderers/AlertRenderer.as b/examples/flexjs/MobileTrader/src/main/flex/renderers/AlertRenderer.as new file mode 100644 index 0000000..e683020 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/renderers/AlertRenderer.as @@ -0,0 +1,44 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 renderers +{ + import org.apache.flex.html.supportClasses.StringItemRenderer; + + public class AlertRenderer extends StringItemRenderer + { + public function AlertRenderer() + { + super(); + } + + override public function set data(value:Object):void + { + super.data = value; + + if (labelField == "greaterThan") { + if (Boolean(value[labelField])) { + text = "when over "+value["value"]; + } + else { + text = "when under "+value["value"]; + } + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/renderers/StockRenderer.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/renderers/StockRenderer.as b/examples/flexjs/MobileTrader/src/main/flex/renderers/StockRenderer.as new file mode 100755 index 0000000..afba26f --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/renderers/StockRenderer.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 renderers +{ + import org.apache.flex.html.supportClasses.StringItemRenderer; + + public class StockRenderer extends StringItemRenderer + { + public function StockRenderer() + { + super(); + } + + override public function set data(value:Object):void + { + super.data = value; + + var n1:Number = Number(value[labelField]); + if (!isNaN(n1)) { + n1 = Math.round(n1*100)/100.0; + + // something to keep in mind when using FlexJS for cross-platform + // use: make sure that public properties are used versus protected + // functions or properties. in most cases, internal vars and functions + // will be platform-specific whereas public properties and function + // should be cross-platform. + text = String(n1); + } + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/views/AlertsView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/views/AlertsView.mxml b/examples/flexjs/MobileTrader/src/main/flex/views/AlertsView.mxml new file mode 100755 index 0000000..f06dd65 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/views/AlertsView.mxml @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:TitleView xmlns:fx="http://ns.adobe.com/mxml/2009" + title="Alerts" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:local="*" + className="AlertsView" xmlns:renderers="renderers.*"> + + <fx:Metadata> + [Event("next")] + </fx:Metadata> + + <fx:Script> + <![CDATA[ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadController; + import org.apache.flex.events.Event; + import controller.AlertsViewController; + + public function set dataModel(value:IBeadModel):void + { + var cm:IBeadController = controller; + (cm as AlertsViewController).model = value; + } + public function get dataModel():IBeadModel + { + var cm:IBeadController = controller; + return (cm as AlertsViewController).model; + } + + private function onAlertSet():void + { + dispatchEvent(new org.apache.flex.events.Event("alertSet")); + } + ]]> + </fx:Script> + + <js:Container x="4" y="10" > + <js:beads> + <js:HorizontalLayout /> + </js:beads> + <js:Label text="Symbol:" /> + <js:TextInput id="symbolField" width="50" /> + <js:Label text="Value:" /> + <js:TextInput id="valueField" width="50" /> + <js:CheckBox text="Higher?" id="higherCheck" /> + <js:TextButton text="Set" click="onAlertSet()" /> + </js:Container> + + <js:DataGrid id="dataGrid" x="0" y="40" width="100%" height="200"> + <js:beads> + <js:DataProviderChangeNotifier sourceID="dataModel" propertyName="alerts" /> + <js:SimpleBinding + eventName="alertsUpdate" + sourceID="dataModel" + sourcePropertyName="alerts" + destinationPropertyName="dataProvider" /> + </js:beads> + <js:columns> + <js:DataGridColumn label="Symbol" dataField="symbol"> + <js:itemRenderer> + <fx:Component> + <js:StringItemRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Alert" dataField="greaterThan"> + <js:itemRenderer> + <fx:Component> + <renderers:AlertRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Message" dataField="message"> + <js:itemRenderer> + <fx:Component> + <js:StringItemRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + </js:columns> + </js:DataGrid> + +</js:TitleView> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/views/AssetsView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/views/AssetsView.mxml b/examples/flexjs/MobileTrader/src/main/flex/views/AssetsView.mxml new file mode 100755 index 0000000..2929a3e --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/views/AssetsView.mxml @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:TitleView xmlns:fx="http://ns.adobe.com/mxml/2009" + title="Assets" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:models="models.*" + xmlns:local="*" + className="AssetsView"> + <fx:Script> + <![CDATA[ + + ]]> + </fx:Script> + + <fx:Metadata> + [Event("next")] + </fx:Metadata> + + <js:beads> + <js:VerticalLayout /> + </js:beads> + + <js:model> + <models:AssetsModel /> + </js:model> + + <js:Label text="Summary" height="10%" /> + + <js:DataGrid height="150" width="100%"> + <js:style> + <js:SimpleCSSStyles top="0" left="0" right="0" /> + </js:style> + <js:beads> + <js:ConstantBinding + sourceID="model" + sourcePropertyName="assetsData" + destinationPropertyName="dataProvider" /> + </js:beads> + <js:columns> + <js:DataGridColumn label="Type" dataField="label" /> + <js:DataGridColumn label="Value" dataField="value" /> + <js:DataGridColumn label="Change" dataField="netChange" /> + </js:columns> + </js:DataGrid> + + <js:Label text="Performance History" height="10%" /> + + <js:BarChart id="barChart" width="100%" height="40%"> + <js:beads> + <js:ConstantBinding + sourceID="model" + sourcePropertyName="assetsDataAsArray" + destinationPropertyName="dataProvider" /> + <js:VerticalCategoryAxisBead categoryField="label" /> + <js:HorizontalLinearAxisBead valueField="netChange" /> + </js:beads> + <js:series> + <js:BarSeries xField="netChange"> + <js:itemRenderer> + <fx:Component> + <js:BoxItemRenderer> + <js:fill> + <js:SolidColor color="#FF964D" alpha="1.0" /> + </js:fill> + </js:BoxItemRenderer> + </fx:Component> + </js:itemRenderer> + </js:BarSeries> + </js:series> + </js:BarChart> + +</js:TitleView> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/views/SearchView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/views/SearchView.mxml b/examples/flexjs/MobileTrader/src/main/flex/views/SearchView.mxml new file mode 100755 index 0000000..0348fba --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/views/SearchView.mxml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:TitleView xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:apache="org.apache.flex.html.beads.*" + xmlns:local="*" + className="StockView"> + + <fx:Script> + <![CDATA[ + import org.apache.flex.mobile.StackedViewManager; + private function onBackClick() : void + { + (viewManager as StackedViewManager).pop(); + } + ]]> + </fx:Script> + + <js:Label text="Search View" x="20" y="100" /> +</js:TitleView> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/views/StockView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/views/StockView.mxml b/examples/flexjs/MobileTrader/src/main/flex/views/StockView.mxml new file mode 100755 index 0000000..95b8992 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/views/StockView.mxml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:TitleView xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:apache="org.apache.flex.html.beads.*" + xmlns:local="*" + className="StockView"> + + <fx:Script> + <![CDATA[ + import models.Stock; + + import org.apache.flex.events.Event; + import org.apache.flex.mobile.StackedViewManager; + + private var _stock:Stock; + + [Bindable("stockChanged")] + public function get stock():Stock + { + return _stock; + } + public function set stock(value:Stock):void + { + _stock = value; + dispatchEvent(new org.apache.flex.events.Event("stockChanged")); + } + + private function onBackClick() : void + { + (viewManager as StackedViewManager).pop(); + } + + override public function addedToParent():void + { + super.addedToParent(); + + stockSymbol.text = stock.symbol; + stockName.text = stock.name; + lastPrice.text = String(stock.last); + openPrice.text = String(stock.open); + lowPrice.text = String(stock.low); + highPrice.text = String(stock.high); + changeAmount.text = String(stock.change); + } + + private function removeFromList():void + { + dispatchEvent(new org.apache.flex.events.Event("removeFromList")); + } + ]]> + </fx:Script> + + <js:Container> + <js:beads> + <js:VerticalLayout /> + </js:beads> + <js:style> + <js:SimpleCSSStyles top="10px" left="10px" /> + </js:style> + + <js:Label id="stockSymbol" text="{stock.symbol}" className="ViewTitle" /> + <js:Label id="stockName" text="{stock.name}" className="StockName" /> + + <js:Container className="StockDetailArea"> + <js:beads> + <js:VerticalColumnLayout numColumns="2" /> + </js:beads> + + <js:Label text="Last Price:" className="StockLabel" /> <js:Label id="lastPrice" className="StockValue" /> + <js:Label text="Open Price:" className="StockLabel" /> <js:Label id="openPrice" className="StockValue" /> + <js:Label text="Low Price:" className="StockLabel" /> <js:Label id="lowPrice" className="StockValue" /> + <js:Label text="High Price:" className="StockLabel" /> <js:Label id="highPrice" className="StockValue" /> + <js:Label text="Change: " className="StockLabel" /> <js:Label id="changeAmount" className="StockValue" /> + </js:Container> + + <js:Container className="StockDetailArea"> + <js:TextButton text="Remove From List" width="200" className="StockRemoveButton" click="removeFromList()" /> + </js:Container> + </js:Container> +</js:TitleView> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/flex/views/WatchListView.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/flex/views/WatchListView.mxml b/examples/flexjs/MobileTrader/src/main/flex/views/WatchListView.mxml new file mode 100755 index 0000000..aa9da04 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/flex/views/WatchListView.mxml @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:TitleView xmlns:fx="http://ns.adobe.com/mxml/2009" + title="Watch List" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:controller="controller.*" + xmlns:local="*" + className="WatchListView" + xmlns:renderers="renderers.*"> + + <fx:Script> + <![CDATA[ + import controller.WatchListController; + + import models.ProductsModel; + import models.Stock; + + import org.apache.flex.binding.SimpleBinding; + import org.apache.flex.core.IBeadController; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.events.Event; + import org.apache.flex.mobile.IViewManager; + import org.apache.flex.mobile.StackedViewManager; + + public function set dataModel(value:IBeadModel):void + { + var cm:IBeadController = controller; + (cm as WatchListController).model = value; + } + public function get dataModel():IBeadModel + { + var cm:IBeadController = controller; + return (cm as WatchListController).model; + } + + private function onSelectStock():void + { + var stockView:StockView = new StockView(); + var svm:IViewManager = viewManager; + (viewManager as StackedViewManager).push(stockView); + } + + private function addSymbol():void + { + dispatchEvent(new org.apache.flex.events.Event("addSymbol")); + } + + public var selectedStockIndex:Number; + + private function selectRow():void + { + selectedStockIndex = dataGrid.selectedIndex; + dispatchEvent(new org.apache.flex.events.Event("stockSelected")); + } + + public function showStockDetails(stock:Stock):StockView + { + var stockView:StockView = new StockView(); + stockView.stock = stock; + (viewManager as StackedViewManager).push(stockView); + + var cm:IBeadController = controller; + + return stockView; + } + + public function popView():void + { + (viewManager as StackedViewManager).pop(); + } + ]]> + </fx:Script> + + <js:beads> + <js:VerticalLayout /> + </js:beads> + + <js:HContainer className="WatchListInputArea" width="100%" height="10%"> + <js:Label text="Symbol:" /> + <js:TextInput id="symbolName" /> + <js:TextButton text="Add" click="addSymbol()" /> + </js:HContainer> + + <js:Spacer height="10" /> + + <js:DataGrid id="dataGrid" width="100%" height="85%" change="selectRow()" className="WatchListDataGrid"> + <js:beads> + <js:DataProviderChangeNotifier sourceID="dataModel" propertyName="watchList" /> + <js:SimpleBinding + eventName="update" + sourceID="dataModel" + sourcePropertyName="watchList" + destinationPropertyName="dataProvider" /> + </js:beads> + <js:columns> + <js:DataGridColumn label="Symbol" dataField="symbol"> + <js:itemRenderer> + <fx:Component> + <js:StringItemRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Open" dataField="open"> + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Last" dataField="last" > + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="High" dataField="high" > + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + <js:DataGridColumn label="Low" dataField="low" > + <js:itemRenderer> + <fx:Component> + <renderers:StockRenderer /> + </fx:Component> + </js:itemRenderer> + </js:DataGridColumn> + </js:columns> + </js:DataGrid> + +</js:TitleView> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/main/resources/config.xml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/main/resources/config.xml b/examples/flexjs/MobileTrader/src/main/resources/config.xml new file mode 100644 index 0000000..00b9f64 --- /dev/null +++ b/examples/flexjs/MobileTrader/src/main/resources/config.xml @@ -0,0 +1,44 @@ +<?xml version='1.0' encoding='utf-8'?> +<!-- + + 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. + +--> +<widget id="${groupId}.${artifactId}" version="${version}" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> + <name>${artifactId}</name> + <description> + ${description} + </description> + <author email="d...@flex.apache.org" href="http://flex.apache.org"> + Apache Flex Team + </author> + <content src="index.html" /> + <plugin name="cordova-plugin-whitelist" version="1" /> + <access origin="*" /> + <allow-intent href="http://*/*" /> + <allow-intent href="https://*/*" /> + <allow-intent href="tel:*" /> + <allow-intent href="sms:*" /> + <allow-intent href="mailto:*" /> + <allow-intent href="geo:*" /> + <platform name="android"> + <allow-intent href="market:*" /> + </platform> + <platform name="ios"> + <allow-intent href="itms:*" /> + <allow-intent href="itms-apps:*" /> + </platform> +</widget> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/models/Alert.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/models/Alert.as b/examples/flexjs/MobileTrader/src/models/Alert.as deleted file mode 100644 index 7b9dc8b..0000000 --- a/examples/flexjs/MobileTrader/src/models/Alert.as +++ /dev/null @@ -1,94 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 models -{ - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class Alert extends EventDispatcher - { - public function Alert() - { - super(); - message = ""; - } - - private var _symbol:String; - private var _value:Number; - private var _greaterThan:Boolean; - private var _message:String; - private var _stock:Stock; - - [Binding("symbolChanged")] - public function get symbol():String - { - return _symbol; - } - public function set symbol(value:String):void - { - _symbol = value; - dispatchEvent(new Event("symbolChanged")); - } - - [Binding("messageChanged")] - public function get message():String - { - return _message; - } - public function set message(value:String):void - { - _message = value; - dispatchEvent(new Event("messageChanged")); - } - - [Binding("valueChanged")] - public function get value():Number - { - return _value; - } - public function set value(newValue:Number):void - { - _value = newValue; - dispatchEvent(new Event("valueChanged")); - } - - [Binding("greaterThanChanged")] - public function get greaterThan():Boolean - { - return _greaterThan; - } - public function set greaterThan(value:Boolean):void - { - _greaterThan = value; - dispatchEvent(new Event("greaterThanChanged")); - } - - [Binding("stockChanged")] - public function get stock():Stock - { - return _stock; - } - public function set stock(value:Stock):void - { - _stock = value; - dispatchEvent(new Event("stockChanged")); - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e75059f7/examples/flexjs/MobileTrader/src/models/Asset.as ---------------------------------------------------------------------- diff --git a/examples/flexjs/MobileTrader/src/models/Asset.as b/examples/flexjs/MobileTrader/src/models/Asset.as deleted file mode 100644 index 869ba72..0000000 --- a/examples/flexjs/MobileTrader/src/models/Asset.as +++ /dev/null @@ -1,77 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 models -{ - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class Asset extends EventDispatcher - { - private var _label:String; - private var _value:Number; - private var _netChange:Number; - - public function Asset(newLabel:String, newValue:Number, newNetChange:Number) - { - _label = newLabel; - _value = newValue; - _netChange = newNetChange; - } - - [Bindable("labelChanged")] - public function get label():String - { - return _label; - } - public function set label(value:String):void - { - if (value != _label) { - _label = value; - dispatchEvent(new Event("labelChanged")); - } - } - - [Bindable("valueChanged")] - public function get value():Number - { - return _value; - } - public function set value(newValue:Number):void - { - if (_value != newValue) { - _value = newValue; - dispatchEvent(new Event("valueChanged")); - } - } - - [Bindable("netChangeChanged")] - public function get netChange():Number - { - return _netChange; - } - public function set netChange(value:Number):void - { - if (_netChange != value) { - _netChange = value; - dispatchEvent(new Event("netChangeChanged")); - } - } - } - -}