Updated Branches: refs/heads/develop 5aa3a6168 -> 97a6d7f93
move datagrid classes to FlexJSJX so they can be cross-compiled Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1b89c96a Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1b89c96a Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1b89c96a Branch: refs/heads/develop Commit: 1b89c96ac7c7464f97f3bccc12c08b6f1768480c Parents: 5aa3a61 Author: Alex Harui <[email protected]> Authored: Wed Jan 22 23:05:47 2014 -0800 Committer: Alex Harui <[email protected]> Committed: Wed Jan 22 23:05:47 2014 -0800 ---------------------------------------------------------------------- .../flex/core/IDataGridPresentationModel.as | 31 ++++ .../apache/flex/html/staticControls/DataGrid.as | 56 ++++++ .../staticControls/beads/DataGridColumnView.as | 57 ++++++ .../html/staticControls/beads/DataGridView.as | 181 +++++++++++++++++++ .../DataItemRendererFactoryForColumnData.as | 101 +++++++++++ .../html/staticControls/beads/IDataGridView.as | 27 +++ .../beads/models/DataGridPresentationModel.as | 65 +++++++ .../flex/core/IDataGridPresentationModel.as | 31 ---- .../apache/flex/html/staticControls/DataGrid.as | 56 ------ .../staticControls/beads/DataGridColumnView.as | 57 ------ .../html/staticControls/beads/DataGridView.as | 181 ------------------- .../DataItemRendererFactoryForColumnData.as | 101 ----------- .../html/staticControls/beads/IDataGridView.as | 27 --- .../beads/models/DataGridPresentationModel.as | 65 ------- 14 files changed, 518 insertions(+), 518 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/core/IDataGridPresentationModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/core/IDataGridPresentationModel.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/core/IDataGridPresentationModel.as new file mode 100644 index 0000000..34a5d84 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/core/IDataGridPresentationModel.as @@ -0,0 +1,31 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import org.apache.flex.events.IEventDispatcher; + + public interface IDataGridPresentationModel extends IEventDispatcher, IBead + { + function get columnLabels():Array; + function set columnLabels(value:Array):void; + + function get rowHeight():Number; + function set rowHeight(value:Number):void; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/DataGrid.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/DataGrid.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/DataGrid.as new file mode 100644 index 0000000..63ff36e --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/DataGrid.as @@ -0,0 +1,56 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.staticControls +{ + import org.apache.flex.core.IDataGridModel; + import org.apache.flex.core.UIBase; + + [Event(name="change", type="org.apache.flex.events.Event")] + + public class DataGrid extends UIBase + { + public function DataGrid() + { + super(); + } + + public function get columns():Array + { + return IDataGridModel(model).columns; + } + public function set columns(value:Array):void + { + IDataGridModel(model).columns = value; + } + + public function get dataProvider():Object + { + return IDataGridModel(model).dataProvider; + } + public function set dataProvider(value:Object):void + { + IDataGridModel(model).dataProvider = value; + } + + public function get selectedIndex():int + { + return IDataGridModel(model).selectedIndex; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as new file mode 100644 index 0000000..7246bf3 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.staticControls.beads +{ + import org.apache.flex.core.IStrand; + import org.apache.flex.html.staticControls.supportClasses.DataGridColumn; + + public class DataGridColumnView extends ListView + { + public function DataGridColumnView() + { + } + + private var _strand:IStrand; + override public function set strand(value:IStrand):void + { + super.strand = value; + _strand = value; + } + + private var _columnIndex:uint; + public function get columnIndex():uint + { + return _columnIndex; + } + public function set columnIndex(value:uint):void + { + _columnIndex = value; + } + + private var _column:DataGridColumn; + public function get column():DataGridColumn + { + return _column; + } + public function set column(value:DataGridColumn):void + { + _column = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridView.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridView.as new file mode 100644 index 0000000..93350ee --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataGridView.as @@ -0,0 +1,181 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.staticControls.beads +{ + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.Shape; + + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IDataGridModel; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.staticControls.Button; + import org.apache.flex.html.staticControls.ButtonBar; + import org.apache.flex.html.staticControls.Container; + import org.apache.flex.html.staticControls.List; + import org.apache.flex.html.staticControls.beads.layouts.ButtonBarLayout; + import org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout; + import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; + import org.apache.flex.html.staticControls.supportClasses.DataGridColumn; + + public class DataGridView implements IDataGridView + { + public function DataGridView() + { + } + + private var background:Shape; + private var buttonBar:ButtonBar; + private var buttonBarModel:ArraySelectionModel; + private var columnContainer:Container; + private var columns:Array; + + public function getColumnLists():Array + { + return columns; + } + + private var _strand:IStrand; + public function set strand(value:IStrand):void + { + _strand = value; + + var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel; + + background = new Shape(); + DisplayObjectContainer(_strand).addChild(background); + + // create an array of columnLabels for use by the ButtonBar/DataGrid header. + var columnLabels:Array = new Array(); + var buttonWidths:Array = new Array(); + for(var i:int=0; i < sharedModel.columns.length; i++) { + columnLabels.push(sharedModel.columns[i].label); + buttonWidths.push(sharedModel.columns[i].columnWidth); + } + var bblayout:ButtonBarLayout = new ButtonBarLayout(); + bblayout.buttonWidths = buttonWidths; + + buttonBarModel = new ArraySelectionModel(); + buttonBarModel.dataProvider = columnLabels; + + buttonBar = new ButtonBar(); + buttonBar.addBead(buttonBarModel); + buttonBar.addBead(bblayout); + UIBase(_strand).addElement(buttonBar); + + columnContainer = new Container(); + var layout:NonVirtualHorizontalLayout = new NonVirtualHorizontalLayout(); + columnContainer.addBead(layout); + UIBase(_strand).addElement(columnContainer); + + columns = new Array(); + for(i=0; i < sharedModel.columns.length; i++) { + 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; + + var colWidth:Number = dataGridColumn.columnWidth; + if (!isNaN(colWidth)) list.width = colWidth; + + columnContainer.addElement(list); + columns.push(list); + list.addEventListener('change',columnListChangeHandler); + list.addEventListener('rollover',columnListRollOverHandler); + } + + IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange); + IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange); + + handleSizeChange(null); // initial sizing + } + + private function handleSizeChange(event:Event):void + { + var sw:Number = DisplayObject(_strand).width; + var sh:Number = DisplayObject(_strand).height; + + var backgroundColor:Number = 0xDDDDDD; + var value:Object = ValuesManager.valuesImpl.getValue(_strand, "background-color"); + if (value != null) backgroundColor = Number(value); + + background.graphics.clear(); + background.graphics.beginFill(backgroundColor); + background.graphics.drawRect(0,0,sw,sh); + background.graphics.endFill(); + + buttonBar.x = 0; + buttonBar.y = 0; + buttonBar.width = sw; + buttonBar.height = 25; + + columnContainer.x = 0; + columnContainer.y = 30; + columnContainer.width = sw; + columnContainer.height = sh - 25; + + for(var i:int=0; i < columns.length; i++) { + var column:List = columns[i]; + + var cw:Number = sw/(columns.length); + column.y = 0; + column.height = columnContainer.height; // this will actually be Nitem*rowHeight + } + + IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete")); + } + + private function columnListChangeHandler(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]) { + columns[i].selectedIndex = list.selectedIndex; + } + } + + IEventDispatcher(_strand).dispatchEvent(new Event('change')); + } + + private function columnListRollOverHandler(event:Event):void + { + var list:List = event.target as List; + for(var i:int=0; i < columns.length; i++) { + if (list != columns[i]) { + columns[i].rollOverIndex = list.rollOverIndex; + } + } + + IEventDispatcher(_strand).dispatchEvent(new Event('rollOver')); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as new file mode 100644 index 0000000..87e5366 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as @@ -0,0 +1,101 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.staticControls.beads +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IDataGridModel; + import org.apache.flex.core.IDataProviderItemRendererMapper; + import org.apache.flex.core.IItemRenderer; + import org.apache.flex.core.IItemRendererClassFactory; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.html.staticControls.supportClasses.DataGridColumn; + import org.apache.flex.html.staticControls.supportClasses.DataItemRenderer; + + public class DataItemRendererFactoryForColumnData implements IBead, IDataProviderItemRendererMapper + { + public function DataItemRendererFactoryForColumnData() + { + } + + private var selectionModel:IDataGridModel; + + private var _strand:IStrand; + + public function set strand(value:IStrand):void + { + _strand = value; + selectionModel = value.getBeadByType(IDataGridModel) as IDataGridModel; + var listView:IListView = value.getBeadByType(IListView) as IListView; + dataGroup = listView.dataGroup; + selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler); + + if (!itemRendererFactory) + { + _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory; + _strand.addBead(_itemRendererFactory); + } + + dataProviderChangeHandler(null); + } + + public var _itemRendererFactory:IItemRendererClassFactory; + + public function get itemRendererFactory():IItemRendererClassFactory + { + return _itemRendererFactory + } + + public function set itemRendererFactory(value:IItemRendererClassFactory):void + { + _itemRendererFactory = value; + } + + protected var dataGroup:IItemRendererParent; + + private function dataProviderChangeHandler(event:Event):void + { + var dp:Array = selectionModel.dataProvider as Array; + if (!dp) + return; + + dataGroup.removeAllElements(); + + var view:DataGridColumnView = _strand.getBeadByType(IBeadView) as DataGridColumnView; + if (view == null) return; + + var n:int = dp.length; + for (var i:int = 0; i < n; i++) + { + var tf:DataItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as DataItemRenderer; + tf.index = i; + tf.labelField = view.column.dataField; + dataGroup.addElement(tf); + tf.data = dp[i]; + } + + IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated")); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IDataGridView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IDataGridView.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IDataGridView.as new file mode 100644 index 0000000..17afcd5 --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/IDataGridView.as @@ -0,0 +1,27 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.staticControls.beads +{ + import org.apache.flex.core.IBeadView; + + public interface IDataGridView extends IBeadView + { + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as new file mode 100644 index 0000000..4c19aac --- /dev/null +++ b/frameworks/as/projects/FlexJSJX/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as @@ -0,0 +1,65 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.html.staticControls.beads.models +{ + import org.apache.flex.core.IDataGridPresentationModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + + public class DataGridPresentationModel extends EventDispatcher implements IDataGridPresentationModel + { + public function DataGridPresentationModel() + { + super(); + } + + private var _columnLabels:Array; + public function get columnLabels():Array + { + return _columnLabels; + } + public function set columnLabels(value:Array):void + { + if (value != _columnLabels) { + _columnLabels = value; + dispatchEvent(new Event("columnsChanged")); + } + } + + private var _rowHeight:Number = 30; + public function get rowHeight():Number + { + return _rowHeight; + } + public function set rowHeight(value:Number):void + { + if (value != _rowHeight) { + _rowHeight = value; + dispatchEvent(new Event("rowHeightChanged")); + } + } + + private var _strand:IStrand; + public function set strand(value:IStrand):void + { + _strand = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IDataGridPresentationModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IDataGridPresentationModel.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IDataGridPresentationModel.as deleted file mode 100644 index 34a5d84..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IDataGridPresentationModel.as +++ /dev/null @@ -1,31 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.core -{ - import org.apache.flex.events.IEventDispatcher; - - public interface IDataGridPresentationModel extends IEventDispatcher, IBead - { - function get columnLabels():Array; - function set columnLabels(value:Array):void; - - function get rowHeight():Number; - function set rowHeight(value:Number):void; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/DataGrid.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/DataGrid.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/DataGrid.as deleted file mode 100644 index 63ff36e..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/DataGrid.as +++ /dev/null @@ -1,56 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.staticControls -{ - import org.apache.flex.core.IDataGridModel; - import org.apache.flex.core.UIBase; - - [Event(name="change", type="org.apache.flex.events.Event")] - - public class DataGrid extends UIBase - { - public function DataGrid() - { - super(); - } - - public function get columns():Array - { - return IDataGridModel(model).columns; - } - public function set columns(value:Array):void - { - IDataGridModel(model).columns = value; - } - - public function get dataProvider():Object - { - return IDataGridModel(model).dataProvider; - } - public function set dataProvider(value:Object):void - { - IDataGridModel(model).dataProvider = value; - } - - public function get selectedIndex():int - { - return IDataGridModel(model).selectedIndex; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as deleted file mode 100644 index 7246bf3..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridColumnView.as +++ /dev/null @@ -1,57 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.staticControls.beads -{ - import org.apache.flex.core.IStrand; - import org.apache.flex.html.staticControls.supportClasses.DataGridColumn; - - public class DataGridColumnView extends ListView - { - public function DataGridColumnView() - { - } - - private var _strand:IStrand; - override public function set strand(value:IStrand):void - { - super.strand = value; - _strand = value; - } - - private var _columnIndex:uint; - public function get columnIndex():uint - { - return _columnIndex; - } - public function set columnIndex(value:uint):void - { - _columnIndex = value; - } - - private var _column:DataGridColumn; - public function get column():DataGridColumn - { - return _column; - } - public function set column(value:DataGridColumn):void - { - _column = value; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridView.as deleted file mode 100644 index 93350ee..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataGridView.as +++ /dev/null @@ -1,181 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.staticControls.beads -{ - import flash.display.DisplayObject; - import flash.display.DisplayObjectContainer; - import flash.display.Shape; - - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IDataGridModel; - import org.apache.flex.core.ISelectionModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.Button; - import org.apache.flex.html.staticControls.ButtonBar; - import org.apache.flex.html.staticControls.Container; - import org.apache.flex.html.staticControls.List; - import org.apache.flex.html.staticControls.beads.layouts.ButtonBarLayout; - import org.apache.flex.html.staticControls.beads.layouts.NonVirtualHorizontalLayout; - import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; - import org.apache.flex.html.staticControls.supportClasses.DataGridColumn; - - public class DataGridView implements IDataGridView - { - public function DataGridView() - { - } - - private var background:Shape; - private var buttonBar:ButtonBar; - private var buttonBarModel:ArraySelectionModel; - private var columnContainer:Container; - private var columns:Array; - - public function getColumnLists():Array - { - return columns; - } - - private var _strand:IStrand; - public function set strand(value:IStrand):void - { - _strand = value; - - var sharedModel:IDataGridModel = _strand.getBeadByType(IBeadModel) as IDataGridModel; - - background = new Shape(); - DisplayObjectContainer(_strand).addChild(background); - - // create an array of columnLabels for use by the ButtonBar/DataGrid header. - var columnLabels:Array = new Array(); - var buttonWidths:Array = new Array(); - for(var i:int=0; i < sharedModel.columns.length; i++) { - columnLabels.push(sharedModel.columns[i].label); - buttonWidths.push(sharedModel.columns[i].columnWidth); - } - var bblayout:ButtonBarLayout = new ButtonBarLayout(); - bblayout.buttonWidths = buttonWidths; - - buttonBarModel = new ArraySelectionModel(); - buttonBarModel.dataProvider = columnLabels; - - buttonBar = new ButtonBar(); - buttonBar.addBead(buttonBarModel); - buttonBar.addBead(bblayout); - UIBase(_strand).addElement(buttonBar); - - columnContainer = new Container(); - var layout:NonVirtualHorizontalLayout = new NonVirtualHorizontalLayout(); - columnContainer.addBead(layout); - UIBase(_strand).addElement(columnContainer); - - columns = new Array(); - for(i=0; i < sharedModel.columns.length; i++) { - 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; - - var colWidth:Number = dataGridColumn.columnWidth; - if (!isNaN(colWidth)) list.width = colWidth; - - columnContainer.addElement(list); - columns.push(list); - list.addEventListener('change',columnListChangeHandler); - list.addEventListener('rollover',columnListRollOverHandler); - } - - IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange); - IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange); - - handleSizeChange(null); // initial sizing - } - - private function handleSizeChange(event:Event):void - { - var sw:Number = DisplayObject(_strand).width; - var sh:Number = DisplayObject(_strand).height; - - var backgroundColor:Number = 0xDDDDDD; - var value:Object = ValuesManager.valuesImpl.getValue(_strand, "background-color"); - if (value != null) backgroundColor = Number(value); - - background.graphics.clear(); - background.graphics.beginFill(backgroundColor); - background.graphics.drawRect(0,0,sw,sh); - background.graphics.endFill(); - - buttonBar.x = 0; - buttonBar.y = 0; - buttonBar.width = sw; - buttonBar.height = 25; - - columnContainer.x = 0; - columnContainer.y = 30; - columnContainer.width = sw; - columnContainer.height = sh - 25; - - for(var i:int=0; i < columns.length; i++) { - var column:List = columns[i]; - - var cw:Number = sw/(columns.length); - column.y = 0; - column.height = columnContainer.height; // this will actually be Nitem*rowHeight - } - - IEventDispatcher(_strand).dispatchEvent(new Event("layoutComplete")); - } - - private function columnListChangeHandler(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]) { - columns[i].selectedIndex = list.selectedIndex; - } - } - - IEventDispatcher(_strand).dispatchEvent(new Event('change')); - } - - private function columnListRollOverHandler(event:Event):void - { - var list:List = event.target as List; - for(var i:int=0; i < columns.length; i++) { - if (list != columns[i]) { - columns[i].rollOverIndex = list.rollOverIndex; - } - } - - IEventDispatcher(_strand).dispatchEvent(new Event('rollOver')); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as deleted file mode 100644 index 87e5366..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForColumnData.as +++ /dev/null @@ -1,101 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.staticControls.beads -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.IDataGridModel; - import org.apache.flex.core.IDataProviderItemRendererMapper; - import org.apache.flex.core.IItemRenderer; - import org.apache.flex.core.IItemRendererClassFactory; - import org.apache.flex.core.IItemRendererParent; - import org.apache.flex.core.ISelectionModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.events.Event; - import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.html.staticControls.supportClasses.DataGridColumn; - import org.apache.flex.html.staticControls.supportClasses.DataItemRenderer; - - public class DataItemRendererFactoryForColumnData implements IBead, IDataProviderItemRendererMapper - { - public function DataItemRendererFactoryForColumnData() - { - } - - private var selectionModel:IDataGridModel; - - private var _strand:IStrand; - - public function set strand(value:IStrand):void - { - _strand = value; - selectionModel = value.getBeadByType(IDataGridModel) as IDataGridModel; - var listView:IListView = value.getBeadByType(IListView) as IListView; - dataGroup = listView.dataGroup; - selectionModel.addEventListener("dataProviderChanged", dataProviderChangeHandler); - - if (!itemRendererFactory) - { - _itemRendererFactory = new (ValuesManager.valuesImpl.getValue(_strand, "iItemRendererClassFactory")) as IItemRendererClassFactory; - _strand.addBead(_itemRendererFactory); - } - - dataProviderChangeHandler(null); - } - - public var _itemRendererFactory:IItemRendererClassFactory; - - public function get itemRendererFactory():IItemRendererClassFactory - { - return _itemRendererFactory - } - - public function set itemRendererFactory(value:IItemRendererClassFactory):void - { - _itemRendererFactory = value; - } - - protected var dataGroup:IItemRendererParent; - - private function dataProviderChangeHandler(event:Event):void - { - var dp:Array = selectionModel.dataProvider as Array; - if (!dp) - return; - - dataGroup.removeAllElements(); - - var view:DataGridColumnView = _strand.getBeadByType(IBeadView) as DataGridColumnView; - if (view == null) return; - - var n:int = dp.length; - for (var i:int = 0; i < n; i++) - { - var tf:DataItemRenderer = itemRendererFactory.createItemRenderer(dataGroup) as DataItemRenderer; - tf.index = i; - tf.labelField = view.column.dataField; - dataGroup.addElement(tf); - tf.data = dp[i]; - } - - IEventDispatcher(_strand).dispatchEvent(new Event("itemsCreated")); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/IDataGridView.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/IDataGridView.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/IDataGridView.as deleted file mode 100644 index 17afcd5..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/IDataGridView.as +++ /dev/null @@ -1,27 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.staticControls.beads -{ - import org.apache.flex.core.IBeadView; - - public interface IDataGridView extends IBeadView - { - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1b89c96a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as deleted file mode 100644 index 4c19aac..0000000 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/beads/models/DataGridPresentationModel.as +++ /dev/null @@ -1,65 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.html.staticControls.beads.models -{ - import org.apache.flex.core.IDataGridPresentationModel; - import org.apache.flex.core.IStrand; - import org.apache.flex.events.Event; - import org.apache.flex.events.EventDispatcher; - - public class DataGridPresentationModel extends EventDispatcher implements IDataGridPresentationModel - { - public function DataGridPresentationModel() - { - super(); - } - - private var _columnLabels:Array; - public function get columnLabels():Array - { - return _columnLabels; - } - public function set columnLabels(value:Array):void - { - if (value != _columnLabels) { - _columnLabels = value; - dispatchEvent(new Event("columnsChanged")); - } - } - - private var _rowHeight:Number = 30; - public function get rowHeight():Number - { - return _rowHeight; - } - public function set rowHeight(value:Number):void - { - if (value != _rowHeight) { - _rowHeight = value; - dispatchEvent(new Event("rowHeightChanged")); - } - } - - private var _strand:IStrand; - public function set strand(value:IStrand):void - { - _strand = value; - } - } -} \ No newline at end of file
