This is an automated email from the ASF dual-hosted git repository.
pent pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new a2b71eb Modified Express version of the DataGrid to handle both Array
and ArrayList in the dataProvider. Extended DataGridColumn definition in
Express to set columnWidth as pixel or percent.
a2b71eb is described below
commit a2b71ebf37a8e6c62373605d2777c42404131d6f
Author: Peter Ent <[email protected]>
AuthorDate: Mon Feb 5 17:15:23 2018 -0500
Modified Express version of the DataGrid to handle both Array and ArrayList
in the dataProvider. Extended DataGridColumn definition in Express to set
columnWidth as pixel or percent.
---
.../Express/src/main/resources/defaults.css | 6 +-
.../src/main/resources/express-manifest.xml | 3 +-
.../Express/src/main/royale/ExpressClasses.as | 4 +
.../royale/express/beads/layouts/DataGridLayout.as | 209 +++++++++++++++++++++
.../royale/express/beads/models/DataGridModel.as | 41 ++++
.../express/supportClasses/DataGridColumn.as | 98 ++++++++++
6 files changed, 357 insertions(+), 4 deletions(-)
diff --git a/frameworks/projects/Express/src/main/resources/defaults.css
b/frameworks/projects/Express/src/main/resources/defaults.css
index 434c104..6f50bdc 100644
--- a/frameworks/projects/Express/src/main/resources/defaults.css
+++ b/frameworks/projects/Express/src/main/resources/defaults.css
@@ -49,8 +49,8 @@ DataGrid
IChangePropagator:
ClassReference("org.apache.royale.html.beads.DataGridColumnChangePropagator");
IDataGridPresentationModel:
ClassReference("org.apache.royale.html.beads.models.DataGridPresentationModel");
IBeadView: ClassReference("org.apache.royale.html.beads.DataGridView");
- IBeadModel:
ClassReference("org.apache.royale.html.beads.models.DataGridCollectionViewModel");
- IBeadLayout:
ClassReference("org.apache.royale.html.beads.DataGridWithDrawingLayerLayout");
+ IBeadModel:
ClassReference("org.apache.royale.express.beads.models.DataGridModel");
+ IBeadLayout:
ClassReference("org.apache.royale.express.beads.layouts.DataGridLayout");
ColumnClassName: "DataGridColumnList";
background-color: #FFFFFF;
@@ -61,7 +61,7 @@ DataGrid
.DataGridColumnList
{
- IBeadModel:
ClassReference("org.apache.royale.html.beads.models.DataGridCollectionViewModel");
+ IBeadModel:
ClassReference("org.apache.royale.express.beads.models.DataGridModel");
IBeadView: ClassReference("org.apache.royale.html.beads.ListView");
IBeadController:
ClassReference("org.apache.royale.html.beads.controllers.ListSingleSelectionMouseController");
IBeadLayout:
ClassReference("org.apache.royale.html.beads.layouts.VerticalLayout");
diff --git
a/frameworks/projects/Express/src/main/resources/express-manifest.xml
b/frameworks/projects/Express/src/main/resources/express-manifest.xml
index 710bb82..e7b8b2e 100644
--- a/frameworks/projects/Express/src/main/resources/express-manifest.xml
+++ b/frameworks/projects/Express/src/main/resources/express-manifest.xml
@@ -40,6 +40,8 @@
<component id="VSlider" class="org.apache.royale.express.VSlider"/>
<component id="VView" class="org.apache.royale.express.VView"/>
+ <component id="DataGridColumn"
class="org.apache.royale.express.supportClasses.DataGridColumn" />
+
<!-- Basic Components -->
<component id="SimpleCSSValuesImpl"
class="org.apache.royale.core.SimpleCSSValuesImpl" lookupOnly="true"/>
@@ -93,7 +95,6 @@
<component id="ScrollingViewport"
class="org.apache.royale.html.supportClasses.ScrollingViewport"
lookupOnly="true" />
<component id="DataGridButtonBar"
class="org.apache.royale.html.DataGridButtonBar" lookupOnly="true" />
- <component id="DataGridColumn"
class="org.apache.royale.html.supportClasses.DataGridColumn" lookupOnly="true"
/>
<component id="DateChooser" class="org.apache.royale.html.DateChooser"
lookupOnly="true" />
<component id="DateField" class="org.apache.royale.html.DateField"
lookupOnly="true" />
diff --git a/frameworks/projects/Express/src/main/royale/ExpressClasses.as
b/frameworks/projects/Express/src/main/royale/ExpressClasses.as
index 3ef366d..e643fc4 100644
--- a/frameworks/projects/Express/src/main/royale/ExpressClasses.as
+++ b/frameworks/projects/Express/src/main/royale/ExpressClasses.as
@@ -45,6 +45,10 @@ internal class ExpressClasses
import org.apache.royale.express.View; View;
import org.apache.royale.express.VSlider; VSlider;
import org.apache.royale.express.VView; VView;
+
+ import org.apache.royale.express.beads.models.DataGridModel;
DataGridModel;
+ import org.apache.royale.express.beads.layouts.DataGridLayout;
DataGridLayout;
+ import org.apache.royale.express.supportClasses.DataGridColumn;
DataGridColumn;
}
}
diff --git
a/frameworks/projects/Express/src/main/royale/org/apache/royale/express/beads/layouts/DataGridLayout.as
b/frameworks/projects/Express/src/main/royale/org/apache/royale/express/beads/layouts/DataGridLayout.as
new file mode 100644
index 0000000..a17c495
--- /dev/null
+++
b/frameworks/projects/Express/src/main/royale/org/apache/royale/express/beads/layouts/DataGridLayout.as
@@ -0,0 +1,209 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.royale.express.beads.layouts
+{
+ import org.apache.royale.core.IBeadLayout;
+ import org.apache.royale.core.IDataGridModel;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.IUIBase;
+ import org.apache.royale.core.UIBase;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.IEventDispatcher;
+ import org.apache.royale.express.supportClasses.DataGridColumn;
+ import org.apache.royale.geom.Rectangle;
+ import org.apache.royale.html.beads.IDataGridView;
+ import org.apache.royale.html.beads.IDrawingLayerBead;
+ import org.apache.royale.html.beads.models.ButtonBarModel;
+ import org.apache.royale.html.supportClasses.ScrollingViewport;
+ import org.apache.royale.utils.CSSContainerUtils;
+
+ /**
+ * This DataGridLayout class sizes and positions all of the elements of
the DataGrid
+ * in the Express package. The ButtonBar header, the container content
area for the
+ * the list columns, and the positioning and sizing of the list columns
within that
+ * container. On top of the contain a drawing layer is floating to
allow for the
+ * graphics of a drag-and-drop indicator.
+ */
+ public class DataGridLayout implements IBeadLayout
+ {
+ /**
+ * constructor
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function DataGridLayout()
+ {
+ }
+
+ private var _strand:IStrand;
+
+ /**
+ * @copy org.apache.royale.core.IBead#strand
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+
+ (_strand as
IEventDispatcher).addEventListener("widthChanged", handleSizeChanges);
+ (_strand as
IEventDispatcher).addEventListener("heightChanged", handleSizeChanges);
+ (_strand as
IEventDispatcher).addEventListener("sizeChanged", handleSizeChanges);
+ (_strand as
IEventDispatcher).addEventListener("layoutNeeded", handleLayoutNeeded);
+ }
+
+ private function get host():IUIBase
+ {
+ return _strand as IUIBase;
+ }
+ private function get uiHost():UIBase
+ {
+ return _strand as UIBase;
+ }
+
+ private function handleSizeChanges(event:Event):void
+ {
+ layout();
+ }
+
+ private function handleLayoutNeeded(event:Event):void
+ {
+ layout();
+ }
+
+ /**
+ * This layout algorithm handles columns of both pixel and
percent widths. The percent
+ * width represents the amount of space remaining after the
fixed width columns have
+ * been placed. For example, with three columns of widths,
"50", "100%", and "80" the
+ * 100% size represents the amount left over after the 130
pixels have been removed from
+ * whatever width the DataGrid currently has at the time this
layout is executed.
+ */
+ public function layout():Boolean
+ {
+ var header:IUIBase = (uiHost.view as
IDataGridView).header;
+ var listArea:IUIBase = (uiHost.view as
IDataGridView).listArea;
+
+ var displayedColumns:Array = (uiHost.view as
IDataGridView).columnLists;
+ var model:IDataGridModel = uiHost.model as
IDataGridModel;
+
+ var borderMetrics:Rectangle =
CSSContainerUtils.getBorderMetrics(_strand);
+ var useWidth:Number = uiHost.width -
(borderMetrics.left + borderMetrics.right);
+ var useHeight:Number = uiHost.height -
(borderMetrics.top + borderMetrics.bottom);
+
+ var xpos:Number = 0;
+ var defaultColumnWidth:Number = (useWidth) /
model.columns.length;
+ var columnWidths:Array = [];
+
+ // first determine the amount of space remaining once
the fixed width
+ // columns are accounted for.
+ var remainingSpace:Number = useWidth;
+ for (var i:int=0; i < displayedColumns.length; i++) {
+ var columnDef:DataGridColumn = model.columns[i]
as DataGridColumn;
+ if (isNaN(columnDef.percentColumnWidth) &&
!isNaN(columnDef.columnWidth)) {
+ remainingSpace -=
(columnDef.columnWidth / uiHost.width) * useWidth;
+ }
+ }
+
+ for(i=0; i < displayedColumns.length; i++) {
+ columnDef = model.columns[i] as DataGridColumn;
+ var columnList:UIBase = displayedColumns[i] as
UIBase;
+
+ // probably do not need to set (x,y), but if
the Container's layout requires it, they will be set.
+ columnList.x = xpos;
+ columnList.y = 0;
+
+ var columnWidth:Number = defaultColumnWidth;
+ if (isNaN(columnDef.columnWidth) &&
!isNaN(columnDef.percentColumnWidth)) {
+ columnWidth =
(columnDef.percentColumnWidth/100.0) * remainingSpace;
+ }
+ else if (isNaN(columnDef.percentColumnWidth) &&
!isNaN(columnDef.columnWidth)) {
+ columnWidth = (columnDef.columnWidth /
uiHost.width) * useWidth;
+ }
+
+ columnList.width = columnWidth;
+ columnWidths.push(columnWidth);
+
+ xpos += columnList.width;
+ }
+
+ var bbmodel:ButtonBarModel =
header.getBeadByType(ButtonBarModel) as ButtonBarModel;
+ bbmodel.buttonWidths = columnWidths;
+
+ header.x = borderMetrics.left;
+ header.y = borderMetrics.top;
+ COMPILE::SWF {
+ header.width = useWidth;
+ }
+ COMPILE::JS {
+ (header as UIBase).percentWidth = 100;
+ }
+ // header's height is set in CSS
+
+ listArea.x = borderMetrics.left;
+ listArea.y = header.height + header.y;
+ COMPILE::SWF {
+ listArea.width = useWidth;
+ }
+ COMPILE::JS {
+ (listArea as UIBase).percentWidth = 100;
+ }
+ listArea.height = useHeight - header.height;
+
+ // Get the drawing layer, if there is one, so it can be
positioned at the
+ // top of the z-order and sized properly.
+ var layerBead:IDrawingLayerBead =
_strand.getBeadByType(IDrawingLayerBead) as IDrawingLayerBead;
+
+ // Put the drawing layer back, sizing it to fit over
the listArea.
+ if (layerBead != null && layerBead.layer != null) {
+ UIBase(_strand).removeElement(layerBead.layer);
+ UIBase(_strand).addElement(layerBead.layer); //
always keep it on top
+
+ var layerX:Number = listArea.x;
+ var layerY:Number = listArea.y;
+ useWidth = listArea.width;
+ useHeight = listArea.height;
+
+ COMPILE::SWF {
+ var scrollViewport:ScrollingViewport =
listArea.getBeadByType(ScrollingViewport) as ScrollingViewport;
+ if (scrollViewport) {
+ var vbar:UIBase =
scrollViewport.verticalScroller as UIBase;
+ if (vbar != null &&
vbar.visible) useWidth -= vbar.width;
+ var hbar:UIBase =
scrollViewport.horizontalScroller as UIBase;
+ if (hbar != null &&
hbar.visible) useHeight -= hbar.height;
+ }
+ }
+
+ layerBead.layer.x = layerX;
+ layerBead.layer.y = layerY;
+ layerBead.layer.setWidthAndHeight(useWidth,
useHeight, true);
+ }
+
+ header.dispatchEvent(new Event("layoutNeeded"));
+ listArea.dispatchEvent(new Event("layoutNeeded"));
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git
a/frameworks/projects/Express/src/main/royale/org/apache/royale/express/beads/models/DataGridModel.as
b/frameworks/projects/Express/src/main/royale/org/apache/royale/express/beads/models/DataGridModel.as
new file mode 100644
index 0000000..1810535
--- /dev/null
+++
b/frameworks/projects/Express/src/main/royale/org/apache/royale/express/beads/models/DataGridModel.as
@@ -0,0 +1,41 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.express.beads.models
+{
+ import org.apache.royale.collections.ArrayList;
+ import org.apache.royale.html.beads.models.DataGridCollectionViewModel;
+
+ public class DataGridModel extends DataGridCollectionViewModel
+ {
+ public function DataGridModel()
+ {
+ super();
+ }
+
+ override public function set dataProvider(value:Object):void
+ {
+ if (value is Array) {
+ super.dataProvider = new ArrayList(value as
Array);
+ }
+ else {
+ super.dataProvider = value;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git
a/frameworks/projects/Express/src/main/royale/org/apache/royale/express/supportClasses/DataGridColumn.as
b/frameworks/projects/Express/src/main/royale/org/apache/royale/express/supportClasses/DataGridColumn.as
new file mode 100644
index 0000000..2cef89e
--- /dev/null
+++
b/frameworks/projects/Express/src/main/royale/org/apache/royale/express/supportClasses/DataGridColumn.as
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.express.supportClasses
+{
+ import org.apache.royale.core.IFactory;
+ import org.apache.royale.core.IUIBase;
+ import org.apache.royale.html.List;
+ import org.apache.royale.html.supportClasses.DataGridColumn;
+
+ /**
+ * This class defines how a column in the DataGrid should look,
including the label for
+ * the column and its width. In particular, the width may be given as a
fixed pixel size
+ * (e.g., "80") or a percentage of the remaining space once all
fixed-width columns have
+ * been taken into consideration (e.g., "100%"). That is, if the
DataGrid has a width
+ * of 400 pixels with columns of "50", "100%", and "80", the "100%"
column is the remainder
+ * of 400-50-80 or 260. If the DataGrid is resized to 500 pixels, the
outer columns remain
+ * at 50 and 80 pixels, but the middle column expands to 360 pixels
given its "100%" value.
+ */
+ public class DataGridColumn extends
org.apache.royale.html.supportClasses.DataGridColumn
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function DataGridColumn()
+ {
+ super();
+ }
+
+ private var _percentColumnWidth:Number = Number.NaN;
+
+ /**
+ * Sets the size of the column as a percentage of the remaining
space
+ * once the fixed columns have been accounted for.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ public function get percentColumnWidth():Number
+ {
+ return _percentColumnWidth;
+ }
+
+ public function set percentColumnWidth(value:Number):void
+ {
+ _percentColumnWidth = value;
+ _columnWidth= Number.NaN;
+ }
+
+ private var _columnWidth:Number = Number.NaN;
+
+ /**
+ * Sets the size of the column as a fixed pixel width. In MXML
you can set
+ * this propery as a percentage (e.g., columnWidth="75%") and
it will automatically
+ * transfer to the percentWidth as 75.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.0
+ */
+ [PercentProxy("percentColumnWidth")]
+ override public function get columnWidth():Number
+ {
+ return _columnWidth;
+ }
+
+ [PercentProxy("percentColumnWidth")]
+ override public function set columnWidth(value:Number):void
+ {
+ _columnWidth = value;
+ _percentColumnWidth = Number.NaN;
+ }
+
+ }
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
[email protected].