rename DataBindingTest to DataBindingExample and fix up references
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4b6f8a80 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4b6f8a80 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4b6f8a80 Branch: refs/heads/develop Commit: 4b6f8a803358cb5bfdfacc8b21b70ac5a93fdec7 Parents: 9c7e00b Author: Alex Harui <[email protected]> Authored: Fri Aug 21 10:27:46 2015 -0700 Committer: Alex Harui <[email protected]> Committed: Fri Aug 21 10:27:46 2015 -0700 ---------------------------------------------------------------------- examples/DataBindingExample/build.xml | 4 +- .../src/DataBindingExample.mxml | 53 ++++ .../DataBindingExample/src/DataBindingTest.mxml | 53 ---- examples/DataBindingExample/src/README.txt | 7 +- .../src/controllers/MyController.as | 6 +- examples/DataBindingExample_Flat/build.xml | 4 +- .../src/DataBindingExample.mxml | 53 ++++ .../src/DataBindingTest.mxml | 53 ---- .../src/controllers/MyController.as | 6 +- examples/DataBindingExample_as/build.xml | 4 +- .../src/DataBindingExample.as | 257 +++++++++++++++++++ .../src/DataBindingTest.as | 257 ------------------- .../src/controllers/MyController.as | 6 +- 13 files changed, 382 insertions(+), 381 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample/build.xml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample/build.xml b/examples/DataBindingExample/build.xml index 9c551dd..0cfef1b 100644 --- a/examples/DataBindingExample/build.xml +++ b/examples/DataBindingExample/build.xml @@ -19,9 +19,9 @@ --> -<project name="databindingtest" default="main" basedir="."> +<project name="databindingexample" default="main" basedir="."> <property name="FLEXJS_HOME" location="../.."/> - <property name="example" value="DataBindingTest" /> + <property name="example" value="DataBindingExample" /> <property file="${FLEXJS_HOME}/env.properties"/> <property environment="env"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample/src/DataBindingExample.mxml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample/src/DataBindingExample.mxml b/examples/DataBindingExample/src/DataBindingExample.mxml new file mode 100644 index 0000000..751e427 --- /dev/null +++ b/examples/DataBindingExample/src/DataBindingExample.mxml @@ -0,0 +1,53 @@ +<?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:js="library://ns.apache.org/flexjs/basic" + xmlns:models="models.*" + xmlns:controllers="controllers.*" + initialize="MyModel(model).stockSymbol='ADBE'" + > + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + <js:initialView> + <local:MyInitialView /> + </js:initialView> + <js:model> + <models:MyModel /> + </js:model> + <js:controller> + <controllers:MyController /> + </js:controller> + <js:beads> + <js:HTTPService id="service"> + <js:LazyCollection id="collection"> + <js:inputParser> + <js:JSONInputParser /> + </js:inputParser> + <js:itemConverter> + <local:StockDataJSONItemConverter /> + </js:itemConverter> + </js:LazyCollection> + </js:HTTPService> + <js:CSSFontFaceBead /> + <js:ViewSourceContextMenuOption /> + </js:beads> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample/src/DataBindingTest.mxml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample/src/DataBindingTest.mxml b/examples/DataBindingExample/src/DataBindingTest.mxml deleted file mode 100644 index 751e427..0000000 --- a/examples/DataBindingExample/src/DataBindingTest.mxml +++ /dev/null @@ -1,53 +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:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:models="models.*" - xmlns:controllers="controllers.*" - initialize="MyModel(model).stockSymbol='ADBE'" - > - <js:valuesImpl> - <js:SimpleCSSValuesImpl /> - </js:valuesImpl> - <js:initialView> - <local:MyInitialView /> - </js:initialView> - <js:model> - <models:MyModel /> - </js:model> - <js:controller> - <controllers:MyController /> - </js:controller> - <js:beads> - <js:HTTPService id="service"> - <js:LazyCollection id="collection"> - <js:inputParser> - <js:JSONInputParser /> - </js:inputParser> - <js:itemConverter> - <local:StockDataJSONItemConverter /> - </js:itemConverter> - </js:LazyCollection> - </js:HTTPService> - <js:CSSFontFaceBead /> - <js:ViewSourceContextMenuOption /> - </js:beads> -</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample/src/README.txt ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample/src/README.txt b/examples/DataBindingExample/src/README.txt index afe521b..91a0359 100644 --- a/examples/DataBindingExample/src/README.txt +++ b/examples/DataBindingExample/src/README.txt @@ -19,14 +19,15 @@ DESCRIPTION -The DataBindingTest example shows a Flex application that can communicate with +The DataBindingExample shows a Flex application that can communicate with a third-party data source (in this case, yahoo.finance) and display the values -returned using data binding. +returned using data binding. It also demonstrates that you can use âstatesâ to +control the UI. This Flex application may be run as a Flash SWF or cross-compiled (using Falcon JX) into JavaScript and HTML and run without Flash. -The DataBindingTest example also shows how the model-view-controller (MVC) pattern +The DataBindingExample also shows how the model-view-controller (MVC) pattern can be used to separate the parts of the application. This is facilitated by the use of FlexJS beads added to the main application that provide the data connection (via HTTPService) and interacting with the rest of the application http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample/src/controllers/MyController.as ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample/src/controllers/MyController.as b/examples/DataBindingExample/src/controllers/MyController.as index 83c2cd5..2ee16ae 100644 --- a/examples/DataBindingExample/src/controllers/MyController.as +++ b/examples/DataBindingExample/src/controllers/MyController.as @@ -31,14 +31,14 @@ package controllers { if (app) { - this.app = app as DataBindingTest; + this.app = app as DataBindingExample; app.addEventListener("viewChanged", viewChangeHandler); } } 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 app:DataBindingTest; + private var app:DataBindingExample; private function viewChangeHandler(event:Event):void { @@ -73,7 +73,7 @@ package controllers public function setDocument(document:Object, id:String = null):void { - this.app = document as DataBindingTest; + this.app = document as DataBindingExample; app.addEventListener("viewChanged", viewChangeHandler); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_Flat/build.xml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_Flat/build.xml b/examples/DataBindingExample_Flat/build.xml index ab55f2f..5ede59c 100644 --- a/examples/DataBindingExample_Flat/build.xml +++ b/examples/DataBindingExample_Flat/build.xml @@ -19,9 +19,9 @@ --> -<project name="databindingtest_flat" default="main" basedir="."> +<project name="databindingexample_flat" default="main" basedir="."> <property name="FLEXJS_HOME" location="../.."/> - <property name="example" value="DataBindingTest" /> + <property name="example" value="DataBindingExample" /> <property name="theme_arg" value="-theme=${FLEXJS_HOME}/frameworks/libs/Flat.swc" /> <property file="${FLEXJS_HOME}/env.properties"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_Flat/src/DataBindingExample.mxml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_Flat/src/DataBindingExample.mxml b/examples/DataBindingExample_Flat/src/DataBindingExample.mxml new file mode 100644 index 0000000..751e427 --- /dev/null +++ b/examples/DataBindingExample_Flat/src/DataBindingExample.mxml @@ -0,0 +1,53 @@ +<?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:js="library://ns.apache.org/flexjs/basic" + xmlns:models="models.*" + xmlns:controllers="controllers.*" + initialize="MyModel(model).stockSymbol='ADBE'" + > + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + <js:initialView> + <local:MyInitialView /> + </js:initialView> + <js:model> + <models:MyModel /> + </js:model> + <js:controller> + <controllers:MyController /> + </js:controller> + <js:beads> + <js:HTTPService id="service"> + <js:LazyCollection id="collection"> + <js:inputParser> + <js:JSONInputParser /> + </js:inputParser> + <js:itemConverter> + <local:StockDataJSONItemConverter /> + </js:itemConverter> + </js:LazyCollection> + </js:HTTPService> + <js:CSSFontFaceBead /> + <js:ViewSourceContextMenuOption /> + </js:beads> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_Flat/src/DataBindingTest.mxml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_Flat/src/DataBindingTest.mxml b/examples/DataBindingExample_Flat/src/DataBindingTest.mxml deleted file mode 100644 index 751e427..0000000 --- a/examples/DataBindingExample_Flat/src/DataBindingTest.mxml +++ /dev/null @@ -1,53 +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:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:local="*" - xmlns:js="library://ns.apache.org/flexjs/basic" - xmlns:models="models.*" - xmlns:controllers="controllers.*" - initialize="MyModel(model).stockSymbol='ADBE'" - > - <js:valuesImpl> - <js:SimpleCSSValuesImpl /> - </js:valuesImpl> - <js:initialView> - <local:MyInitialView /> - </js:initialView> - <js:model> - <models:MyModel /> - </js:model> - <js:controller> - <controllers:MyController /> - </js:controller> - <js:beads> - <js:HTTPService id="service"> - <js:LazyCollection id="collection"> - <js:inputParser> - <js:JSONInputParser /> - </js:inputParser> - <js:itemConverter> - <local:StockDataJSONItemConverter /> - </js:itemConverter> - </js:LazyCollection> - </js:HTTPService> - <js:CSSFontFaceBead /> - <js:ViewSourceContextMenuOption /> - </js:beads> -</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_Flat/src/controllers/MyController.as ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_Flat/src/controllers/MyController.as b/examples/DataBindingExample_Flat/src/controllers/MyController.as index 83c2cd5..2ee16ae 100644 --- a/examples/DataBindingExample_Flat/src/controllers/MyController.as +++ b/examples/DataBindingExample_Flat/src/controllers/MyController.as @@ -31,14 +31,14 @@ package controllers { if (app) { - this.app = app as DataBindingTest; + this.app = app as DataBindingExample; app.addEventListener("viewChanged", viewChangeHandler); } } 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 app:DataBindingTest; + private var app:DataBindingExample; private function viewChangeHandler(event:Event):void { @@ -73,7 +73,7 @@ package controllers public function setDocument(document:Object, id:String = null):void { - this.app = document as DataBindingTest; + this.app = document as DataBindingExample; app.addEventListener("viewChanged", viewChangeHandler); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_as/build.xml ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_as/build.xml b/examples/DataBindingExample_as/build.xml index 3a04dfa..3e40bfd 100644 --- a/examples/DataBindingExample_as/build.xml +++ b/examples/DataBindingExample_as/build.xml @@ -19,9 +19,9 @@ --> -<project name="databindingtest_as" default="main" basedir="."> +<project name="databindingexample_as" default="main" basedir="."> <property name="FLEXJS_HOME" location="../.."/> - <property name="example" value="DataBindingTest" /> + <property name="example" value="DataBindingExample" /> <property file="${FLEXJS_HOME}/env.properties"/> <property environment="env"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_as/src/DataBindingExample.as ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_as/src/DataBindingExample.as b/examples/DataBindingExample_as/src/DataBindingExample.as new file mode 100644 index 0000000..5e7af98 --- /dev/null +++ b/examples/DataBindingExample_as/src/DataBindingExample.as @@ -0,0 +1,257 @@ +/** + +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.core.Application; +import org.apache.flex.core.ItemRendererClassFactory; +import org.apache.flex.core.SimpleCSSValuesImpl; +import org.apache.flex.events.Event; +import org.apache.flex.html.beads.CSSButtonView; +import org.apache.flex.html.beads.CSSTextButtonView; +import org.apache.flex.html.beads.CheckBoxView; +import org.apache.flex.html.beads.ContainerView; +import org.apache.flex.html.beads.DataItemRendererFactoryForArrayData; +import org.apache.flex.html.beads.DropDownListView; +import org.apache.flex.html.beads.ListView; +import org.apache.flex.html.beads.RadioButtonView; +import org.apache.flex.html.beads.SingleLineBorderBead; +import org.apache.flex.html.beads.SolidBackgroundBead; +import org.apache.flex.html.beads.TextAreaView; +import org.apache.flex.html.beads.TextButtonMeasurementBead; +import org.apache.flex.html.beads.TextFieldLabelMeasurementBead; +import org.apache.flex.html.beads.TextFieldView; +import org.apache.flex.html.beads.TextInputWithBorderView; +import org.apache.flex.html.beads.TextItemRendererFactoryForArrayData; +import org.apache.flex.html.beads.controllers.DropDownListController; +import org.apache.flex.html.beads.controllers.ItemRendererMouseController; +import org.apache.flex.html.beads.controllers.EditableTextKeyboardController; +import org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController; +import org.apache.flex.html.beads.layouts.VerticalScrollingLayout; +import org.apache.flex.html.beads.models.ArraySelectionModel; +import org.apache.flex.html.beads.models.SingleLineBorderModel; +import org.apache.flex.html.beads.models.TextModel; +import org.apache.flex.html.beads.models.ToggleButtonModel; +import org.apache.flex.html.beads.models.ValueToggleButtonModel; +import org.apache.flex.html.supportClasses.DropDownListList; +import org.apache.flex.html.supportClasses.DataGroup; +import org.apache.flex.html.supportClasses.StringItemRenderer; +import org.apache.flex.net.HTTPService; +import org.apache.flex.collections.parsers.JSONInputParser; +import org.apache.flex.collections.LazyCollection; +import org.apache.flex.utils.ViewSourceContextMenuOption; + +import models.MyModel; +import controllers.MyController; + +public class DataBindingExample extends Application +{ + + public function DataBindingExample() + { + addEventListener("initialize", initializeHandler); + var vi:SimpleCSSValuesImpl = new SimpleCSSValuesImpl(); + setupStyles(vi); + valuesImpl = vi; + initialView = new MyInitialView(); + model = new MyModel(); + controller = new MyController(this); + service = new HTTPService(); + collection = new LazyCollection(); + collection.inputParser = new JSONInputParser(); + collection.itemConverter = new StockDataJSONItemConverter(); + service.addBead(collection); + addBead(service); + addBead(new ViewSourceContextMenuOption()); + } + + public var service:HTTPService; + public var collection:LazyCollection; + + private function initializeHandler(event:Event):void + { + MyModel(model).stockSymbol="ADBE"; + } + + private function setupStyles(vi:SimpleCSSValuesImpl):void + { + var viv:Object = vi.values = {}; + viv["global"] = + { + fontFamily: "Arial", + fontSize: 12 + }; + + var o:Object; + + o = viv[makeDefinitionName("org.apache.flex.html::Container")] = + { + + iBeadView: ContainerView + }; + + CONFIG::as_only { + o.iBackgroundBead = SolidBackgroundBead; + o.iBorderBead = SingleLineBorderBead; + } + + viv[makeDefinitionName("org.apache.flex.html::List")] = + { + iBeadModel: ArraySelectionModel, + iBeadView: ListView, + iBeadController: ListSingleSelectionMouseController, + iBeadLayout: VerticalScrollingLayout, + iDataGroup: DataGroup, + iDataProviderItemRendererMapper: DataItemRendererFactoryForArrayData, + iItemRendererClassFactory: ItemRendererClassFactory, + iItemRenderer: StringItemRenderer + }; + + o = viv[makeDefinitionName("org.apache.flex.html::Button")] = + { + backgroundColor: 0xd8d8d8, + border: [1, "solid", 0x000000], + padding: 4 + }; + CONFIG::as_only { + o.iBeadView = CSSButtonView; + } + + viv[makeDefinitionName("org.apache.flex.html::Button:hover")] = + { + backgroundColor: 0x9fa0a1, + border: [1, "solid", 0x000000], + padding: 4 + }; + + viv[makeDefinitionName("org.apache.flex.html::Button:active")] = + { + backgroundColor: 0x929496, + border: [1, "solid", 0x000000], + padding: 4 + }; + + CONFIG::as_only { + viv["org.apache.flex.html::CheckBox"] = + { + iBeadModel: ToggleButtonModel, + iBeadView: CheckBoxView + }; + + viv["org.apache.flex.html::DropDownList"] = + { + iBeadModel: ArraySelectionModel, + iBeadView: DropDownListView, + iBeadController: DropDownListController, + iPopUp: DropDownListList + }; + + viv["org.apache.flex.html.supportClasses::DropDownListList"] = + { + iBeadModel: ArraySelectionModel, + iDataProviderItemRendererMapper: TextItemRendererFactoryForArrayData, + iItemRendererClassFactory: ItemRendererClassFactory, + iItemRenderer: StringItemRenderer + }; + + viv["org.apache.flex.html::Label"] = + { + iBeadModel: TextModel, + iBeadView: TextFieldView, + iMeasurementBead: TextFieldLabelMeasurementBead + }; + + viv["org.apache.flex.html::List"] = + { + iBorderBead: SingleLineBorderBead, + iBorderModel: SingleLineBorderModel + }; + + viv["org.apache.flex.html::RadioButton"] = + { + iBeadModel: ValueToggleButtonModel, + iBeadView: RadioButtonView + }; + + viv["org.apache.flex.html::TextArea"] = + { + iBeadModel: TextModel, + iBeadView: TextAreaView, + iBeadController: EditableTextKeyboardController, + iBorderBead: SingleLineBorderBead, + iBorderModel: SingleLineBorderModel, + width: 135, + height: 20 + }; + + viv["org.apache.flex.html::TextButton"] = + { + iBeadModel: TextModel, + iBeadView: CSSTextButtonView, + iMeasurementBead: TextButtonMeasurementBead + }; + + viv["org.apache.flex.html::TextInput"] = + { + iBeadModel: TextModel, + iBeadView: TextInputWithBorderView, + iBeadController: EditableTextKeyboardController, + iBorderBead: SingleLineBorderBead, + iBorderModel: SingleLineBorderModel, + width: 135, + height: 20 + }; + + viv["org.apache.flex.html::ToggleTextButton"] = + { + iBeadModel: ToggleButtonModel, + iBeadView: CSSTextButtonView + }; + + viv["org.apache.flex.html::SimpleList"] = + { + iBeadModel: ArraySelectionModel, + iBeadView: ListView, + iBeadController: ListSingleSelectionMouseController, + iBeadLayout: VerticalScrollingLayout, + iDataGroup: DataGroup, + iDataProviderItemRendererMapper: TextItemRendererFactoryForArrayData, + iItemRendererClassFactory: ItemRendererClassFactory, + iItemRenderer: StringItemRenderer + } + + viv["org.apache.flex.html.supportClasses::StringItemRenderer"] = + { + iBeadController: ItemRendererMouseController, + height: 16 + } + } + } + + private function makeDefinitionName(s:String):String + { + CONFIG::js_only { + s = s.replace(/\./g, "_"); + s = s.replace("::", "_"); + } + return s; + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_as/src/DataBindingTest.as ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_as/src/DataBindingTest.as b/examples/DataBindingExample_as/src/DataBindingTest.as deleted file mode 100644 index 56d1a0e..0000000 --- a/examples/DataBindingExample_as/src/DataBindingTest.as +++ /dev/null @@ -1,257 +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.core.Application; -import org.apache.flex.core.ItemRendererClassFactory; -import org.apache.flex.core.SimpleCSSValuesImpl; -import org.apache.flex.events.Event; -import org.apache.flex.html.beads.CSSButtonView; -import org.apache.flex.html.beads.CSSTextButtonView; -import org.apache.flex.html.beads.CheckBoxView; -import org.apache.flex.html.beads.ContainerView; -import org.apache.flex.html.beads.DataItemRendererFactoryForArrayData; -import org.apache.flex.html.beads.DropDownListView; -import org.apache.flex.html.beads.ListView; -import org.apache.flex.html.beads.RadioButtonView; -import org.apache.flex.html.beads.SingleLineBorderBead; -import org.apache.flex.html.beads.SolidBackgroundBead; -import org.apache.flex.html.beads.TextAreaView; -import org.apache.flex.html.beads.TextButtonMeasurementBead; -import org.apache.flex.html.beads.TextFieldLabelMeasurementBead; -import org.apache.flex.html.beads.TextFieldView; -import org.apache.flex.html.beads.TextInputWithBorderView; -import org.apache.flex.html.beads.TextItemRendererFactoryForArrayData; -import org.apache.flex.html.beads.controllers.DropDownListController; -import org.apache.flex.html.beads.controllers.ItemRendererMouseController; -import org.apache.flex.html.beads.controllers.EditableTextKeyboardController; -import org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController; -import org.apache.flex.html.beads.layouts.VerticalScrollingLayout; -import org.apache.flex.html.beads.models.ArraySelectionModel; -import org.apache.flex.html.beads.models.SingleLineBorderModel; -import org.apache.flex.html.beads.models.TextModel; -import org.apache.flex.html.beads.models.ToggleButtonModel; -import org.apache.flex.html.beads.models.ValueToggleButtonModel; -import org.apache.flex.html.supportClasses.DropDownListList; -import org.apache.flex.html.supportClasses.DataGroup; -import org.apache.flex.html.supportClasses.StringItemRenderer; -import org.apache.flex.net.HTTPService; -import org.apache.flex.collections.parsers.JSONInputParser; -import org.apache.flex.collections.LazyCollection; -import org.apache.flex.utils.ViewSourceContextMenuOption; - -import models.MyModel; -import controllers.MyController; - -public class DataBindingTest extends Application -{ - - public function DataBindingTest() - { - addEventListener("initialize", initializeHandler); - var vi:SimpleCSSValuesImpl = new SimpleCSSValuesImpl(); - setupStyles(vi); - valuesImpl = vi; - initialView = new MyInitialView(); - model = new MyModel(); - controller = new MyController(this); - service = new HTTPService(); - collection = new LazyCollection(); - collection.inputParser = new JSONInputParser(); - collection.itemConverter = new StockDataJSONItemConverter(); - service.addBead(collection); - addBead(service); - addBead(new ViewSourceContextMenuOption()); - } - - public var service:HTTPService; - public var collection:LazyCollection; - - private function initializeHandler(event:Event):void - { - MyModel(model).stockSymbol="ADBE"; - } - - private function setupStyles(vi:SimpleCSSValuesImpl):void - { - var viv:Object = vi.values = {}; - viv["global"] = - { - fontFamily: "Arial", - fontSize: 12 - }; - - var o:Object; - - o = viv[makeDefinitionName("org.apache.flex.html::Container")] = - { - - iBeadView: ContainerView - }; - - CONFIG::as_only { - o.iBackgroundBead = SolidBackgroundBead; - o.iBorderBead = SingleLineBorderBead; - } - - viv[makeDefinitionName("org.apache.flex.html::List")] = - { - iBeadModel: ArraySelectionModel, - iBeadView: ListView, - iBeadController: ListSingleSelectionMouseController, - iBeadLayout: VerticalScrollingLayout, - iDataGroup: DataGroup, - iDataProviderItemRendererMapper: DataItemRendererFactoryForArrayData, - iItemRendererClassFactory: ItemRendererClassFactory, - iItemRenderer: StringItemRenderer - }; - - o = viv[makeDefinitionName("org.apache.flex.html::Button")] = - { - backgroundColor: 0xd8d8d8, - border: [1, "solid", 0x000000], - padding: 4 - }; - CONFIG::as_only { - o.iBeadView = CSSButtonView; - } - - viv[makeDefinitionName("org.apache.flex.html::Button:hover")] = - { - backgroundColor: 0x9fa0a1, - border: [1, "solid", 0x000000], - padding: 4 - }; - - viv[makeDefinitionName("org.apache.flex.html::Button:active")] = - { - backgroundColor: 0x929496, - border: [1, "solid", 0x000000], - padding: 4 - }; - - CONFIG::as_only { - viv["org.apache.flex.html::CheckBox"] = - { - iBeadModel: ToggleButtonModel, - iBeadView: CheckBoxView - }; - - viv["org.apache.flex.html::DropDownList"] = - { - iBeadModel: ArraySelectionModel, - iBeadView: DropDownListView, - iBeadController: DropDownListController, - iPopUp: DropDownListList - }; - - viv["org.apache.flex.html.supportClasses::DropDownListList"] = - { - iBeadModel: ArraySelectionModel, - iDataProviderItemRendererMapper: TextItemRendererFactoryForArrayData, - iItemRendererClassFactory: ItemRendererClassFactory, - iItemRenderer: StringItemRenderer - }; - - viv["org.apache.flex.html::Label"] = - { - iBeadModel: TextModel, - iBeadView: TextFieldView, - iMeasurementBead: TextFieldLabelMeasurementBead - }; - - viv["org.apache.flex.html::List"] = - { - iBorderBead: SingleLineBorderBead, - iBorderModel: SingleLineBorderModel - }; - - viv["org.apache.flex.html::RadioButton"] = - { - iBeadModel: ValueToggleButtonModel, - iBeadView: RadioButtonView - }; - - viv["org.apache.flex.html::TextArea"] = - { - iBeadModel: TextModel, - iBeadView: TextAreaView, - iBeadController: EditableTextKeyboardController, - iBorderBead: SingleLineBorderBead, - iBorderModel: SingleLineBorderModel, - width: 135, - height: 20 - }; - - viv["org.apache.flex.html::TextButton"] = - { - iBeadModel: TextModel, - iBeadView: CSSTextButtonView, - iMeasurementBead: TextButtonMeasurementBead - }; - - viv["org.apache.flex.html::TextInput"] = - { - iBeadModel: TextModel, - iBeadView: TextInputWithBorderView, - iBeadController: EditableTextKeyboardController, - iBorderBead: SingleLineBorderBead, - iBorderModel: SingleLineBorderModel, - width: 135, - height: 20 - }; - - viv["org.apache.flex.html::ToggleTextButton"] = - { - iBeadModel: ToggleButtonModel, - iBeadView: CSSTextButtonView - }; - - viv["org.apache.flex.html::SimpleList"] = - { - iBeadModel: ArraySelectionModel, - iBeadView: ListView, - iBeadController: ListSingleSelectionMouseController, - iBeadLayout: VerticalScrollingLayout, - iDataGroup: DataGroup, - iDataProviderItemRendererMapper: TextItemRendererFactoryForArrayData, - iItemRendererClassFactory: ItemRendererClassFactory, - iItemRenderer: StringItemRenderer - } - - viv["org.apache.flex.html.supportClasses::StringItemRenderer"] = - { - iBeadController: ItemRendererMouseController, - height: 16 - } - } - } - - private function makeDefinitionName(s:String):String - { - CONFIG::js_only { - s = s.replace(/\./g, "_"); - s = s.replace("::", "_"); - } - return s; - } -} - -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4b6f8a80/examples/DataBindingExample_as/src/controllers/MyController.as ---------------------------------------------------------------------- diff --git a/examples/DataBindingExample_as/src/controllers/MyController.as b/examples/DataBindingExample_as/src/controllers/MyController.as index 83c2cd5..2ee16ae 100644 --- a/examples/DataBindingExample_as/src/controllers/MyController.as +++ b/examples/DataBindingExample_as/src/controllers/MyController.as @@ -31,14 +31,14 @@ package controllers { if (app) { - this.app = app as DataBindingTest; + this.app = app as DataBindingExample; app.addEventListener("viewChanged", viewChangeHandler); } } 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 app:DataBindingTest; + private var app:DataBindingExample; private function viewChangeHandler(event:Event):void { @@ -73,7 +73,7 @@ package controllers public function setDocument(document:Object, id:String = null):void { - this.app = document as DataBindingTest; + this.app = document as DataBindingExample; app.addEventListener("viewChanged", viewChangeHandler); }
