Repository: flex-asjs Updated Branches: refs/heads/develop 669dee0c3 -> dc35db71b
Added support and other classes for DataGrid and List to make styling easier. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/dc35db71 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/dc35db71 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/dc35db71 Branch: refs/heads/develop Commit: dc35db71b166a9ed195700a57bd09b5d99c1b13a Parents: 669dee0 Author: Peter Ent <[email protected]> Authored: Thu Jun 30 16:02:10 2016 -0400 Committer: Peter Ent <[email protected]> Committed: Thu Jun 30 16:02:10 2016 -0400 ---------------------------------------------------------------------- .../projects/HTML/src/main/flex/HTMLClasses.as | 3 + .../main/flex/org/apache/flex/html/DataGrid.as | 2 + .../org/apache/flex/html/DataGridButtonBar.as | 51 ++++++++++++ .../flex/html/DataGridButtonBarTextButton.as | 55 +++++++++++++ .../org/apache/flex/html/beads/DataGridView.as | 6 +- .../flex/org/apache/flex/html/beads/ListView.as | 1 + .../ButtonBarButtonItemRenderer.as | 4 +- .../DataGridButtonBarButtonItemRenderer.as | 81 ++++++++++++++++++++ .../html/supportClasses/DataItemRenderer.as | 17 ++-- .../HTML/src/main/resources/basic-manifest.xml | 2 + .../HTML/src/main/resources/defaults.css | 14 ++++ 11 files changed, 224 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/HTMLClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as index c31d79c..51b5e48 100644 --- a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as +++ b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as @@ -148,7 +148,10 @@ internal class HTMLClasses 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.html.supportClasses.DataGridButtonBarButtonItemRenderer; DataGridButtonBarButtonItemRenderer; + import org.apache.flex.html.DataGridButtonBarTextButton; DataGridButtonBarTextButton; + import org.apache.flex.html.DataGridButtonBar; DataGridButtonBar; import org.apache.flex.html.beads.DataGridColumnView; DataGridColumnView; import org.apache.flex.html.beads.DataGridView; DataGridView; import org.apache.flex.html.beads.DateChooserView; DateChooserView; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGrid.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGrid.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGrid.as index 8cba078..c271134 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGrid.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGrid.as @@ -52,6 +52,8 @@ package org.apache.flex.html public function DataGrid() { super(); + + className = "DataGrid"; } /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBar.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBar.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBar.as new file mode 100644 index 0000000..c7208dc --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBar.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The DataGridButtonBar class extends ButtonBar and provides a class for styling + * the header region of the DataGrid. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridButtonBar extends ButtonBar + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridButtonBar() + { + super(); + className = "DataGridButtonBar"; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as new file mode 100644 index 0000000..67be174 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DataGridButtonBarTextButton.as @@ -0,0 +1,55 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.ITextModel; + + COMPILE::JS { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The DataGridButtonBarTextButton class extends TextButton so that + * the buttons used in the DataGrid header can be styled separately + * from normal TextButtons. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridButtonBarTextButton extends TextButton + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridButtonBarTextButton() + { + super(); + typeNames = ""; + className = "DataGridButtonBarTextButton"; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as index 582a1e7..73e6af7 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DataGridView.as @@ -30,7 +30,7 @@ package org.apache.flex.html.beads 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.DataGridButtonBar; import org.apache.flex.html.Container; import org.apache.flex.html.List; import org.apache.flex.html.beads.layouts.ButtonBarLayout; @@ -66,7 +66,7 @@ package org.apache.flex.html.beads } private var _strand:IStrand; - private var _header:ButtonBar; + private var _header:DataGridButtonBar; private var _listArea:Container; private var _lists:Array; @@ -103,7 +103,7 @@ package org.apache.flex.html.beads host.addEventListener("widthChanged", handleSizeChanges); host.addEventListener("heightChanged", handleSizeChanges); - _header = new ButtonBar(); + _header = new DataGridButtonBar(); _header.id = "dataGridHeader"; var scrollPort:ScrollingViewport = new ScrollingViewport(); http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ListView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ListView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ListView.as index a38afec..378355e 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ListView.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ListView.as @@ -88,6 +88,7 @@ package org.apache.flex.html.beads */ public function get dataGroup():IItemRendererParent { + (contentView as UIBase).className = "ListDataGroup"; return contentView as IItemRendererParent; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as index a461fac..1d320e3 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/ButtonBarButtonItemRenderer.as @@ -52,7 +52,7 @@ package org.apache.flex.html.supportClasses super(); } - private var textButton:TextButton; + protected var textButton:TextButton; /** * @private @@ -65,7 +65,7 @@ package org.apache.flex.html.supportClasses /** * @private */ - private function handleClickEvent(event:MouseEvent):void + protected function handleClickEvent(event:MouseEvent):void { var newEvent:ItemClickedEvent = new ItemClickedEvent("itemClicked"); newEvent.multipleSelection = event.shiftKey; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridButtonBarButtonItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridButtonBarButtonItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridButtonBarButtonItemRenderer.as new file mode 100644 index 0000000..f6663a5 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataGridButtonBarButtonItemRenderer.as @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.supportClasses +{ + import org.apache.flex.core.IItemRenderer; + import org.apache.flex.core.IItemRendererParent; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + import org.apache.flex.events.MouseEvent; + import org.apache.flex.html.DataGridButtonBarTextButton; + import org.apache.flex.html.beads.ITextItemRenderer; + import org.apache.flex.events.ItemClickedEvent; + + /** + * The ButtonBarButtonItemRenderer class handles the display of each item for the + * org.apache.flex.html.ButtonBar component. This class uses a + * org.apache.flex.html.Button to represent the data. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DataGridButtonBarButtonItemRenderer extends ButtonBarButtonItemRenderer + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DataGridButtonBarButtonItemRenderer() + { + super(); + } + + /** + * The data to be displayed by the itemRenderer instance. For ButtonBarItemRenderer, the + * data's string version is used as the label for the Button. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set data(value:Object):void + { + var added:Boolean = false; + if (textButton == null) { + textButton = new DataGridButtonBarTextButton(); + + // listen for clicks on the button and translate them into + // an itemClicked event. + textButton.addEventListener('click',handleClickEvent); + added = true; + } + + super.data = value; + + if (added) addElement(textButton); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as index f3b2527..796e6b7 100644 --- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DataItemRenderer.as @@ -27,6 +27,7 @@ package org.apache.flex.html.supportClasses import org.apache.flex.core.WrappedHTMLElement; import org.apache.flex.html.beads.controllers.ItemRendererMouseController; } + import org.apache.flex.core.ValuesManager; /** * The DataItemRenderer class is the base class for most itemRenderers. This class @@ -137,19 +138,21 @@ package org.apache.flex.html.supportClasses { super.updateRenderer(); + var color:uint = ValuesManager.valuesImpl.getValue(this, "background-color", "selected"); + background.graphics.clear(); - background.graphics.beginFill(useColor, (down||selected||hovered)?1:0); + background.graphics.beginFill(color, (down||selected||hovered)?1:0); background.graphics.drawRect(0, 0, width, height); background.graphics.endFill(); } COMPILE::JS { - if (selected) - element.style.backgroundColor = '#9C9C9C'; - else if (hovered) - element.style.backgroundColor = '#ECECEC'; - else - element.style.backgroundColor = null; + if (selected) { + element.className = "StringItemRenderer selected"; + } + else { + element.className = "StringItemRenderer"; + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/resources/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml index 8904c6e..baa4ff0 100644 --- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml @@ -87,6 +87,8 @@ <component id="DataGrid" class="org.apache.flex.html.DataGrid"/> <component id="DataProviderChangeNotifier" class="org.apache.flex.html.beads.DataProviderChangeNotifier"/> + <component id="DataGridButtonBar" class="org.apache.flex.html.DataGridButtonBar"/> + <component id="DataGridButtonBarTextButton" class="org.apache.flex.html.DataGridButtonBarTextButton"/> <component id="DataGridColumn" class="org.apache.flex.html.supportClasses.DataGridColumn"/> <component id="DataGridLinesBead" class="org.apache.flex.html.beads.DataGridLinesBead"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/dc35db71/frameworks/projects/HTML/src/main/resources/defaults.css ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/resources/defaults.css b/frameworks/projects/HTML/src/main/resources/defaults.css index dae3e5a..51152e8 100644 --- a/frameworks/projects/HTML/src/main/resources/defaults.css +++ b/frameworks/projects/HTML/src/main/resources/defaults.css @@ -117,6 +117,20 @@ DataGrid border-width: 1px; } +DataGridButtonBar +{ + IBeadModel: ClassReference("org.apache.flex.html.beads.models.ArraySelectionModel"); + IBeadView: ClassReference("org.apache.flex.html.beads.ButtonBarView"); + IBeadController: ClassReference("org.apache.flex.html.beads.controllers.ListSingleSelectionMouseController"); + IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.ButtonBarLayout"); + IContentView: ClassReference("org.apache.flex.html.supportClasses.DataGroup"); + IDataProviderItemRendererMapper: ClassReference("org.apache.flex.html.beads.TextItemRendererFactoryForArrayData"); + IItemRendererClassFactory: ClassReference("org.apache.flex.core.ItemRendererClassFactory"); + IItemRenderer: ClassReference("org.apache.flex.html.supportClasses.DataGridButtonBarButtonItemRenderer"); + + border-style: none; +} + .DataGridColumn { IBeadModel: ClassReference("org.apache.flex.html.beads.models.DataGridModel"); IBeadView: ClassReference("org.apache.flex.html.beads.ListView");
