Added DataGrid component to ActionScript framework. This included adjustments 
to ButtonBar and other supporting classes and components.


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

Branch: refs/heads/develop
Commit: 7cef6640f129dab2b20f94d9deabcf5d5707ad9b
Parents: 8fabb09
Author: Peter Ent <[email protected]>
Authored: Tue Oct 22 16:02:27 2013 -0400
Committer: Peter Ent <[email protected]>
Committed: Tue Oct 22 16:02:27 2013 -0400

----------------------------------------------------------------------
 frameworks/as/basic-manifest.xml                |   2 +
 frameworks/as/defaults.css                      |  13 +-
 frameworks/as/src/FlexJSUIClasses.as            |   8 +-
 .../src/org/apache/flex/core/IDataGridModel.as  |  26 ++++
 .../flex/core/IDataGridPresentationModel.as     |  31 +++++
 .../apache/flex/html/staticControls/DataGrid.as |  49 +++++++
 .../html/staticControls/beads/ButtonBarView.as  |  44 +++++++
 .../staticControls/beads/CSSTextButtonView.as   |  30 ++++-
 .../staticControls/beads/DataGridColumnView.as  |  56 ++++++++
 .../html/staticControls/beads/DataGridView.as   | 129 +++++++++++++++++++
 .../DataItemRendererFactoryForColumnData.as     |  98 ++++++++++++++
 .../html/staticControls/beads/IDataGridView.as  |  27 ++++
 .../html/staticControls/beads/TextButtonView.as |  13 +-
 .../beads/layouts/ButtonBarLayout.as            |  69 ++++++++++
 .../beads/models/DataGridModel.as               |  45 +++++++
 .../beads/models/DataGridPresentationModel.as   |  65 ++++++++++
 .../ButtonBarButtonItemRenderer.as              |   1 -
 .../supportClasses/DataItemRenderer.as          |  30 +++++
 18 files changed, 727 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/as/basic-manifest.xml b/frameworks/as/basic-manifest.xml
index 2fe364b..7b2aaa5 100644
--- a/frameworks/as/basic-manifest.xml
+++ b/frameworks/as/basic-manifest.xml
@@ -29,6 +29,7 @@
     <component id="SimpleBinding" 
class="org.apache.flex.binding.SimpleBinding"/>
     <component id="Button" class="org.apache.flex.html.staticControls.Button"/>
     <component id="ButtonBar" 
class="org.apache.flex.html.staticControls.ButtonBar"/>
+    <component id="DataGrid" 
class="org.apache.flex.html.staticControls.DataGrid"/>
     <component id="DropDownList" 
class="org.apache.flex.html.staticControls.DropDownList"/>
     <component id="DropDownListList" 
class="org.apache.flex.html.staticControls.supportClasses.DropDownListList"/>
     <component id="Image" class="org.apache.flex.html.staticControls.Image"/>
@@ -68,5 +69,6 @@
     <component id="NumericOnlyTextInputBead" 
class="org.apache.flex.html.staticControls.accessories.NumericOnlyTextInputBead"
 />
     <component id="PasswordInputBead" 
class="org.apache.flex.html.staticControls.accessories.PasswordInputBead" />
     <component id="TextPromptBead" 
class="org.apache.flex.html.staticControls.accessories.TextPromptBead" />
+    <component id="DataGridPresentationModel" 
class="org.apache.flex.html.staticControls.beads.models.DataGridPresentationModel"
 />
 
 </componentPackage>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/as/defaults.css b/frameworks/as/defaults.css
index 74f0a38..5681af4 100644
--- a/frameworks/as/defaults.css
+++ b/frameworks/as/defaults.css
@@ -76,9 +76,9 @@ Alert
 ButtonBar
 {
     IBeadModel: 
ClassReference("org.apache.flex.html.staticControls.beads.models.ArraySelectionModel");
-    IBeadView:  
ClassReference("org.apache.flex.html.staticControls.beads.ListView");           
       
+    IBeadView:  
ClassReference("org.apache.flex.html.staticControls.beads.ButtonBarView");      
               
     IBeadController: 
ClassReference("org.apache.flex.html.staticControls.beads.controllers.ListSingleSelectionMouseController");
-    IBeadLayout: 
ClassReference("org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout");
+    IBeadLayout: 
ClassReference("org.apache.flex.html.staticControls.beads.layouts.ButtonBarLayout");
     IDataProviderItemRendererMapper: 
ClassReference("org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData");
     IItemRendererClassFactory: 
ClassReference("org.apache.flex.core.ItemRendererClassFactory");
     IItemRenderer: 
ClassReference("org.apache.flex.html.staticControls.supportClasses.ButtonBarButtonItemRenderer");
@@ -127,6 +127,15 @@ ControlBar
     border-thickness: 1;
 }
 
+DataGrid
+{
+    IDataGridPresentationModel: 
ClassReference("org.apache.flex.html.staticControls.beads.models.DataGridPresentationModel");
+    IBeadView: 
ClassReference("org.apache.flex.html.staticControls.beads.DataGridView");
+    IBeadModel: 
ClassReference("org.apache.flex.html.staticControls.beads.models.DataGridModel");
+
+    background-color: #FFFFFF;;
+}
+
 DropDownList
 {
     IBeadModel: 
ClassReference("org.apache.flex.html.staticControls.beads.models.ArraySelectionModel");

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/FlexJSUIClasses.as 
b/frameworks/as/src/FlexJSUIClasses.as
index 9b94af9..1fe8a69 100644
--- a/frameworks/as/src/FlexJSUIClasses.as
+++ b/frameworks/as/src/FlexJSUIClasses.as
@@ -31,11 +31,14 @@ internal class FlexJSUIClasses
        import 
org.apache.flex.html.staticControls.accessories.PasswordInputBead; 
PasswordInputBead;
        import org.apache.flex.html.staticControls.accessories.TextPromptBead; 
TextPromptBead;
     import org.apache.flex.html.staticControls.beads.AlertView; AlertView;
-    import org.apache.flex.html.staticControls.beads.CheckBoxView; 
CheckBoxView;
+       import org.apache.flex.html.staticControls.beads.ButtonBarView; 
ButtonBarView;
+       import org.apache.flex.html.staticControls.beads.CheckBoxView; 
CheckBoxView;
     import org.apache.flex.html.staticControls.beads.ComboBoxView; 
ComboBoxView;
     import org.apache.flex.html.staticControls.beads.ContainerView; 
ContainerView;
     import 
org.apache.flex.html.staticControls.beads.ControlBarMeasurementBead; 
ControlBarMeasurementBead;
        import org.apache.flex.html.staticControls.beads.CSSTextButtonView; 
CSSTextButtonView;
+       import org.apache.flex.html.staticControls.beads.DataGridColumnView; 
DataGridColumnView;
+       import org.apache.flex.html.staticControls.beads.DataGridView; 
DataGridView;
     import org.apache.flex.html.staticControls.beads.DropDownListView; 
DropDownListView;
        import org.apache.flex.html.staticControls.beads.ImageView; ImageView;
     import org.apache.flex.html.staticControls.beads.ListView; ListView;
@@ -59,6 +62,8 @@ internal class FlexJSUIClasses
     import org.apache.flex.html.staticControls.beads.models.AlertModel; 
AlertModel;
     import 
org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; 
ArraySelectionModel;
     import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; 
ComboBoxModel;
+       import org.apache.flex.html.staticControls.beads.models.DataGridModel; 
DataGridModel;
+       import 
org.apache.flex.html.staticControls.beads.models.DataGridPresentationModel; 
DataGridPresentationModel;
        import org.apache.flex.html.staticControls.beads.models.ImageModel; 
ImageModel;
        import org.apache.flex.html.staticControls.beads.models.PanelModel; 
PanelModel;
        import org.apache.flex.html.staticControls.beads.models.TextModel; 
TextModel;
@@ -74,6 +79,7 @@ internal class FlexJSUIClasses
        import 
org.apache.flex.html.staticControls.beads.controllers.SliderMouseController; 
SliderMouseController;
        import 
org.apache.flex.html.staticControls.beads.controllers.SpinnerMouseController; 
SpinnerMouseController;
     import 
org.apache.flex.html.staticControls.beads.controllers.VScrollBarMouseController;
 VScrollBarMouseController;
+       import 
org.apache.flex.html.staticControls.beads.layouts.ButtonBarLayout; 
ButtonBarLayout;
     import 
org.apache.flex.html.staticControls.beads.layouts.NonVirtualVerticalScrollingLayout;
 NonVirtualVerticalScrollingLayout;  
        import 
org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalScrollingLayout;
 NonVirtualHorizontalScrollingLayout;
     import org.apache.flex.html.staticControls.beads.layouts.VScrollBarLayout; 
VScrollBarLayout;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/core/IDataGridModel.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IDataGridModel.as 
b/frameworks/as/src/org/apache/flex/core/IDataGridModel.as
new file mode 100644
index 0000000..606d938
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IDataGridModel.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+       public interface IDataGridModel extends ISelectionModel
+       {
+               function get labelFields():Object;
+               function set labelFields(value:Object):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/core/IDataGridPresentationModel.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/core/IDataGridPresentationModel.as 
b/frameworks/as/src/org/apache/flex/core/IDataGridPresentationModel.as
new file mode 100644
index 0000000..34a5d84
--- /dev/null
+++ b/frameworks/as/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/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/DataGrid.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/DataGrid.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/DataGrid.as
new file mode 100644
index 0000000..5fb436b
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/DataGrid.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+       import org.apache.flex.core.IDataGridModel;
+       import org.apache.flex.core.UIBase;
+       
+       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;
+               }
+               
+               public function get labelFields():Object
+               {
+                       return IDataGridModel(model).labelFields;
+               }
+               public function set labelFields(value:Object):void
+               {
+                       IDataGridModel(model).labelFields = value;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/ButtonBarView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ButtonBarView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ButtonBarView.as
new file mode 100644
index 0000000..d1c781f
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ButtonBarView.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 org.apache.flex.html.staticControls.beads
+{
+       import flash.display.DisplayObject;
+       import flash.display.DisplayObjectContainer;
+       
+       import org.apache.flex.core.ILayoutParent;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+
+       public class ButtonBarView extends ListView
+       {
+               public function ButtonBarView()
+               {
+                       super();
+               }
+               
+               private var _strand:IStrand;
+               
+               override public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       super.strand = value;
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/CSSTextButtonView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/CSSTextButtonView.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/CSSTextButtonView.as
index bd86ab7..23428d8 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/CSSTextButtonView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/CSSTextButtonView.as
@@ -18,6 +18,7 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.html.staticControls.beads
 {
+       import flash.display.DisplayObject;
        import flash.display.Loader;
        import flash.display.Shape;
        import flash.display.SimpleButton;
@@ -27,12 +28,13 @@ package org.apache.flex.html.staticControls.beads
        import flash.text.TextField;
        import flash.text.TextFieldType;
        
+       import org.apache.flex.core.CSSTextField;
        import org.apache.flex.core.IBeadView;
-    import org.apache.flex.core.CSSTextField;
        import org.apache.flex.core.IStrand;
        import org.apache.flex.core.ITextModel;
        import org.apache.flex.core.ValuesManager;
        import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
        import org.apache.flex.utils.SolidBorderUtil;
 
        public class CSSTextButtonView implements IBeadView
@@ -87,10 +89,16 @@ package org.apache.flex.html.staticControls.beads
             setupSkin(overSprite, overTextField, "hover");
                        setupSkin(downSprite, downTextField, "active");
                        setupSkin(upSprite, upTextField);
+                       
+                       
IEventDispatcher(_strand).addEventListener("widthChanged",sizeChangeHandler);
+                       
IEventDispatcher(_strand).addEventListener("heightChanged",sizeChangeHandler);
                }
        
                private function setupSkin(sprite:Sprite, textField:TextField, 
state:String = null):void
                {
+                       var sw:uint = DisplayObject(_strand).width;
+                       var sh:uint = DisplayObject(_strand).height;
+                       
                        var borderColor:uint;
                        var borderThickness:uint;
                        var borderStyle:String;
@@ -115,7 +123,7 @@ package org.apache.flex.html.staticControls.beads
                        if (borderStyle == "solid")
                        {
                                SolidBorderUtil.drawBorder(sprite.graphics, 
-                                       0, 0, textField.textWidth + 
Number(padding) * 2, textField.textHeight + Number(padding) * 2,
+                                       0, 0, sw, textField.textHeight + 
Number(padding) * 2,
                                        borderColor, backgroundColor, 
borderThickness);
                                textField.y = (sprite.height - 
textField.height) / 2;
                                textField.x = (sprite.width - textField.width) 
/ 2;
@@ -128,13 +136,22 @@ package org.apache.flex.html.staticControls.beads
                                var url:String = backgroundImage as String;
                                loader.load(new URLRequest(url));
                                
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function 
(e:flash.events.Event):void { 
-                                       textField.y = (sprite.height - 
textField.height) / 2;
-                                       textField.x = (sprite.width - 
textField.width) / 2;
+                                       textField.y = (sh - textField.height) / 
2;
+                                       textField.x = (sw - textField.width) / 
2;
                                        updateHitArea();
                                });
                        }
                }
                
+               private function drawSkin() : void
+               {
+                       setupSkin(overSprite, overTextField, "hover");
+                       setupSkin(downSprite, downTextField, "active");
+                       setupSkin(upSprite, upTextField);
+                       
+                       updateHitArea();
+               }
+               
                private function 
textChangeHandler(event:org.apache.flex.events.Event):void
                {
                        text = textModel.text;
@@ -145,6 +162,11 @@ package org.apache.flex.html.staticControls.beads
                        html = textModel.html;
                }
                
+               private function 
sizeChangeHandler(event:org.apache.flex.events.Event):void
+               {
+                       drawSkin();
+               }
+               
                private var upTextField:CSSTextField;
                private var downTextField:CSSTextField;
                private var overTextField:CSSTextField;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as
new file mode 100644
index 0000000..94dc74c
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as
@@ -0,0 +1,56 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.IStrand;
+       
+       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/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridView.as
new file mode 100644
index 0000000..c06b97f
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataGridView.as
@@ -0,0 +1,129 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 flash.display.DisplayObject;
+       import flash.display.DisplayObjectContainer;
+       import flash.display.Shape;
+       
+       import org.apache.flex.core.IBeadModel;
+       import org.apache.flex.core.IDataGridPresentationModel;
+       import org.apache.flex.core.IDataGridModel;
+       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);
+                       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;
+                       
+                       columns = new Array();
+                       for(var i:int=0; i < pm.columnLabels.length; i++) {
+                               var column:List = new SimpleList();
+                               var columnView:DataGridColumnView = new 
DataGridColumnView();
+                               columnView.labelField = 
sharedModel.labelFields[i];
+                               var 
factory:DataItemRendererFactoryForColumnData = new 
DataItemRendererFactoryForColumnData();
+                               columnView.columnIndex = i;
+                               column.addBead(sharedModel);
+                               column.addBead(columnView);
+                               column.addBead(factory);
+                               columnContainer.addElement(column);
+                               columns.push(column);
+                       }
+                       
+                       
IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange);
+                       
IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange);
+                       
+                       handleSizeChange(null); // initial sizing
+               }
+               
+               private function handleSizeChange(event:Event):void
+               {
+                       var sw:Number = DisplayObject(_strand).width;
+                       var sh:Number = DisplayObject(_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
+                       }
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as
new file mode 100644
index 0000000..34b7969
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.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;
+       
+       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)
+                       {
+                               _itemRendererFactory = new 
(ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) 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:ITextItemRenderer = 
itemRendererFactory.createItemRenderer(dataGroup) as ITextItemRenderer;
+                               tf.index = i;
+                               dataGroup.addElement(tf);
+                               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/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/IDataGridView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/IDataGridView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/IDataGridView.as
new file mode 100644
index 0000000..17afcd5
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/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.staticControls.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/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonView.as
index 39fc511..c81782c 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextButtonView.as
@@ -18,15 +18,17 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.html.staticControls.beads
 {
+       import flash.display.DisplayObject;
        import flash.display.Shape;
        import flash.display.SimpleButton;
        import flash.text.TextFieldType;
        
        import org.apache.flex.core.CSSTextField;
-    import org.apache.flex.core.IBeadView;
+       import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IStrand;
        import org.apache.flex.core.ITextModel;
        import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
 
        public class TextButtonView implements IBeadView
        {
@@ -86,6 +88,9 @@ package org.apache.flex.html.staticControls.beads
                                text = textModel.text;
                        if (textModel.html !== null)
                                html = textModel.html;
+                       
+                       
IEventDispatcher(_strand).addEventListener("widthChanged",sizeChangeHandler);
+                       
IEventDispatcher(_strand).addEventListener("heightChanged",sizeChangeHandler);
                }
                        
                private function textChangeHandler(event:Event):void
@@ -98,6 +103,12 @@ package org.apache.flex.html.staticControls.beads
                        html = textModel.html;
                }
                
+               private function sizeChangeHandler(event:Event):void
+               {
+                       upTextField.width = downTextField.width = 
overTextField.width = DisplayObject(_strand).width;
+                       upTextField.height= downTextField.height= 
overTextField.height= DisplayObject(_strand).height;
+               }
+               
                public var upTextField:CSSTextField;
                public var downTextField:CSSTextField;
                public var overTextField:CSSTextField;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/ButtonBarLayout.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/ButtonBarLayout.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/ButtonBarLayout.as
new file mode 100644
index 0000000..c7c0a2d
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/layouts/ButtonBarLayout.as
@@ -0,0 +1,69 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.layouts
+{
+       import flash.display.DisplayObject;
+       import flash.display.DisplayObjectContainer;
+       
+       import org.apache.flex.core.IBeadLayout;
+       import org.apache.flex.core.ILayoutParent;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.ValuesManager;
+       import org.apache.flex.events.Event;
+       import org.apache.flex.events.IEventDispatcher;
+       
+       public class ButtonBarLayout implements IBeadLayout
+       {
+               public function ButtonBarLayout()
+               {
+               }
+               
+               private var _strand:IStrand;
+               
+               public function set strand(value:IStrand):void
+               {
+                       _strand = value;
+                       
IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
+                       
IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
+                       
IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
+               }
+               
+               private function changeHandler(event:Event):void
+               {
+                       var layoutParent:ILayoutParent = 
_strand.getBeadByType(ILayoutParent) as ILayoutParent;
+                       var contentView:DisplayObjectContainer = 
layoutParent.contentView;
+                       
+                       var n:int = contentView.numChildren;
+                       var xpos:Number = 0;
+                       var useWidth:Number = DisplayObject(_strand).width / n;
+                       var useHeight:Number = DisplayObject(_strand).height;
+                       
+                       for (var i:int = 0; i < n; i++)
+                       {
+                               var child:DisplayObject = 
contentView.getChildAt(i);
+                               
+                               child.y = 0;
+                               child.x = xpos;
+                               child.width = useWidth;
+                               child.height = useHeight;
+                               xpos += useWidth;
+                       }
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridModel.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridModel.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridModel.as
new file mode 100644
index 0000000..bc71bff
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridModel.as
@@ -0,0 +1,45 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.models
+{
+       import org.apache.flex.core.IDataGridModel;
+       import org.apache.flex.events.Event;
+       
+       public class DataGridModel extends ArraySelectionModel implements 
IDataGridModel
+       {
+               public function DataGridModel()
+               {
+                       super();
+               }
+               
+               private var _labelFields:Object;
+               public function get labelFields():Object
+               {
+                       return _labelFields;
+               }
+               
+               public function set labelFields(value:Object):void
+               {
+                       if (value != _labelFields) {
+                               _labelFields = value;
+                               dispatchEvent( new Event("labelFieldsChanged"));
+                       }
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as
new file mode 100644
index 0000000..4c19aac
--- /dev/null
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/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.staticControls.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/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/ButtonBarButtonItemRenderer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/ButtonBarButtonItemRenderer.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/ButtonBarButtonItemRenderer.as
index 13c4597..92af717 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/ButtonBarButtonItemRenderer.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/ButtonBarButtonItemRenderer.as
@@ -37,7 +37,6 @@ package org.apache.flex.html.staticControls.supportClasses
                
                private function handleClickEvent(event:Event):void
                {
-                       trace("Click! on index "+this.index);
                        this.dispatchEvent(new Event("selected"));
                }
                

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/7cef6640/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.as
index 9a0a58a..8f2a5cc 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.as
@@ -27,6 +27,36 @@ package org.apache.flex.html.staticControls.supportClasses
                        super();
                }
                
+               private var _columnIndex:int;
+               public function get columnIndex():int
+               {
+                       return _columnIndex;
+               }
+               public function set columnIndex(value:int):void
+               {
+                       _columnIndex = value;
+               }
+               
+               private var _rowIndex:int;
+               public function get rowIndex():int
+               {
+                       return _rowIndex;
+               }
+               public function set rowIndex(value:int):void
+               {
+                       _rowIndex = value;
+               }
+               
+               private var _labelField:String = "label";
+               public function get labelField():String
+               {
+                       return _labelField;
+               }
+               public function set labelField(value:String):void
+               {
+                       _labelField = value;
+               }
+               
                private var background:Sprite;
                
                override public function addedToParent():void

Reply via email to