Updated Branches:
  refs/heads/develop 50e8a637f -> 95b423da7

DataGrid cross-compile example.


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

Branch: refs/heads/develop
Commit: 95b423da737a3470856d1d703088891a4c6c5730
Parents: 50e8a63
Author: Peter Ent <[email protected]>
Authored: Fri Dec 6 14:29:42 2013 -0500
Committer: Peter Ent <[email protected]>
Committed: Fri Dec 6 14:29:42 2013 -0500

----------------------------------------------------------------------
 .../DataGridXcompile/src/DataGridXcompile.mxml  |  37 +++++
 .../DataGridXcompile/src/MyInitialView.mxml     |  83 +++++++++++
 .../src/models/MyGridPresentation.as            |  32 ++++
 .../src/models/ProductsModel.as                 |  53 +++++++
 .../flex/core/IDataGridPresentationModel.as     |  31 ++++
 .../apache/flex/html/customControls/DataGrid.as |  60 ++++++++
 .../customControls/beads/DataGridColumnView.as  |  57 +++++++
 .../html/customControls/beads/DataGridView.as   | 149 +++++++++++++++++++
 .../DataItemRendererFactoryForColumnData.as     | 101 +++++++++++++
 .../html/customControls/beads/IDataGridView.as  |  27 ++++
 .../beads/IDataProviderItemRendererMapper.as    |  34 +++++
 .../beads/models/DataGridPresentationModel.as   |  65 ++++++++
 .../html/staticControls/beads/BoxGridView.as    |  48 ++++++
 .../DataGridXcompile/src/products/Product.as    |  41 +++++
 14 files changed, 818 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/DataGridXcompile.mxml
----------------------------------------------------------------------
diff --git a/examples/DataGridXcompile/src/DataGridXcompile.mxml 
b/examples/DataGridXcompile/src/DataGridXcompile.mxml
new file mode 100644
index 0000000..9182b33
--- /dev/null
+++ b/examples/DataGridXcompile/src/DataGridXcompile.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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<basic:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
+                                  xmlns:local="*"
+                                  xmlns:models="models.*"
+                                  
xmlns:basic="library://ns.apache.org/flexjs/basic" 
+                                  
xmlns:staticControls="org.apache.flex.html.staticControls.*"
+                                  >
+       
+       <basic:valuesImpl>
+               <basic:SimpleCSSValuesImpl />
+       </basic:valuesImpl>
+       <basic:model>
+               <models:ProductsModel />
+       </basic:model>
+       <basic:initialView>
+               <local:MyInitialView />
+       </basic:initialView>
+</basic:Application>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/DataGridXcompile/src/MyInitialView.mxml 
b/examples/DataGridXcompile/src/MyInitialView.mxml
new file mode 100644
index 0000000..11bf6c0
--- /dev/null
+++ b/examples/DataGridXcompile/src/MyInitialView.mxml
@@ -0,0 +1,83 @@
+<?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.
+
+-->
+<basic:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009";
+                               
xmlns:basic="library://ns.apache.org/flexjs/basic"
+                               xmlns:local="*"
+                               xmlns:models="models.*"
+                               initComplete="initControls()" 
+                               
xmlns:customControls="org.apache.flex.html.customControls.*" 
+                               
xmlns:beads="org.apache.flex.html.customControls.beads.*">
+       
+       <fx:Style>
+               @namespace basic "library://ns.apache.org/flexjs/basic";
+               @namespace custom "org.apache.flex.html.customControls.*";
+               
+               .boxGrid {
+                       background-color: #FF0000;
+                       IBeadView: 
ClassReference('org.apache.flex.html.staticControls.beads.BoxGridView');
+               }
+               
+               custom|DataGrid
+               {
+                       IDataGridPresentationModel: 
ClassReference("org.apache.flex.html.staticControls.beads.models.DataGridPresentationModel");
+                       IBeadView: 
ClassReference("org.apache.flex.html.customControls.beads.DataGridView");
+                       IBeadModel: 
ClassReference("org.apache.flex.html.staticControls.beads.models.DataGridModel");
+                       IItemRendererClassFactory: 
ClassReference("org.apache.flex.core.ItemRendererClassFactory");
+                       IItemRenderer: 
ClassReference("org.apache.flex.html.staticControls.supportClasses.StringItemRenderer");
+                       
+                       background-color: #FFFFFF;
+               }
+               
+       </fx:Style>
+       
+    <fx:Script>
+        <![CDATA[
+                       
+                       private function initControls() : void
+                       {
+                                       
+                       }
+                       
+                       private function dataGridChange() : void
+                       {
+                               //output.text = "Clicked on row 
"+dataGrid.selectedIndex;
+                               //trace("Click on row "+dataGrid.selectedIndex);
+                       }
+               ]]>
+    </fx:Script>
+       
+       <basic:Label id="output" text="here" x="450" y="30" width="100" />
+       
+       <customControls:DataGrid id="dataGrid" x="20" y="30" width="400" 
height="300" change="dataGridChange()" >
+               <customControls:beads>
+                       <models:MyGridPresentation rowHeight="50" />
+                       <basic:ConstantBinding
+                               sourceID="applicationModel"
+                               sourcePropertyName="productList"
+                               destinationPropertyName="dataProvider" />
+                       <basic:ConstantBinding
+                               sourceID="applicationModel"
+                               sourcePropertyName="labelFields"
+                               destinationPropertyName="labelFields" />
+                       <beads:DataGridView />
+               </customControls:beads>
+       </customControls:DataGrid>
+
+</basic:ViewBase>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/models/MyGridPresentation.as
----------------------------------------------------------------------
diff --git a/examples/DataGridXcompile/src/models/MyGridPresentation.as 
b/examples/DataGridXcompile/src/models/MyGridPresentation.as
new file mode 100644
index 0000000..a724722
--- /dev/null
+++ b/examples/DataGridXcompile/src/models/MyGridPresentation.as
@@ -0,0 +1,32 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.customControls.beads.models.DataGridPresentationModel;
+       
+       public class MyGridPresentation extends DataGridPresentationModel
+       {
+               public function MyGridPresentation()
+               {
+                       super();
+                       
+                       this.columnLabels = ["ID","Title","Inventory"];
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/models/ProductsModel.as
----------------------------------------------------------------------
diff --git a/examples/DataGridXcompile/src/models/ProductsModel.as 
b/examples/DataGridXcompile/src/models/ProductsModel.as
new file mode 100644
index 0000000..be0bfe2
--- /dev/null
+++ b/examples/DataGridXcompile/src/models/ProductsModel.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.EventDispatcher;
+       
+       import products.Product;
+       
+       public class ProductsModel extends EventDispatcher
+       {
+               public function ProductsModel()
+               {
+               }
+
+               private var _productList:Array = [
+                       new Product("ps100","Widgets","44","smallbluerect.jpg"),
+                       new Product("tx200","Thingys","out of 
stock","smallgreenrect.jpg"),
+                       new 
Product("rz300","Sprockets","8,000","smallyellowrect.jpg"),
+                       new Product("dh440","Doohickies","out of 
stock","smallredrect.jpg"),
+                       new 
Product("ps220","Weejets","235","smallorangerect.jpg")
+                       ];
+               public function get productList():Array
+               {
+                       return _productList;
+               }
+
+               private var _labelFields:Array = [ "id", "title", "detail" ];
+               public function get labelFields():Object
+               {
+                       return _labelFields;
+               }
+               public function set labelFields(value:Object):void
+               {
+                       // ignore
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/core/IDataGridPresentationModel.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/core/IDataGridPresentationModel.as
 
b/examples/DataGridXcompile/src/org/apache/flex/core/IDataGridPresentationModel.as
new file mode 100644
index 0000000..34a5d84
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/core/IDataGridPresentationModel.as
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+       import org.apache.flex.events.IEventDispatcher;
+       
+       public interface IDataGridPresentationModel extends IEventDispatcher, 
IBead
+       {
+               function get columnLabels():Array;
+               function set columnLabels(value:Array):void;
+               
+               function get rowHeight():Number;
+               function set rowHeight(value:Number):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/DataGrid.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/DataGrid.as 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/DataGrid.as
new file mode 100644
index 0000000..b4ded72
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/DataGrid.as
@@ -0,0 +1,60 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.customControls
+{
+       import org.apache.flex.core.IDataGridModel;
+       import org.apache.flex.core.UIBase;
+       
+       [Event(name="change", type="org.apache.flex.events.Event")]
+       
+       public class DataGrid extends UIBase
+       {
+               public function DataGrid()
+               {
+                       super();
+               }
+               
+               public function get dataProvider():Object
+               {
+                       return IDataGridModel(model).dataProvider;
+               }
+               public function set dataProvider(value:Object):void
+               {
+                       //IDataGridModel(model).dataProvider = value;  
+                       var dgm:IDataGridModel = model as IDataGridModel
+                       dgm.dataProvider = value;
+               }
+               
+               public function get labelFields():Object
+               {
+                       return IDataGridModel(model).labelFields;
+               }
+               public function set labelFields(value:Object):void
+               {
+                       //IDataGridModel(model).labelFields = value;
+                       var dgm:IDataGridModel = model as IDataGridModel
+                       dgm.labelFields = value;
+               }
+               
+               public function get selectedIndex():int
+               {
+                       return IDataGridModel(model).selectedIndex;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridColumnView.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridColumnView.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridColumnView.as
new file mode 100644
index 0000000..92ae4d2
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridColumnView.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 org.apache.flex.html.customControls.beads
+{
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.html.staticControls.beads.ListView;
+       
+       public class DataGridColumnView extends ListView
+       {
+               public function DataGridColumnView()
+               {
+               }
+               
+               private var _strand:IStrand;
+               override public function set strand(value:IStrand):void
+               {
+                       super.strand = value;
+                       _strand = value;
+               }
+               
+               private var _columnIndex:uint;
+               public function get columnIndex():uint
+               {
+                       return _columnIndex;
+               }
+               public function set columnIndex(value:uint):void
+               {
+                       _columnIndex = value;
+               }
+               
+               private var _labelField:String;
+               public function get labelField():String
+               {
+                       return _labelField;
+               }
+               public function set labelField(value:String):void
+               {
+                       _labelField = value;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridView.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridView.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridView.as
new file mode 100644
index 0000000..0f41aab
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataGridView.as
@@ -0,0 +1,149 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.customControls.beads
+{
+//     import flash.display.DisplayObject;
+//     import flash.display.DisplayObjectContainer;
+//     import flash.display.Shape;
+       
+       import org.apache.flex.core.IBeadModel;
+       import org.apache.flex.core.IDataGridModel;
+       import org.apache.flex.core.IDataGridPresentationModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.core.ValuesManager;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import org.apache.flex.html.staticControls.ButtonBar;
+       import org.apache.flex.html.staticControls.Container;
+       import org.apache.flex.html.staticControls.List;
+       import org.apache.flex.html.staticControls.SimpleList;
+       import 
org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout;
+       import 
org.apache.flex.html.staticControls.beads.models.ArraySelectionModel;
+       
+       public class DataGridView implements IDataGridView
+       {
+               public function DataGridView()
+               {
+               }
+               
+//             private var background:Shape;
+               private var buttonBar:ButtonBar;
+               private var buttonBarModel:ArraySelectionModel;
+               private var columnContainer:Container;
+               private var columns:Array;
+               
+               private var _strand:IStrand;
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
+//                     background = new Shape();
+//                     DisplayObjectContainer(_strand).addChild(background);
+                       
+                       var pm:IDataGridPresentationModel = 
_strand.getBeadByType(IDataGridPresentationModel) as IDataGridPresentationModel;
+                       buttonBarModel = new ArraySelectionModel();
+                       buttonBarModel.dataProvider = pm.columnLabels;
+                       buttonBar = new ButtonBar();
+                       buttonBar.addBead(buttonBarModel);
+                       buttonBar.height = 20;
+                       buttonBar.width = UIBase(_strand).width;
+                       UIBase(_strand).addElement(buttonBar);
+                       
+                       columnContainer = new Container();
+                       var layout:NonVirtualHorizontalLayout = new 
NonVirtualHorizontalLayout();
+                       columnContainer.addBead(layout);
+                       UIBase(_strand).addElement(columnContainer);
+                       
+                       var sharedModel:IDataGridModel = 
_strand.getBeadByType(IBeadModel) as IDataGridModel;
+                       var columnWidth:Number = UIBase(_strand).width / 
pm.columnLabels.length;
+                       var columnHeight:Number = UIBase(_strand).height - 
buttonBar.height;
+                       
+                       columns = new Array();
+                       for(var i:int=0; i < pm.columnLabels.length; i++) {
+                               var column:List = new List();
+                               var columnView:DataGridColumnView = new 
DataGridColumnView();
+                               columnView.labelField = 
sharedModel.labelFields[i];
+                               var 
factory:DataItemRendererFactoryForColumnData = new 
DataItemRendererFactoryForColumnData();
+                               columnView.columnIndex = i;
+                               column.width = columnWidth;
+                               column.height = columnHeight;
+                               column.addBead(sharedModel);
+                               column.addBead(columnView);
+                               column.addBead(factory);
+                               columnContainer.addElement(column);
+                               columns.push(column);
+                               
+                               
column.addEventListener('change',columnListChangeHandler);
+                       }
+                       
+                       
IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange);
+                       
IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange);
+                       
+                       handleSizeChange(null); // initial sizing
+               }
+               
+               private function handleSizeChange(event:Event):void
+               {
+                       var sw:Number = UIBase(_strand).width;
+                       var sh:Number = UIBase(_strand).height;
+                       
+/*                     var backgroundColor:Number = 0xDDDDDD;
+                       var value:Object = 
ValuesManager.valuesImpl.getValue(_strand, "background-color");
+                       if (value != null) backgroundColor = Number(value);*/
+                       
+/*                     background.graphics.clear();
+                       background.graphics.beginFill(backgroundColor);
+                       background.graphics.drawRect(0,0,sw,sh);
+                       background.graphics.endFill();*/
+                       
+                       buttonBar.x = 0;
+                       buttonBar.y = 0;
+                       buttonBar.width = sw;
+                       buttonBar.height = 25;
+                       
+                       columnContainer.x = 0;
+                       columnContainer.y = 30;
+                       columnContainer.width = sw;
+                       columnContainer.height = sh - 25;
+                       
+                       for(var i:int=0; i < columns.length; i++) {
+                               var column:List = columns[i];
+                       
+                               var cw:Number = sw/(columns.length);
+                               column.x = i*cw; // should be positioned by the 
Container's layout
+                               column.y = 0;
+                               column.width = cw;
+                               column.height = columnContainer.height; // this 
will actually be Nitem*rowHeight
+                       }
+               }
+               
+               private function columnListChangeHandler(event:Event):void
+               {
+                       var list:List = event.target as List;
+                       for(var i:int=0; i < columns.length; i++) {
+                               if (list != columns[i]) {
+                                       columns[i].selectedIndex = 
list.selectedIndex;
+                               }
+                       }
+                       
+                       IEventDispatcher(_strand).dispatchEvent(new 
Event('change'));
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataItemRendererFactoryForColumnData.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataItemRendererFactoryForColumnData.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataItemRendererFactoryForColumnData.as
new file mode 100644
index 0000000..a3e5a38
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/DataItemRendererFactoryForColumnData.as
@@ -0,0 +1,101 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.customControls.beads
+{
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IBeadView;
+       import org.apache.flex.core.IItemRenderer;
+       import org.apache.flex.core.IItemRendererClassFactory;
+       import org.apache.flex.core.IItemRendererParent;
+       import org.apache.flex.core.ISelectionModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.ValuesManager;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       import 
org.apache.flex.html.staticControls.supportClasses.DataItemRenderer;
+       import org.apache.flex.html.staticControls.beads.IListView;
+       
+       public class DataItemRendererFactoryForColumnData implements IBead, 
IDataProviderItemRendererMapper
+       {
+               public function DataItemRendererFactoryForColumnData()
+               {
+               }
+               
+               private var selectionModel:ISelectionModel;
+               
+               private var _strand:IStrand;
+               
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       selectionModel = value.getBeadByType(ISelectionModel) 
as ISelectionModel;
+                       var listView:IListView = value.getBeadByType(IListView) 
as IListView;
+                       dataGroup = listView.dataGroup;
+                       selectionModel.addEventListener("dataProviderChanged", 
dataProviderChangeHandler);
+                       
+                       if (!itemRendererFactory)
+                       {
+                               var c:Class = 
ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory");
+                               _itemRendererFactory = (new c()) as 
IItemRendererClassFactory;
+                               _strand.addBead(_itemRendererFactory);
+                       }
+                       
+                       dataProviderChangeHandler(null);
+               }
+               
+               public var _itemRendererFactory:IItemRendererClassFactory;
+               
+               public function get 
itemRendererFactory():IItemRendererClassFactory
+               {
+                       return _itemRendererFactory
+               }
+               
+               public function set 
itemRendererFactory(value:IItemRendererClassFactory):void
+               {
+                       _itemRendererFactory = value;
+               }
+               
+               protected var dataGroup:IItemRendererParent;
+               
+               private function dataProviderChangeHandler(event:Event):void
+               {
+                       var dp:Array = selectionModel.dataProvider as Array;
+                       if (!dp)
+                               return;
+                       
+                       dataGroup.removeAllElements();
+                       
+                       var view:DataGridColumnView = 
_strand.getBeadByType(IBeadView) as DataGridColumnView;
+                       if (view == null) return;
+                       
+                       var n:int = dp.length; 
+                       for (var i:int = 0; i < n; i++)
+                       {
+                               
+                               var tf:IItemRenderer = 
itemRendererFactory.createItemRenderer(dataGroup) as IItemRenderer;
+                               tf.index = i;
+                               dataGroup.addElement(tf);
+                               tf.data = dp[i];
+                               //tf.text = dp[i][view.labelField];
+                       }
+                       
+                       IEventDispatcher(_strand).dispatchEvent(new 
Event("itemsCreated"));
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataGridView.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataGridView.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataGridView.as
new file mode 100644
index 0000000..2b1bf61
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataGridView.as
@@ -0,0 +1,27 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.customControls.beads
+{
+       import org.apache.flex.core.IBeadView;
+       
+       public interface IDataGridView extends IBeadView
+       {
+               
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataProviderItemRendererMapper.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataProviderItemRendererMapper.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataProviderItemRendererMapper.as
new file mode 100644
index 0000000..8a406de
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/IDataProviderItemRendererMapper.as
@@ -0,0 +1,34 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.customControls.beads
+{
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IItemRendererClassFactory;
+
+    /**
+     * Classes that generate ItemRenderers based on dataProvider contents.
+     * These classes use an IItemRendererFactory to generate the actual
+     * ItemRenderer instances
+     */
+       public interface IDataProviderItemRendererMapper extends IBead
+       {
+        function get itemRendererFactory():IItemRendererClassFactory;
+        function set itemRendererFactory(value:IItemRendererClassFactory):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/models/DataGridPresentationModel.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/models/DataGridPresentationModel.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/models/DataGridPresentationModel.as
new file mode 100644
index 0000000..de24473
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/customControls/beads/models/DataGridPresentationModel.as
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.customControls.beads.models
+{
+       import org.apache.flex.core.IDataGridPresentationModel;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.EventDispatcher;
+       
+       public class DataGridPresentationModel extends EventDispatcher 
implements IDataGridPresentationModel
+       {
+               public function DataGridPresentationModel()
+               {
+                       super();
+               }
+               
+               private var _columnLabels:Array;
+               public function get columnLabels():Array
+               {
+                       return _columnLabels;
+               }
+               public function set columnLabels(value:Array):void
+               {
+                       if (value != _columnLabels) {
+                               _columnLabels = value;
+                               dispatchEvent(new Event("columnsChanged"));
+                       }
+               }
+               
+               private var _rowHeight:Number = 30;
+               public function get rowHeight():Number
+               {
+                       return _rowHeight;
+               }
+               public function set rowHeight(value:Number):void
+               {
+                       if (value != _rowHeight) {
+                               _rowHeight = value;
+                               dispatchEvent(new Event("rowHeightChanged"));
+                       }
+               }
+               
+               private var _strand:IStrand;
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
----------------------------------------------------------------------
diff --git 
a/examples/DataGridXcompile/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
 
b/examples/DataGridXcompile/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
new file mode 100644
index 0000000..e716abb
--- /dev/null
+++ 
b/examples/DataGridXcompile/src/org/apache/flex/html/staticControls/beads/BoxGridView.as
@@ -0,0 +1,48 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html.staticControls.beads
+{
+       import org.apache.flex.core.IBeadView;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.UIBase;
+       import org.apache.flex.html.staticControls.Label;
+       
+       public class BoxGridView implements IBeadView
+       {
+               public function BoxGridView()
+               {
+               }
+               
+               private var label:Label;
+               
+               private var _strand:IStrand;
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
+                       label = new Label();
+                       label.text = "BoxGrid";
+                       label.x = 0;
+                       label.y = 0;
+                       label.width = 100;
+                       label.height = 25;
+                       UIBase(_strand).addElement(label);
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/95b423da/examples/DataGridXcompile/src/products/Product.as
----------------------------------------------------------------------
diff --git a/examples/DataGridXcompile/src/products/Product.as 
b/examples/DataGridXcompile/src/products/Product.as
new file mode 100644
index 0000000..34abf6b
--- /dev/null
+++ b/examples/DataGridXcompile/src/products/Product.as
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 products
+{
+       public class Product
+       {
+               public function 
Product(id:String,title:String,detail:String,image:String)
+               {
+                       this.id = id;
+                       this.title = title;
+                       this.detail = detail;
+                       this.image = image;
+               }
+               
+               public var id:String;
+               public var title:String;
+               public var detail:String;
+               public var image:String;
+               
+               public function toString():String
+               {
+                       return title;
+               }
+       }
+}
\ No newline at end of file

Reply via email to