You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2015/11/20 21:19:29 UTC
[40/41] git commit: [flex-asjs] [refs/heads/core_js_to_as] - Merge
branch 'develop' into core_js_to_as
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
index 97a65db,f3c6205..202806a
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
@@@ -65,11 -63,12 +65,12 @@@ package org.apache.flex.cor
* @productversion FlexJS 0.0
*/
[Event(name="preinitialize", type="org.apache.flex.events.Event")]
-
+
/**
* Dispatched at startup after the initial view has been
- * put on the display list.
+ * put on the display list. This event is sent before
+ * applicationComplete is dispatched.
- *
+ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -91,10 -91,11 +92,11 @@@
* The Application class is the main class and entry point for a FlexJS
* application. This Application class is different than the
* Flex SDK's mx:Application or spark:Application in that it does not contain
- * user interface elements. Those UI elements go in the views. This
- * Application class expects there to be a main model, a controller, and
+ * user interface elements. Those UI elements go in the views (ViewBase). This
- * Application class expects there to be a main model, a controller, and
++ * Application class expects there to be a main model, a controller, and
* an initial view.
-- *
++ *
+ * @see ViewBase
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -104,7 -105,7 +106,7 @@@
{
/**
* Constructor.
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -113,50 -114,57 +115,50 @@@
public function Application()
{
super();
-
- if (stage)
- {
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- // should be opt-in
- //stage.quality = StageQuality.HIGH_16X16_LINEAR;
- }
-
- loaderInfo.addEventListener(flash.events.Event.INIT, initHandler);
++
+ COMPILE::AS3 {
+ if (stage)
+ {
+ stage.align = StageAlign.TOP_LEFT;
+ stage.scaleMode = StageScaleMode.NO_SCALE;
+ // should be opt-in
- //stage.quality = StageQuality.HIGH_16X16_LINEAR;
++ //stage.quality = StageQuality.HIGH_16X16_LINEAR;
+ }
-
++
+ loaderInfo.addEventListener(flash.events.Event.INIT, initHandler);
+ }
}
-
- /**
- * The document property is used to provide
- * a property lookup context for non-display objects.
- * For Application, it points to itself.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public var document:Object = this;
--
++
+ COMPILE::AS3
private function initHandler(event:flash.events.Event):void
{
if (model is IBead) addBead(model as IBead);
if (controller is IBead) addBead(controller as IBead);
--
++
MouseEventConverter.setupAllConverters(stage);
--
++
for each (var bead:IBead in beads)
addBead(bead);
--
++
dispatchEvent(new org.apache.flex.events.Event("beadsAdded"));
if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true)))
initialize();
else
addEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
--
++
}
--
++
+ COMPILE::AS3
private function enterFrameHandler(event:flash.events.Event):void
{
if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true)))
{
removeEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
initialize();
-- }
++ }
}
--
++
/**
* This method gets called when all preinitialize handlers
* no longer call preventDefault();
@@@ -166,12 -174,11 +168,12 @@@
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
+ COMPILE::AS3
protected function initialize():void
{
--
++
MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor);
--
++
dispatchEvent(new org.apache.flex.events.Event("initialize"));
if (initialView)
@@@ -209,7 -216,7 +211,7 @@@
* determine the default values and other values
* for the application. The most common choice
* is org.apache.flex.core.SimpleCSSValuesImpl.
-- *
++ *
* @see org.apache.flex.core.SimpleCSSValuesImpl
*
* @langversion 3.0
@@@ -225,7 -232,7 +227,7 @@@
/**
* The initial view.
-- *
++ *
* @see org.apache.flex.core.ViewBase
*
* @langversion 3.0
@@@ -236,50 -243,22 +238,50 @@@
[Bindable("__NoChangeEvent__")]
public var initialView:ViewBase;
- [Bindable("__NoChangeEvent__")]
/**
* The data model (for the initial view).
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
[Bindable("__NoChangeEvent__")]
+ COMPILE::AS3
public var model:Object;
-
+
+ COMPILE::JS
+ private var _model:Object;
-
++
+ /**
+ * The data model (for the initial view).
- *
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ [Bindable("__NoChangeEvent__")]
+ COMPILE::JS
+ override public function get model():Object
+ {
+ return _model;
+ }
-
++
+ /**
+ * @private
+ */
+ [Bindable("__NoChangeEvent__")]
+ COMPILE::JS
+ override public function set model(value:Object):void
+ {
+ _model = value;
+ }
+
/**
* The controller. The controller typically watches
* the UI for events and updates the model accordingly.
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -291,9 -270,9 +293,9 @@@
* An array of data that describes the MXML attributes
* and tags in an MXML document. This data is usually
* decoded by an MXMLDataInterpreter
-- *
++ *
* @see org.apache.flex.utils.MXMLDataInterpreter
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -308,16 -287,16 +310,16 @@@
* An method called by the compiler's generated
* code to kick off the setting of MXML attribute
* values and instantiation of child tags.
-- *
++ *
* The call has to be made in the generated code
* in order to ensure that the constructors have
* completed first.
-- *
++ *
* @param data The encoded data representing the
* MXML attributes.
-- *
++ *
* @see org.apache.flex.utils.MXMLDataInterpreter
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -327,25 -306,24 +329,25 @@@
{
MXMLDataInterpreter.generateMXMLProperties(this, data);
}
--
++
/**
* The array property that is used to add additional
* beads to an MXML tag. From ActionScript, just
* call addBead directly.
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
public var beads:Array;
--
++
+ COMPILE::AS3
private var _beads:Vector.<IBead>;
--
++
/**
* @copy org.apache.flex.core.IStrand#addBead()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -359,10 -336,10 +361,10 @@@
_beads.push(bead);
bead.strand = this;
}
--
++
/**
* @copy org.apache.flex.core.IStrand#getBeadByType()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -378,17 -354,16 +380,17 @@@
}
return null;
}
--
++
/**
* @copy org.apache.flex.core.IStrand#removeBead()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public function removeBead(value:IBead):IBead
+ COMPILE::AS3
- public function removeBead(value:IBead):IBead
++ public function removeBead(value:IBead):IBead
{
var n:int = _beads.length;
for (var i:int = 0; i < n; i++)
@@@ -402,10 -377,33 +404,10 @@@
}
return null;
}
-
- private var _info:Object;
-
- /**
- * An Object containing information generated
- * by the compiler that is useful at startup time.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function info():Object
- {
- if (!_info)
- {
- var mainClassName:String = getQualifiedClassName(this);
- var initClassName:String = "_" + mainClassName + "_FlexInit";
- var c:Class = ApplicationDomain.currentDomain.getDefinition(initClassName) as Class;
- _info = c.info();
- }
- return _info;
- }
--
++
/**
* @copy org.apache.flex.core.IParent#addElement()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -413,24 -411,18 +415,24 @@@
*/
public function addElement(c:Object, dispatchEvent:Boolean = true):void
{
- if (c is IUIBase)
- {
- addChild(IUIBase(c).element as DisplayObject);
- IUIBase(c).addedToParent();
+ COMPILE::AS3 {
+ if (c is IUIBase)
+ {
+ addChild(IUIBase(c).element as DisplayObject);
+ IUIBase(c).addedToParent();
+ }
+ else
+ addChild(c as DisplayObject);
+ }
+ COMPILE::JS {
+ this.element.appendChild(c.element);
+ c.addedToParent();
}
- else
- addChild(c as DisplayObject);
}
--
++
/**
* @copy org.apache.flex.core.IParent#addElementAt()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -463,7 -441,7 +465,7 @@@
/**
* @copy org.apache.flex.core.IParent#getElementAt()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -471,18 -449,12 +473,18 @@@
*/
public function getElementAt(index:int):Object
{
- return getChildAt(index);
+ COMPILE::AS3 {
+ return getChildAt(index);
+ }
+ COMPILE::JS {
+ var children:NodeList = internalChildren();
+ return children[index].flexjs_wrapper;
+ }
}
--
++
/**
* @copy org.apache.flex.core.IParent#getElementIndex()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -490,27 -462,15 +492,27 @@@
*/
public function getElementIndex(c:Object):int
{
- if (c is IUIBase)
- return getChildIndex(IUIBase(c).element as DisplayObject);
+ COMPILE::AS3 {
+ if (c is IUIBase)
+ return getChildIndex(IUIBase(c).element as DisplayObject);
-
+
- return getChildIndex(c as DisplayObject);
+ return getChildIndex(c as DisplayObject);
+ }
+ COMPILE::JS {
+ var children:NodeList = internalChildren();
+ var n:int = children.length;
+ for (var i:int = 0; i < n; i++)
+ {
+ if (children[i] == c.element)
+ return i;
+ }
+ return -1;
+ }
}
--
++
/**
* @copy org.apache.flex.core.IParent#removeElement()
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -518,22 -478,17 +520,22 @@@
*/
public function removeElement(c:Object, dispatchEvent:Boolean = true):void
{
- if (c is IUIBase)
- {
- removeChild(IUIBase(c).element as DisplayObject);
+ COMPILE::AS3 {
+ if (c is IUIBase)
+ {
+ removeChild(IUIBase(c).element as DisplayObject);
+ }
+ else
+ removeChild(c as DisplayObject);
+ }
+ COMPILE::JS {
+ element.removeChild(c.element);
}
- else
- removeChild(c as DisplayObject);
}
--
++
/**
* @copy org.apache.flex.core.IParent#numElements
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -541,48 -496,7 +543,48 @@@
*/
public function get numElements():int
{
- return numChildren;
+ COMPILE::AS3 {
+ return numChildren;
+ }
+ COMPILE::JS {
+ var children:NodeList = internalChildren();
+ return children.length;
+ }
}
-
++
+ /**
+ * @return {Object} The array of children.
+ */
+ COMPILE::JS
+ protected function internalChildren():NodeList
+ {
+ return element.childNodes;
+ };
-
-
++
++
+
+ /**
- * @flexjsignorecoercion org.apache.flex.core.IBead
++ * @flexjsignorecoercion org.apache.flex.core.IBead
+ */
+ COMPILE::JS
- public function start():void
++ public function start():void
+ {
+ element = document.getElementsByTagName('body')[0];
+ element.flexjs_wrapper = this;
+ element.className = 'Application';
-
++
+ MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor);
-
++
+ dispatchEvent('initialize');
-
++
+ if (model is IBead) addBead(model as IBead);
+ if (controller is IBead) addBead(controller as IBead);
-
++
+ initialView.applicationModel = model;
+ addElement(initialView);
-
++
+ dispatchEvent('viewChanged');
+ };
+
}
-}
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/src/org/apache/flex/core/CSSTextField.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Core/as/src/org/apache/flex/core/CSSTextField.as
index ce90950,41ff87c..99ae97e
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/CSSTextField.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/CSSTextField.as
@@@ -18,18 -18,18 +18,20 @@@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.core
{
-- import flash.text.TextField;
-- import flash.text.TextFieldAutoSize;
-- import flash.text.TextFormat;
--
++ COMPILE::AS3 {
++ import flash.text.TextField;
++ import flash.text.TextFieldAutoSize;
++ import flash.text.TextFormat;
++ }
++
import org.apache.flex.core.ValuesManager;
import org.apache.flex.events.Event;
import org.apache.flex.utils.CSSUtils;
--
++
/**
* The CSSTextField class implements CSS text styles in a TextField.
* Not every CSS text style is currently supported.
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -40,7 -39,7 +42,7 @@@
{
/**
* Constructor.
-- *
++ *
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
@@@ -50,7 -49,7 +52,7 @@@
{
super();
}
--
++
/**
* @private
* The styleParent property is set if the CSSTextField
@@@ -63,7 -62,7 +65,7 @@@
* @productversion FlexJS 0.0
*/
public var styleParent:Object;
--
++
/**
* @private
* The CSS pseudo-state for lookups.
@@@ -74,7 -73,7 +76,7 @@@
* @productversion FlexJS 0.0
*/
public var styleState:String;
--
++
/**
* @private
* The parentDrawsBackground property is set if the CSSTextField
@@@ -86,7 -85,7 +88,7 @@@
* @productversion FlexJS 0.0
*/
public var parentDrawsBackground:Boolean;
--
++
/**
* @private
* The parentHandlesPadding property is set if the CSSTextField
@@@ -98,7 -97,7 +100,7 @@@
* @productversion FlexJS 0.0
*/
public var parentHandlesPadding:Boolean;
--
++
/**
* @private
*/
@@@ -108,7 -107,7 +110,7 @@@
if (styleParent)
sp = styleParent;
sp.addEventListener("classNameChanged", updateStyles);
--
++
var tf: TextFormat = new TextFormat();
tf.font = ValuesManager.valuesImpl.getValue(sp, "fontFamily", styleState) as String;
tf.size = ValuesManager.valuesImpl.getValue(sp, "fontSize", styleState);
@@@ -131,7 -130,7 +133,7 @@@
else if (align == "right")
{
tf.align = "right";
-- autoSize = TextFieldAutoSize.NONE;
++ autoSize = TextFieldAutoSize.NONE;
}
if (!parentDrawsBackground)
{
@@@ -145,12 -144,12 +147,17 @@@
defaultTextFormat = tf;
super.text = value;
}
--
++
private function updateStyles(event:Event):void
{
// force styles to be re-calculated
this.text = text;
}
--
++
++ }
++
++ COMPILE::JS
++ public class CSSTextField extends TextField
++ {
}
-}
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/src/org/apache/flex/core/IDataGridModel.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Core/as/src/org/apache/flex/core/IDataGridModel.as
index e0948da,0000000..5ac0584
mode 100644,000000..100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/IDataGridModel.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IDataGridModel.as
@@@ -1,44 -1,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.core
+{
+ /**
+ * The IDataGridModel interface describes the minimum set of properties
+ * available to an DataGrid control. More sophisticated DataGrid controls
+ * could have models that extend IDataGridModel.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public interface IDataGridModel extends ISelectionModel
+ {
+ /**
+ * The set of DataGridColumns.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ function get columns():Array;
+ function set columns(value:Array):void;
+ }
- }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/src/org/apache/flex/core/IListPresentationModel.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Core/as/src/org/apache/flex/core/IListPresentationModel.as
index 9b3a35e,8166c59..445c3b4
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/IListPresentationModel.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IListPresentationModel.as
@@@ -39,5 -39,16 +39,16 @@@ package org.apache.flex.cor
*/
function get rowHeight():Number;
function set rowHeight(value:Number):void;
+
+ /**
+ * The distance each row should be separated from the row above.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ function get separatorThickness():Number;
+ function set separatorThickness(value:Number):void;
}
-}
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/src/org/apache/flex/core/IViewport.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Core/as/src/org/apache/flex/core/IViewport.as
index e87a1d6,d84addc..a274f52
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/IViewport.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IViewport.as
@@@ -19,42 -19,65 +19,62 @@@
package org.apache.flex.core
{
import org.apache.flex.geom.Size;
-
-
- /**
- * A Viewport is the area of a Container set aside for displaying
- * content and any scrolling controls.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public interface IViewport extends IBead
++
+ /**
+ * A Viewport is a window onto an area of content. A viewport is given space
+ * in which to operate by a View bead. Viewports can control their area which
+ * is specified by the IViewportModel, adding scrollbars or whatever scrolling
+ * mechanism they want.
+ */
+ public interface IViewport extends IBead
{
/**
* Get the actual parent of the container's content.
- *
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
*/
function get contentView():IUIBase;
--
++
/**
* Sets the upper left position of the viewport
* @param x The left position.
* @param y The top position.
- *
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
*/
function setPosition(x:Number, y:Number):void;
--
++
/**
* Size the content area based on any visible scrolling controls and
* the given width and height. If width and/or height is NaN
* then that dimension is being sized to content.
- *
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
*/
function layoutViewportBeforeContentLayout(width:Number, height:Number):void;
--
++
/**
* This method is invoked after layout is complete. If width and/or height is
* sized to content, the viewport should determine that size and set the
* content area size appropriately, and display any scrolling controls
* before returning the resulting size of the viewport (which means the
* area used up by both content area and scrolling controls).
- *
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
*/
function layoutViewportAfterContentLayout():Size;
--
++
}
-}
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/src/org/apache/flex/core/ItemRendererClassFactory.as
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/as/tests/build.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/Core/asjs/src/CoreASJSClasses.as
----------------------------------------------------------------------
diff --cc frameworks/projects/Core/asjs/src/CoreASJSClasses.as
index 0c5e1a8,e385ade..1eeb7bd
--- a/frameworks/projects/Core/asjs/src/CoreASJSClasses.as
+++ b/frameworks/projects/Core/asjs/src/CoreASJSClasses.as
@@@ -26,8 -27,7 +26,7 @@@ packag
*/
internal class CoreASJSClasses
{
- /*import org.apache.flex.core.IDataGridLayout; IDataGridLayout;
-- import org.apache.flex.core.IDataGridModel; IDataGridModel;
++ /*import org.apache.flex.core.IDataGridModel; IDataGridModel;
import org.apache.flex.core.IDataGridPresentationModel; IDataGridPresentationModel;
import org.apache.flex.core.IDateChooserModel; IDateChooserModel;
import org.apache.flex.core.ParentDocumentBead; ParentDocumentBead;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/HTMLClasses.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/HTMLClasses.as
index 5e90559,5bd520c..b863088
--- a/frameworks/projects/HTML/as/src/HTMLClasses.as
+++ b/frameworks/projects/HTML/as/src/HTMLClasses.as
@@@ -140,30 -101,17 +140,30 @@@ internal class HTMLClasse
import org.apache.flex.html.beads.layouts.TileLayout; TileLayout;
import org.apache.flex.html.beads.TextItemRendererFactoryForArrayData; TextItemRendererFactoryForArrayData;
import org.apache.flex.html.beads.DataItemRendererFactoryForArrayData; DataItemRendererFactoryForArrayData;
++ import org.apache.flex.html.beads.DataItemRendererFactoryForArrayList; DataItemRendererFactoryForArrayList;
import org.apache.flex.html.supportClasses.DataGroup; DataGroup;
import org.apache.flex.html.supportClasses.Viewport; Viewport;
import org.apache.flex.html.supportClasses.ScrollingViewport; ScrollingViewport;
- import org.apache.flex.events.CustomEvent; CustomEvent;
- import org.apache.flex.events.Event; Event;
- import org.apache.flex.events.MouseEvent; MouseEvent;
- import org.apache.flex.events.ValueEvent; ValueEvent;
- import org.apache.flex.utils.EffectTimer; EffectTimer;
- import org.apache.flex.utils.Timer; Timer;
- import org.apache.flex.utils.UIUtils; UIUtils;
- import org.apache.flex.events.utils.MouseUtils; MouseUtils;
+
+ import org.apache.flex.html.beads.DataGridColumnView; DataGridColumnView;
+ import org.apache.flex.html.beads.DataGridView; DataGridView;
+ import org.apache.flex.html.beads.DateChooserView; DateChooserView;
+ import org.apache.flex.html.beads.DateFieldView; DateFieldView;
- import org.apache.flex.html.beads.layouts.DataGridLayout; DataGridLayout;
+ import org.apache.flex.html.beads.layouts.FlexibleFirstChildHorizontalLayout; FlexibleFirstChildHorizontalLayout;
+ import org.apache.flex.html.beads.models.DataGridModel; DataGridModel;
+ import org.apache.flex.html.beads.models.DateChooserModel; DateChooserModel;
+ import org.apache.flex.html.beads.models.DataGridPresentationModel; DataGridPresentationModel;
+ import org.apache.flex.html.beads.controllers.DateChooserMouseController; DateChooserMouseController;
+ import org.apache.flex.html.beads.controllers.DateFieldMouseController; DateFieldMouseController;
+ import org.apache.flex.html.supportClasses.DataGridColumn; DataGridColumn;
+ import org.apache.flex.html.supportClasses.DateChooserButton; DateChooserButton;
+ import org.apache.flex.html.supportClasses.GraphicsItemRenderer; GraphicsItemRenderer;
+
+ import org.apache.flex.html.MXMLBeadViewBase; MXMLBeadViewBase;
+ import org.apache.flex.html.beads.TitleBarView; TitleBarView;
+ import org.apache.flex.html.beads.TitleBarMeasurementBead; TitleBarMeasurementBead;
+
+
}
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/Container.as
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/DataGrid.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/DataGrid.as
index 4aa38d2,0000000..8cba078
mode 100644,000000..100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/DataGrid.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/DataGrid.as
@@@ -1,144 -1,0 +1,164 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import org.apache.flex.core.IBead;
+ import org.apache.flex.core.IDataGridModel;
+ import org.apache.flex.core.IDataGridPresentationModel;
+ import org.apache.flex.core.UIBase;
+ import org.apache.flex.html.beads.models.DataGridPresentationModel;
+
+ [Event(name="change", type="org.apache.flex.events.Event")]
+
+ /**
+ * The DataGrid class displays a collection of data using columns and rows. Each
+ * column represents a specific field in the data set; each row represents a specific
+ * datum. The DataGrid is a composite component built with a org.apache.flex.html.ButtonBar
+ * for the column headers and a org.apache.flex.html.List for each column. The DataGrid's
+ * view bead (usually org.apache.flex.html.beads.DataGridView) constructs these parts while
+ * itemRenderer factories contruct the elements to display the data in each cell.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class DataGrid extends UIBase
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function DataGrid()
+ {
+ super();
+ }
+
+ /**
+ * The array of org.apache.flex.html.supportClasses.DataGridColumns used to
+ * describe each column.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get columns():Array
+ {
+ return IDataGridModel(model).columns;
+ }
+ public function set columns(value:Array):void
+ {
+ IDataGridModel(model).columns = value;
+ }
+
+ /**
+ * The object used to provide data to the org.apache.flex.html.DataGrid.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get dataProvider():Object
+ {
+ return IDataGridModel(model).dataProvider;
+ }
+ public function set dataProvider(value:Object):void
+ {
+ IDataGridModel(model).dataProvider = value;
+ }
+
+ /**
+ * The currently selected row.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get selectedIndex():int
+ {
+ return IDataGridModel(model).selectedIndex;
+ }
+
+ /**
+ * The DataGrid's presentation model
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get presentationModel():IDataGridPresentationModel
+ {
+ var beadMod:IBead = getBeadByType(IDataGridPresentationModel);
+ var presModel:IDataGridPresentationModel;
+
+ if (beadMod == null) {
+ presModel = new DataGridPresentationModel();
+ addBead(presModel);
+ } else {
+ presModel = beadMod as IDataGridPresentationModel;
+ }
+ return presModel;
+ }
+
+ /**
+ * The default height of each cell in every column
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get rowHeight():Number
+ {
+ return presentationModel.rowHeight;
+ }
+ public function set rowHeight(value:Number):void
+ {
+ presentationModel.rowHeight = value;
+ }
++
++ /**
++ * @private
++ * The DataGrid needs to know whenever its size is being changed so the columns can be
++ * be aligned properly, so the noEvent value must always be false.
++ */
++ override public function setWidth(value:Number, noEvent:Boolean=false):void
++ {
++ super.setWidth(value,false);
++ }
++
++ /**
++ * @private
++ * The DataGrid needs to know whenever its size is being changed so the columns can be
++ * be aligned properly, so the noEvent value must always be false.
++ */
++ override public function setHeight(value:Number, noEvent:Boolean=false):void
++ {
++ super.setHeight(value,false);
++ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ButtonBarView.as
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridLinesBead.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridLinesBead.as
index 0000000,0000000..b4e5b1d
new file mode 100644
--- /dev/null
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridLinesBead.as
@@@ -1,0 -1,0 +1,199 @@@
++////////////////////////////////////////////////////////////////////////////////
++//
++// 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.beads
++{
++ import org.apache.flex.collections.ArrayList;
++ import org.apache.flex.core.IBead;
++ import org.apache.flex.core.IBeadModel;
++ import org.apache.flex.core.IDataGridModel;
++ import org.apache.flex.core.ILayoutHost;
++ import org.apache.flex.core.IParentIUIBase;
++ import org.apache.flex.core.IStrand;
++ import org.apache.flex.core.UIBase;
++ import org.apache.flex.core.graphics.GraphicsContainer;
++ import org.apache.flex.core.graphics.IStroke;
++ import org.apache.flex.core.graphics.SolidColor;
++ import org.apache.flex.core.graphics.SolidColorStroke;
++ import org.apache.flex.events.Event;
++ import org.apache.flex.events.IEventDispatcher;
++ import org.apache.flex.html.beads.models.DataGridPresentationModel;
++ import org.apache.flex.html.supportClasses.DataGridColumn;
++
++ /**
++ * The DataGridLinesBead is an add on bead for the DataGrid. This bead
++ * adds horizontal and vertical grid lines to a DataGrid. The size and
++ * color of the lines is specified by the stroke property (defaults to
++ * a thin dark line).
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public class DataGridLinesBead implements IBead
++ {
++ /**
++ * Constructor.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function DataGridLinesBead()
++ {
++ // Set default separator line stroke.
++ var lineStroke:SolidColorStroke = new SolidColorStroke();
++ lineStroke.color = 0x333333;
++ lineStroke.alpha = 1.0;
++ lineStroke.weight = 1;
++ stroke = lineStroke;
++ }
++
++ private var _strand:IStrand;
++
++ /**
++ * @copy org.apache.flex.core.UIBase#strand
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function set strand(value:IStrand):void
++ {
++ _strand = value;
++
++ _overlay = new GraphicsContainer();
++
++ IEventDispatcher(_strand).addEventListener("beadsAdded", handleBeadsAdded);
++ }
++
++ private var _stroke:IStroke;
++
++ /**
++ * Describes the line style used to separate the rows and columns.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get stroke():IStroke
++ {
++ return _stroke;
++ }
++ public function set stroke(value:IStroke):void
++ {
++ _stroke = value;
++ }
++
++ private var _overlay:GraphicsContainer;
++ private var _area:UIBase;
++
++ /**
++ * Invoked when all of the beads have been added to the DataGrid. This
++ * function seeks the Container that parents the lists that are the DataGrid's
++ * columns. An overlay GraphicContainer is added to this Container so that the
++ * grid lines will scroll with the rows.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ private function handleBeadsAdded(event:Event):void
++ {
++ var host:UIBase = _strand as UIBase;
++ var n:int = host.numElements;
++ for (var i:int=0; i < n; i++) {
++ var child:UIBase = host.getElementAt(i) as UIBase;
++ if (child.id == "dataGridListArea") {
++ _area = child;
++ _area.addElement(_overlay);
++ break;
++ }
++ }
++
++ // Now set up listeners to handle changes in the size of the DataGrid.
++ IEventDispatcher(_strand).addEventListener("sizeChanged", drawLines);
++ IEventDispatcher(_strand).addEventListener("widthChanged", drawLines);
++ IEventDispatcher(_strand).addEventListener("heightChanged", drawLines);
++
++ // Also set up a listener on the model to know when the dataProvider has
++ // changed which might affect the number of rows/columns and thus the
++ // grid lines.
++ var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel;
++ IEventDispatcher(model).addEventListener("dataProviderChanged", drawLines);
++ }
++
++ /**
++ * This event handler is invoked whenever something happens to the DataGrid. This
++ * function draws the lines either using a default stroke or the one specified by
++ * the stroke property.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ private function drawLines(event:Event):void
++ {
++ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
++ var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel;
++ var layoutParent:ILayoutHost = _area.getBeadByType(ILayoutHost) as ILayoutHost;
++ var contentView:IParentIUIBase = layoutParent.contentView as IParentIUIBase;
++
++ var columns:Array = sharedModel.columns;
++ var arrayList:ArrayList = sharedModel.dataProvider as ArrayList;
++ var rowHeight:Number = presentationModel.rowHeight;
++
++ var totalHeight:Number = arrayList.length * rowHeight;
++ var columnWidth:Number = _area.width / columns.length;
++
++ // translate the stroke to a fill since rectangles are used for the grid
++ // lines and not lines.
++ var lineFill:SolidColor = new SolidColor();
++ var weight:Number = 1;
++ lineFill.color = (stroke as SolidColorStroke).color;
++ lineFill.alpha = (stroke as SolidColorStroke).alpha;
++ weight = (stroke as SolidColorStroke).weight;
++ _overlay.fill = lineFill;
++
++ columnWidth = (columns[0] as DataGridColumn).columnWidth;
++ var xpos:Number = isNaN(columnWidth) ? _area.width / columns.length : columnWidth;
++
++ _overlay.removeAllElements();
++
++ // draw the verticals
++ for (var i:int=1; i < columns.length; i++) {
++ _overlay.drawRect(xpos, 0, weight, totalHeight);
++ columnWidth = (columns[i] as DataGridColumn).columnWidth;
++ xpos += isNaN(columnWidth) ? _area.width / columns.length : columnWidth;
++ }
++
++ var n:int = arrayList.length;
++
++ // draw the horizontals
++ for (i=1; i < n+1; i++) {
++ _overlay.drawRect(0, i*rowHeight, _area.width, weight);
++ }
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridView.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridView.as
index d578a6e,0000000..d1fbe61
mode 100644,000000..100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataGridView.as
@@@ -1,251 -1,0 +1,318 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.beads
- {
- import org.apache.flex.core.BeadViewBase;
- import org.apache.flex.core.IBead;
- import org.apache.flex.core.IBeadModel;
- import org.apache.flex.core.IDataGridLayout;
- import org.apache.flex.core.IDataGridModel;
- import org.apache.flex.core.ISelectionModel;
- import org.apache.flex.core.IStrand;
- import org.apache.flex.core.UIBase;
- import org.apache.flex.events.Event;
- import org.apache.flex.events.IEventDispatcher;
- import org.apache.flex.html.ButtonBar;
- import org.apache.flex.html.Container;
- import org.apache.flex.html.List;
- import org.apache.flex.html.beads.layouts.ButtonBarLayout;
- import org.apache.flex.html.beads.layouts.DataGridLayout;
- import org.apache.flex.html.beads.models.ArraySelectionModel;
- import org.apache.flex.html.beads.models.DataGridPresentationModel;
- import org.apache.flex.html.supportClasses.DataGridColumn;
++{
++ import org.apache.flex.core.IBead;
++ import org.apache.flex.core.IBeadModel;
++ import org.apache.flex.core.IBeadView;
++ import org.apache.flex.core.IDataGridModel;
++ import org.apache.flex.core.ISelectableItemRenderer;
++ import org.apache.flex.core.ISelectionModel;
++ import org.apache.flex.core.IStrand;
++ import org.apache.flex.core.IUIBase;
++ 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.ButtonBar;
++ import org.apache.flex.html.Container;
++ import org.apache.flex.html.List;
++ import org.apache.flex.html.beads.layouts.ButtonBarLayout;
++ import org.apache.flex.html.beads.layouts.VerticalLayout;
++ import org.apache.flex.html.beads.models.ArraySelectionModel;
++ import org.apache.flex.html.beads.models.DataGridPresentationModel;
++ import org.apache.flex.html.supportClasses.DataGridColumn;
++ import org.apache.flex.html.supportClasses.ScrollingViewport;
+ import org.apache.flex.html.supportClasses.Viewport;
-
++
+ /**
- * The DataGridView class is the visual bead for the org.apache.flex.html.DataGrid.
- * This class constructs the items that make the DataGrid: Lists for each column and a
- * org.apache.flex.html.ButtonBar for the column headers.
- *
++ * The DataGridView class is the visual bead for the org.apache.flex.html.DataGrid.
++ * This class constructs the items that make the DataGrid: Lists for each column and a
++ * org.apache.flex.html.ButtonBar for the column headers.
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
- public class DataGridView extends BeadViewBase implements IDataGridView
++ public class DataGridView implements IBeadView
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ 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;
++ private var _header:ButtonBar;
++ private var _listArea:Container;
++ private var _lists:Array;
++
+ /**
- * The array of org.apache.flex.html.supportClasses.DataGridColumn instances.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
++ * @private
+ */
- public function getColumnLists():Array
++ public function get host():IUIBase
+ {
- return columns;
++ return _strand as IUIBase;
+ }
-
- private var _strand:IStrand;
-
++
+ /**
+ * @copy org.apache.flex.core.IBead#strand
- *
++ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
- override public function set strand(value:IStrand):void
++ public function set strand(value:IStrand):void
+ {
+ _strand = value;
- super.strand = value;
-
- IEventDispatcher(_strand).addEventListener("sizeChanged", onSizeChanged);
- IEventDispatcher(_strand).addEventListener("widthChanged", onSizeChanged);
- IEventDispatcher(_strand).addEventListener("heightChanged", onSizeChanged);
-
++
++ var host:UIBase = value as UIBase;
++ host.addEventListener("widthChanged", handleSizeChanges);
++ host.addEventListener("heightChanged", handleSizeChanges);
++
++ _header = new ButtonBar();
++ _header.id = "dataGridHeader";
++
++ var scrollPort:ScrollingViewport = new ScrollingViewport();
++// scrollPort.showsHorizontalScrollBar = false;
++
++ _listArea = new Container();
++ _listArea.id = "dataGridListArea";
++ _listArea.className = "DataGridListArea";
++ _listArea.addBead(scrollPort);
++
++ finishSetup(null);
++ }
++
++ /**
++ * @private
++ */
++ private function finishSetup(event:Event):void
++ {
++ var host:UIBase = _strand as UIBase;
++
+ // see if there is a presentation model already in place. if not, add one.
- var modBead:IBead = _strand.getBeadByType(DataGridPresentationModel);
- var presentationModel:DataGridPresentationModel;
- if (modBead == null) {
++ var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel;
++ if (presentationModel == null) {
+ presentationModel = new DataGridPresentationModel();
+ _strand.addBead(presentationModel);
+ }
- else {
- presentationModel = modBead as DataGridPresentationModel;
- }
-
++
+ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
- IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",onDataProviderChanged);
-
- // create an array of columnLabels for use by the ButtonBar/DataGrid header.
++ IEventDispatcher(sharedModel).addEventListener("dataProviderChanged",handleDataProviderChanged);
++
+ var columnLabels:Array = new Array();
++ var buttonWidths:Array = new Array();
++
+ for(var i:int=0; i < sharedModel.columns.length; i++) {
+ var dgc:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
+ columnLabels.push(dgc.label);
++ if (!isNaN(dgc.columnWidth)) buttonWidths.push(dgc.columnWidth);
+ }
++
+ var bblayout:ButtonBarLayout = new ButtonBarLayout();
-
- buttonBarModel = new ArraySelectionModel();
++ if (buttonWidths.length == sharedModel.columns.length) {
++ bblayout.buttonWidths = buttonWidths;
++ }
++
++ var buttonBarModel:ArraySelectionModel = new ArraySelectionModel();
+ buttonBarModel.dataProvider = columnLabels;
-
- buttonBar = new ButtonBar();
- buttonBar.addBead(buttonBarModel);
- buttonBar.addBead(bblayout);
- buttonBar.addBead(new Viewport());
- buttonBar.height = 25;
- buttonBar.width = UIBase(_strand).width;
- UIBase(_strand).addElement(buttonBar);
-
- // Create a List for each column, storing a reference to each List in
- // the columns property.
- columns = new Array();
- for(i=0; i < sharedModel.columns.length; i++)
- {
- // Each list shares the same dataProvider but needs its own model to
- // keep track of its own data.
- var listModel:ISelectionModel = new ArraySelectionModel();
- listModel.dataProvider = sharedModel.dataProvider;
-
- var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
-
- var list:List = new List();
- list.addBead(listModel);
- list.itemRenderer = dataGridColumn.itemRenderer;
- list.labelField = dataGridColumn.dataField;
- list.addBead(presentationModel);
-
- var colWidth:Number = dataGridColumn.columnWidth;
- if (!isNaN(colWidth)) list.width = colWidth;
+
- UIBase(_strand).addElement(list);
- columns.push(list);
- list.addEventListener('change',columnListChangeHandler);
- list.addEventListener('rollover',columnListRollOverHandler);
- list.addEventListener('layoutComplete',forwardEvent);
++ _header.addBead(buttonBarModel);
++ _header.addBead(bblayout);
++ _header.addBead(new Viewport());
++ host.addElement(_header);
++
++ host.addElement(_listArea);
++
++ // do we know what the size is? If not, wait to be sized
++
++ if (host.isHeightSizedToContent() || host.isWidthSizedToContent()) {
++ host.addEventListener("sizeChanged", handleSizeChanges);
++ }
++
++ // else size now
++ else {
++ handleDataProviderChanged(event);
+ }
-
- // TODO: allow a developer to specify their own DataGridLayout
- // possibly by seeing if a bead already exists
-
- onSizeChanged(null);
- IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
+ }
-
- private function onSizeChanged(event:Event):void
++
++ /**
++ * @private
++ */
++ private function handleSizeChanges(event:Event):void
+ {
- var bead:IBead = _strand.getBeadByType(IDataGridLayout);
- var layout:IDataGridLayout;
- if (bead == null) {
- // NOTE: the following line will not cross-compile correctly into JavaScript
- // so it has been commented and the class hard-coded.
- //layout = new ValuesManager.valuesImpl.getValue(_strand, "iBeadLayout")) as IDataGridLayout;
- layout = new DataGridLayout();
- _strand.addBead(layout);
- } else {
- layout = bead as IDataGridLayout;
++ var useWidth:Number = _listArea.width;
++ var useHeight:Number = _listArea.height;
++
++ if (host.width > 0) {
++ useWidth = host.width;
++ }
++
++ _header.x = 0;
++ _header.y = 0;
++ _header.width = useWidth;
++ _header.height = 25;
++
++ if (host.height > 0) {
++ useHeight = host.height - _header.height;
++ }
++
++ _listArea.x = 0;
++ _listArea.y = 26;
++ _listArea.width = useWidth;
++ _listArea.height = useHeight;
++
++ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
++
++ if (_lists != null && _lists.length > 0) {
++ var xpos:Number = 0;
++ var listWidth:Number = host.width / _lists.length;
++ for (var i:int=0; i < _lists.length; i++) {
++ var list:List = _lists[i] as List;
++ list.x = xpos;
++ list.y = 0;
++
++ var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
++ var colWidth:Number = dataGridColumn.columnWidth;
++ if (!isNaN(colWidth)) list.width = colWidth;
++ else list.width = listWidth;
++
++ xpos += list.width;
++ }
+ }
- layout.header = buttonBar;
- layout.columns = columns;
- layout.layout();
+ }
-
++
+ /**
+ * @private
- * When the dataProvider is changed for the DataGrid, this updates each List (column)
- * with the new (or changed) dataProvider.
+ */
- private function onDataProviderChanged(event:Event):void
++ private function handleDataProviderChanged(event:Event):void
+ {
+ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
-
- for (var i:int=0; i < columns.length; i++)
++
++ if (_lists == null || _lists.length == 0) {
++ createLists();
++ }
++
++ for (var i:int=0; i < _lists.length; i++)
+ {
- var list:List = columns[i] as List;
++ var list:List = _lists[i] as List;
+ var listModel:ISelectionModel = list.getBeadByType(IBeadModel) as ISelectionModel;
+ listModel.dataProvider = sharedModel.dataProvider;
+ }
++
++ handleSizeChanges(event);
+ }
-
++
+ /**
+ * @private
+ */
- private function columnListChangeHandler(event:Event):void
++ private function handleColumnListChange(event:Event):void
+ {
+ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
+ var list:List = event.target as List;
+ sharedModel.selectedIndex = list.selectedIndex;
-
- for(var i:int=0; i < columns.length; i++) {
- if (list != columns[i]) {
- var otherList:List = columns[i] as List;
++
++ for(var i:int=0; i < _lists.length; i++) {
++ if (list != _lists[i]) {
++ var otherList:List = _lists[i] as List;
+ otherList.selectedIndex = list.selectedIndex;
+ }
+ }
-
++
+ IEventDispatcher(_strand).dispatchEvent(new Event('change'));
+ }
-
++
+ /**
+ * @private
+ */
- private function columnListRollOverHandler(event:Event):void
++ private function handleColumnListRollOver(event:Event):void
+ {
- var list:List = event.target as List;
++ var itemRenderer:ISelectableItemRenderer = event.target as ISelectableItemRenderer;
++ var list:List = event.currentTarget as List;
+ if (list == null) return;
- for(var i:int=0; i < columns.length; i++) {
- if (list != columns[i]) {
- var otherList:List = columns[i] as List;
- otherList.rollOverIndex = list.rollOverIndex;
++ for(var i:int=0; i < _lists.length; i++) {
++ if (list != _lists[i]) {
++ var otherList:List = _lists[i] as List;
++ otherList.rollOverIndex = itemRenderer.index;
+ }
+ }
-
++
++ IEventDispatcher(_strand).dispatchEvent(new Event('rollOver'));
++ }
++
++ /**
++ * @private
++ */
++ private function handleColumnListRollOut(event:Event):void
++ {
++ for(var i:int=0; i < _lists.length; i++) {
++ var otherList:List = _lists[i] as List;
++ otherList.rollOverIndex = -1;
++ }
++
+ IEventDispatcher(_strand).dispatchEvent(new Event('rollOver'));
+ }
-
++
+ /**
+ * @private
+ */
- private function forwardEvent(event:Event):void
++ private function createLists():void
+ {
- IEventDispatcher(_strand).dispatchEvent(event);
++ var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel;
++ var presentationModel:DataGridPresentationModel = _strand.getBeadByType(DataGridPresentationModel) as DataGridPresentationModel;
++ var listWidth:Number = host.width / sharedModel.columns.length;
++
++ _lists = new Array();
++
++ for (var i:int=0; i < sharedModel.columns.length; i++) {
++ var dataGridColumn:DataGridColumn = sharedModel.columns[i] as DataGridColumn;
++
++ var list:List = new List();
++ list.id = "dataGridColumn"+String(i);
++ list.className = "DataGridColumn";
++ list.addBead(sharedModel);
++ list.itemRenderer = dataGridColumn.itemRenderer;
++ list.labelField = dataGridColumn.dataField;
++ list.addEventListener('change',handleColumnListChange);
++ list.addEventListener('rollover',handleColumnListRollOver);
++ list.addEventListener('rollout',handleColumnListRollOut);
++ list.addBead(presentationModel);
++
++ var colWidth:Number = dataGridColumn.columnWidth;
++ if (!isNaN(colWidth)) list.width = colWidth;
++ else list.width = listWidth;
++
++ _listArea.addElement(list);
++ _lists.push(list);
++ }
++
++ _listArea.dispatchEvent(new Event("layoutNeeded"));
+ }
-
+ }
+}
++
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
index 0000000,0000000..9895394
new file mode 100644
--- /dev/null
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataItemRendererFactoryForArrayList.as
@@@ -1,0 -1,0 +1,174 @@@
++////////////////////////////////////////////////////////////////////////////////
++//
++// 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.beads
++{
++ import org.apache.flex.collections.ArrayList;
++ import org.apache.flex.core.IBead;
++ import org.apache.flex.core.IDataProviderItemRendererMapper;
++ import org.apache.flex.core.IItemRendererClassFactory;
++ import org.apache.flex.core.IItemRendererParent;
++ import org.apache.flex.core.IListPresentationModel;
++ import org.apache.flex.core.ISelectableItemRenderer;
++ import org.apache.flex.core.ISelectionModel;
++ import org.apache.flex.core.IStrand;
++ import org.apache.flex.core.IUIBase;
++ import org.apache.flex.core.SimpleCSSStyles;
++ 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.List;
++
++ /**
++ * The DataItemRendererFactoryForArrayList class uses an ArrayList
++ * and creates an item renderer for every
++ * item in the collection. Other implementations of
++ * IDataProviderItemRendererMapper map different data
++ * structures or manage a virtual set of renderers.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public class DataItemRendererFactoryForArrayList implements IBead, IDataProviderItemRendererMapper
++ {
++ /**
++ * Constructor.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function DataItemRendererFactoryForArrayList()
++ {
++ }
++
++ private var selectionModel:ISelectionModel;
++
++ private var labelField:String;
++
++ private var _strand:IStrand;
++
++ /**
++ * @copy org.apache.flex.core.IBead#strand
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function set strand(value:IStrand):void
++ {
++ _strand = value;
++ IEventDispatcher(_strand).addEventListener("beadsAdded", finishSetup);
++ IEventDispatcher(_strand).addEventListener("initComplete", finishSetup);
++ }
++
++ private function finishSetup(event:Event):void
++ {
++ selectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
++ var listView:IListView = _strand.getBeadByType(IListView) as IListView;
++ dataGroup = listView.dataGroup;
++ selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler);
++
++ labelField = (listView.host as List).labelField;
++
++ if (!itemRendererFactory)
++ {
++ _itemRendererFactory = _strand.getBeadByType(IItemRendererClassFactory) as IItemRendererClassFactory;
++ if (_itemRendererFactory == null) {
++ _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory;
++ _strand.addBead(_itemRendererFactory);
++ }
++ }
++
++ dataProviderChangeHandler(null);
++ }
++
++ private var _itemRendererFactory:IItemRendererClassFactory;
++
++ /**
++ * The org.apache.flex.core.IItemRendererClassFactory used
++ * to generate instances of item renderers.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get itemRendererFactory():IItemRendererClassFactory
++ {
++ return _itemRendererFactory;
++ }
++
++ /**
++ * @private
++ */
++ public function set itemRendererFactory(value:IItemRendererClassFactory):void
++ {
++ _itemRendererFactory = value;
++ }
++
++ /**
++ * The org.apache.flex.core.IItemRendererParent that will
++ * parent the item renderers.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ protected var dataGroup:IItemRendererParent;
++
++ private function dataProviderChangeHandler(event:Event):void
++ {
++ var dp:ArrayList = selectionModel.dataProvider as ArrayList;
++ if (!dp)
++ return;
++
++ dataGroup.removeAllElements();
++
++ var listView:IListView = _strand.getBeadByType(IListView) as IListView;
++ var presentationModel:IListPresentationModel = _strand.getBeadByType(IListPresentationModel) as IListPresentationModel;
++
++ var n:int = dp.length;
++ for (var i:int = 0; i < n; i++)
++ {
++ var ir:ISelectableItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as ISelectableItemRenderer;
++ ir.index = i;
++ ir.labelField = labelField;
++ if (presentationModel) {
++ UIBase(ir).height = presentationModel.rowHeight;
++
++ // ensure that the IR spans the width of its column
++ var style:SimpleCSSStyles = new SimpleCSSStyles();
++ style.right = 0;
++ style.left = 0;
++ UIBase(ir).style = style;
++ }
++ dataGroup.addElement(ir);
++ ir.data = dp.getItemAt(i);
++ }
++
++ IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated"));
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataProviderChangeNotifier.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataProviderChangeNotifier.as
index 0000000,0000000..8905fb9
new file mode 100644
--- /dev/null
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/DataProviderChangeNotifier.as
@@@ -1,0 -1,0 +1,154 @@@
++////////////////////////////////////////////////////////////////////////////////
++//
++// 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.beads
++{
++ import org.apache.flex.core.IBead;
++ import org.apache.flex.core.IDocument;
++ import org.apache.flex.core.ISelectionModel;
++ import org.apache.flex.core.IStrand;
++ import org.apache.flex.events.Event;
++ import org.apache.flex.collections.ArrayList;
++
++ /**
++ * The DataProviderChangeNotifier notifies listeners when a selection model's
++ * ArrayList dataProvider has changed.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public class DataProviderChangeNotifier implements IBead, IDocument
++ {
++ /**
++ * constructor.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function DataProviderChangeNotifier()
++ {
++ }
++
++ protected var _dataProvider:ArrayList;
++
++ private var _strand:IStrand;
++
++ /**
++ * @copy org.apache.flex.core.IBead#strand
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function set strand(value:IStrand):void
++ {
++ _strand = value;
++
++ if (_dataProvider == null) {
++ var object:Object = document[sourceID];
++ _dataProvider = object[propertyName] as ArrayList;
++ }
++
++ _dataProvider.addEventListener("itemAdded", handleItemAdded);
++ _dataProvider.addEventListener("itemRemoved", handleItemRemoved);
++ _dataProvider.addEventListener("itemUpdated", handleItemUpdated);
++
++ }
++
++ protected var document:Object;
++
++ /**
++ * @private
++ */
++ public function setDocument(document:Object, id:String = null):void
++ {
++ this.document = document;
++ }
++
++ private var _sourceID:String;
++
++ /**
++ * The ID of the object holding the ArrayList, usually a model.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get sourceID():String
++ {
++ return _sourceID;
++ }
++ public function set sourceID(value:String):void
++ {
++ _sourceID = value;
++ }
++
++ private var _propertyName:String;
++
++ /**
++ * The property in the sourceID that is the ArrayList.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get propertyName():String
++ {
++ return _propertyName;
++ }
++
++ public function set propertyName(value:String):void
++ {
++ _propertyName = value;
++ }
++
++ /**
++ * @private
++ */
++ private function handleItemAdded(event:Event):void
++ {
++ var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
++ selectionModel.dispatchEvent(new Event("dataProviderChanged"));
++ }
++
++ /**
++ * @private
++ */
++ private function handleItemRemoved(event:Event):void
++ {
++ var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
++ selectionModel.dispatchEvent(new Event("dataProviderChanged"));
++ }
++
++ /**
++ * @private
++ */
++ private function handleItemUpdated(event:Event):void
++ {
++ var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
++ selectionModel.dispatchEvent(new Event("dataProviderChanged"));
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/controllers/ItemRendererMouseController.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/controllers/ItemRendererMouseController.as
index ed6ffb8,0b67de8..952cca9
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/controllers/ItemRendererMouseController.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/controllers/ItemRendererMouseController.as
@@@ -127,19 -91,9 +127,20 @@@ COMPILE::JS
{
target.hovered = false;
target.down = false;
+ target.dispatchEvent(new Event("rollout",true));
}
}
+
+ COMPILE::JS
+ protected function handleMouseOut(event:BrowserEvent):void
+ {
+ var target:ISelectableItemRenderer = event.target as ISelectableItemRenderer;
+ if (target)
+ {
+ target.hovered = false;
+ target.down = false;
+ }
+ }
/**
* @private
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/ArrayListSelectionModel.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/ArrayListSelectionModel.as
index 0000000,0000000..920e967
new file mode 100644
--- /dev/null
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/ArrayListSelectionModel.as
@@@ -1,0 -1,0 +1,242 @@@
++////////////////////////////////////////////////////////////////////////////////
++//
++// 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.beads.models
++{
++ import org.apache.flex.collections.ArrayList;
++ import org.apache.flex.core.IRollOverModel;
++ import org.apache.flex.core.ISelectionModel;
++ import org.apache.flex.core.IStrand;
++ import org.apache.flex.events.Event;
++ import org.apache.flex.events.EventDispatcher;
++
++ /**
++ * The ArrayListSelectionModel class is a selection model for
++ * a dataProvider that is an ArrayList. It assumes that items
++ * can be fetched from the dataProvider using dataProvider.getItemAt(index).
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public class ArrayListSelectionModel extends EventDispatcher implements ISelectionModel, IRollOverModel
++ {
++ /**
++ * Constructor.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function ArrayListSelectionModel()
++ {
++ }
++
++ private var _strand:IStrand;
++
++ /**
++ * @copy org.apache.flex.core.IBead#strand
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function set strand(value:IStrand):void
++ {
++ _strand = value;
++ }
++
++ private var _dataProvider:ArrayList;
++
++ /**
++ * @copy org.apache.flex.core.ISelectionModel#dataProvider
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get dataProvider():Object
++ {
++ return _dataProvider;
++ }
++
++ /**
++ * @private
++ */
++ public function set dataProvider(value:Object):void
++ {
++ if (value === _dataProvider) return;
++
++ _dataProvider = value as ArrayList;
++ if (_selectedIndex != -1)
++ _selectedItem = (_dataProvider == null || _selectedIndex >= _dataProvider.length) ? null :
++ _dataProvider.getItemAt(_selectedIndex);
++ dispatchEvent(new Event("dataProviderChanged"));
++ }
++
++ private var _selectedIndex:int = -1;
++ private var _rollOverIndex:int = -1;
++ private var _labelField:String = null;
++
++ /**
++ * @copy org.apache.flex.core.ISelectionModel#labelField
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get labelField():String
++ {
++ return _labelField;
++ }
++
++ /**
++ * @private
++ */
++ public function set labelField(value:String):void
++ {
++ if (value != _labelField) {
++ _labelField = value;
++ dispatchEvent(new Event("labelFieldChanged"));
++ }
++ }
++
++ /**
++ * @copy org.apache.flex.core.ISelectionModel#selectedIndex
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get selectedIndex():int
++ {
++ return _selectedIndex;
++ }
++
++ /**
++ * @private
++ */
++ public function set selectedIndex(value:int):void
++ {
++ if (value === _selectedIndex) return;
++
++ _selectedIndex = value;
++ _selectedItem = (value == -1 || _dataProvider == null) ? null : (value < _dataProvider.length) ? _dataProvider.getItemAt(value) : null;
++ dispatchEvent(new Event("selectedIndexChanged"));
++ }
++
++ /**
++ * @copy org.apache.flex.core.IRollOverModel#rollOverIndex
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get rollOverIndex():int
++ {
++ return _rollOverIndex;
++ }
++
++ /**
++ * @private
++ */
++ public function set rollOverIndex(value:int):void
++ {
++ _rollOverIndex = value;
++ dispatchEvent(new Event("rollOverIndexChanged"));
++ }
++
++ private var _selectedItem:Object;
++
++ /**
++ * @copy org.apache.flex.core.ISelectionModel#selectedItem
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get selectedItem():Object
++ {
++ return _selectedItem;
++ }
++
++ /**
++ * @private
++ */
++ public function set selectedItem(value:Object):void
++ {
++ if (value === _selectedItem) return;
++
++ _selectedItem = value;
++ var n:int = _dataProvider.length;
++ for (var i:int = 0; i < n; i++)
++ {
++ if (_dataProvider.getItemAt(i) == value)
++ {
++ _selectedIndex = i;
++ break;
++ }
++ }
++ dispatchEvent(new Event("selectedItemChanged"));
++ dispatchEvent(new Event("selectedIndexChanged"));
++ }
++
++ private var _selectedString:String;
++
++ /**
++ * An alternative to selectedItem for strongly typing the
++ * the selectedItem if the Array is an Array of Strings.
++ *
++ * @langversion 3.0
++ * @playerversion Flash 10.2
++ * @playerversion AIR 2.6
++ * @productversion FlexJS 0.0
++ */
++ public function get selectedString():String
++ {
++ return String(_selectedItem);
++ }
++
++ /**
++ * @private
++ */
++ public function set selectedString(value:String):void
++ {
++ _selectedString = value;
++ var n:int = _dataProvider.length;
++ for (var i:int = 0; i < n; i++)
++ {
++ if (String(_dataProvider.getItemAt(i)) == value)
++ {
++ _selectedIndex = i;
++ break;
++ }
++ }
++ dispatchEvent(new Event("selectedItemChanged"));
++ dispatchEvent(new Event("selectedIndexChanged"));
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridModel.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridModel.as
index f50b36a,0000000..531edac
mode 100644,000000..100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridModel.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridModel.as
@@@ -1,72 -1,0 +1,71 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.beads.models
+{
+ import org.apache.flex.core.IDataGridModel;
+ import org.apache.flex.events.Event;
+
+ /**
- * The DataGridModel class bead extends org.apache.flex.html.beads.modelsArraySelectionModel
- * and adds the array of org.apache.flex.html.supportClasses.DataGridColumns used to define
- * each of the column in the DataGrid.
++ * The DataGridModel class bead extends org.apache.flex.html.beads.models.ArrayListSelectionModel
++ * to facilitate using an ArrayList as the dataProvider for the DataGrid.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
- public class DataGridModel extends ArraySelectionModel implements IDataGridModel
++ public class DataGridModel extends ArrayListSelectionModel implements IDataGridModel
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function DataGridModel()
+ {
+ super();
+ }
+
+ private var _columns:Array;
+
+ /**
+ * The array of org.apache.flex.html.supportClasses.DataGridColumns used to
+ * define each column of the org.apache.flex.html.DataGrid.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get columns():Array
+ {
+ return _columns;
+ }
+ public function set columns(value:Array):void
+ {
+ if (_columns != value) {
+ _columns = value;
+ dispatchEvent( new Event("columnsChanged"));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d384b50d/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridPresentationModel.as
----------------------------------------------------------------------
diff --cc frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridPresentationModel.as
index 2959aad,0000000..0a00edb
mode 100644,000000..100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridPresentationModel.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/models/DataGridPresentationModel.as
@@@ -1,86 -1,0 +1,88 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.beads.models
+{
+ import org.apache.flex.core.IDataGridPresentationModel;
+ import org.apache.flex.core.IStrand;
+ import org.apache.flex.events.Event;
+
+ /**
+ * The DataGridPresentationModel class contains the data to label the columns
+ * of the org.apache.flex.html.DataGrid along with the height of the rows.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class DataGridPresentationModel extends ListPresentationModel implements IDataGridPresentationModel
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function DataGridPresentationModel()
+ {
+ super();
++
++ separatorThickness = 1;
+ }
+
+ private var _columnLabels:Array;
+
+ /**
+ * The labels for each column.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ 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 _strand:IStrand;
+
+ /**
+ * @copy org.apache.flex.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ override public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ }
+ }
+}