Repository: flex-asjs Updated Branches: refs/heads/tlf 738c9e8b2 -> 3ceecca9d
Added a bead to simplify automatic update of list according to its data provider. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/e4fcceaa Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/e4fcceaa Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/e4fcceaa Branch: refs/heads/tlf Commit: e4fcceaa6221ac583ab8c14671df06bd97bf14af Parents: 9af3c0d Author: DESKTOP-RH4S838\Yishay <[email protected]> Authored: Thu Jun 15 10:20:04 2017 +0300 Committer: DESKTOP-RH4S838\Yishay <[email protected]> Committed: Thu Jun 15 10:20:04 2017 +0300 ---------------------------------------------------------------------- .../beads/SimpleDataProviderChangeNotifier.as | 89 ++++++++++++++++++++ .../Basic/src/main/resources/basic-manifest.xml | 1 + 2 files changed, 90 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e4fcceaa/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as new file mode 100644 index 0000000..718f6bb --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/SimpleDataProviderChangeNotifier.as @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.ISelectionModel; + import org.apache.flex.core.IStrand; + import org.apache.flex.events.Event; + + /** + * The SimpleDataProviderChangeNotifier is similar to DataProviderChangeNotifier + * but allows the user to populate the data provider after it's been added. + * Also, no attributes are required. Just add <SimpleDataProviderChangeNotifier/>. + * The dataProvider is assumed to be an ArrayList. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class SimpleDataProviderChangeNotifier extends DataProviderChangeNotifier + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function SimpleDataProviderChangeNotifier() + { + super(); + } + + override public function set strand(value:IStrand):void + { + _strand = value; + destinationChangedHandler(null); + } + + override protected function destinationChangedHandler(event:Event):void + { + if (!dataProvider) + { + setDataProvider(); + if (!dataProvider) + selectionModel.addEventListener("dataProviderChanged", setFirstDataProvider); + } else + { + super.destinationChangedHandler(event); + } + } + + private function setFirstDataProvider(e:Event):void + { + setDataProvider(); + selectionModel.removeEventListener("dataProviderChanged", setFirstDataProvider); + destinationChangedHandler(null); + } + + private function setDataProvider():void + { + dataProvider = selectionModel.dataProvider as ArrayList; + } + + private function get selectionModel():ISelectionModel + { + return _strand.getBeadByType(ISelectionModel) as ISelectionModel; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e4fcceaa/frameworks/projects/Basic/src/main/resources/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml index bc5dca3..d050d8a 100644 --- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml @@ -122,6 +122,7 @@ <component id="DataGrid" class="org.apache.flex.html.DataGrid"/> <component id="DataProviderChangeNotifier" class="org.apache.flex.html.beads.DataProviderChangeNotifier"/> + <component id="SimpleDataProviderChangeNotifier" class="org.apache.flex.html.beads.SimpleDataProviderChangeNotifier"/> <component id="DataProviderCollectionChangeNotifier" class="org.apache.flex.html.beads.DataProviderCollectionChangeNotifier"/> <component id="DataProviderItemsChangeNotifier" class="org.apache.flex.html.beads.DataProviderItemsChangeNotifier"/> <component id="DataGridButtonBar" class="org.apache.flex.html.DataGridButtonBar"/>
