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/10/13 19:52:28 UTC
[1/3] git commit: [flex-asjs] [refs/heads/develop] - "beadsAdded"
event not being dispatched from JavaScript version of UIBase.
Repository: flex-asjs
Updated Branches:
refs/heads/develop 258e69239 -> 27ef9d1c4
"beadsAdded" event not being dispatched from JavaScript version of UIBase.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1cd233cc
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1cd233cc
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1cd233cc
Branch: refs/heads/develop
Commit: 1cd233cc444aa3cf09ee6dac4fe4d75d6e2f0fce
Parents: 258e692
Author: Peter Ent <pe...@apache.org>
Authored: Tue Oct 13 13:50:42 2015 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Tue Oct 13 13:50:42 2015 -0400
----------------------------------------------------------------------
frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1cd233cc/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js b/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
index f79061d..a0345a8 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
@@ -332,6 +332,8 @@ org.apache.flex.core.UIBase.prototype.addedToParent = function() {
}
}
}
+
+ this.dispatchEvent(new org.apache.flex.events.Event('beadsAdded'));
};
[2/3] git commit: [flex-asjs] [refs/heads/develop] - Added
DataGridLinesBead to the DataGrid components.
Posted by pe...@apache.org.
Added DataGridLinesBead to the DataGrid 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/e42934b6
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/e42934b6
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/e42934b6
Branch: refs/heads/develop
Commit: e42934b6d71436cce030ab98d4818bd8028c7101
Parents: 1cd233c
Author: Peter Ent <pe...@apache.org>
Authored: Tue Oct 13 13:51:39 2015 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Tue Oct 13 13:51:39 2015 -0400
----------------------------------------------------------------------
.../projects/HTML/asjs/src/HTMLASJSClasses.as | 1 +
.../apache/flex/html/beads/DataGridLinesBead.as | 199 +++++++++++++++++++
frameworks/projects/HTML/basic-manifest.xml | 1 +
3 files changed, 201 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e42934b6/frameworks/projects/HTML/asjs/src/HTMLASJSClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/HTMLASJSClasses.as b/frameworks/projects/HTML/asjs/src/HTMLASJSClasses.as
index 99a837b..8478924 100644
--- a/frameworks/projects/HTML/asjs/src/HTMLASJSClasses.as
+++ b/frameworks/projects/HTML/asjs/src/HTMLASJSClasses.as
@@ -28,6 +28,7 @@ package
internal class HTMLASJSClasses
{
import org.apache.flex.html.beads.DataGridColumnView; DataGridColumnView;
+ import org.apache.flex.html.beads.DataGridLinesBead; DataGridLinesBead;
import org.apache.flex.html.beads.DataGridView; DataGridView;
import org.apache.flex.html.beads.DataProviderChangeNotifier; DataProviderChangeNotifier;
import org.apache.flex.html.beads.DataItemRendererFactoryForArrayList; DataItemRendererFactoryForArrayList;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e42934b6/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridLinesBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridLinesBead.as b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridLinesBead.as
new file mode 100644
index 0000000..b4e5b1d
--- /dev/null
+++ b/frameworks/projects/HTML/asjs/src/org/apache/flex/html/beads/DataGridLinesBead.as
@@ -0,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);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e42934b6/frameworks/projects/HTML/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/basic-manifest.xml b/frameworks/projects/HTML/basic-manifest.xml
index 921c67b..77ddd5e 100644
--- a/frameworks/projects/HTML/basic-manifest.xml
+++ b/frameworks/projects/HTML/basic-manifest.xml
@@ -82,6 +82,7 @@
<component id="DataGrid" class="org.apache.flex.html.DataGrid"/>
<component id="DataProviderChangeNotifier" class="org.apache.flex.html.beads.DataProviderChangeNotifier"/>
<component id="DataGridColumn" class="org.apache.flex.html.supportClasses.DataGridColumn"/>
+ <component id="DataGridLinesBead" class="org.apache.flex.html.beads.DataGridLinesBead"/>
<component id="DateChooser" class="org.apache.flex.html.DateChooser"/>
<component id="DateField" class="org.apache.flex.html.DateField"/>
[3/3] git commit: [flex-asjs] [refs/heads/develop] - Added
demonstration of DataGridLinesBead to DataGridExample.
Posted by pe...@apache.org.
Added demonstration of DataGridLinesBead to DataGridExample.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/27ef9d1c
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/27ef9d1c
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/27ef9d1c
Branch: refs/heads/develop
Commit: 27ef9d1c4838283a8a0b31290c80cf4bb5703d75
Parents: e42934b
Author: Peter Ent <pe...@apache.org>
Authored: Tue Oct 13 13:52:21 2015 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Tue Oct 13 13:52:21 2015 -0400
----------------------------------------------------------------------
.../DataGridExample/src/MyInitialView.mxml | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/27ef9d1c/examples/flexjs/DataGridExample/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/DataGridExample/src/MyInitialView.mxml b/examples/flexjs/DataGridExample/src/MyInitialView.mxml
index dd51c7c..d6173a1 100644
--- a/examples/flexjs/DataGridExample/src/MyInitialView.mxml
+++ b/examples/flexjs/DataGridExample/src/MyInitialView.mxml
@@ -44,5 +44,24 @@ limitations under the License.
<js:DataGridColumn label="Sales" dataField="sales" columnWidth="100" />
</js:columns>
</js:DataGrid>
+
+ <js:DataGrid id="dataGrid2" x="20" y="400" width="400" height="300" change="dataGridChange()" rowHeight="40">
+ <js:beads>
+ <js:DataGridLinesBead>
+ <js:stroke>
+ <js:SolidColorStroke color="#FF8800" weight="2" />
+ </js:stroke>
+ </js:DataGridLinesBead>
+ <js:ConstantBinding
+ sourceID="applicationModel"
+ sourcePropertyName="productList"
+ destinationPropertyName="dataProvider" />
+ </js:beads>
+ <js:columns>
+ <js:DataGridColumn label="Image" dataField="image" columnWidth="100" itemRenderer="products.ProductItemRenderer" />
+ <js:DataGridColumn label="Title" dataField="title" columnWidth="200" />
+ <js:DataGridColumn label="Sales" dataField="sales" columnWidth="100" />
+ </js:columns>
+ </js:DataGrid>
</js:ViewBase>