You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/09/28 03:42:56 UTC
[royale-asjs] 16/21: use ICollectionView
This is an automated email from the ASF dual-hosted git repository.
aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 80846647c8fb99de67c9b7abbf2d46ff882f17a4
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Sep 27 00:46:34 2018 -0700
use ICollectionView
---
.../src/main/royale/mx/controls/ComboBase.as | 35 +++++++++++++++++++++
.../royale/mx/controls/listClasses/ListBase.as | 36 ++++++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as
index 9a640a1..118144e 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/ComboBase.as
@@ -65,6 +65,11 @@ import org.apache.royale.html.beads.IComboBoxView;
import org.apache.royale.core.IComboBoxModel;
import org.apache.royale.core.IUIBase;
import mx.events.FlexEvent;
+import mx.collections.IList;
+import mx.collections.XMLListCollection;
+import mx.collections.ArrayCollection;
+import mx.collections.ICollectionView;
+import mx.collections.ListCollectionView;
/**
* The alpha of the content background for this component.
@@ -472,6 +477,36 @@ public class ComboBase extends UIComponent implements /*IIMESupport,*/ IFocusMan
*/
public function set dataProvider(value:Object):void
{
+ if (value is Array)
+ {
+ value = new ArrayCollection(value as Array);
+ }
+ else if (value is ICollectionView)
+ {
+ value = ICollectionView(value);
+ }
+ else if (value is IList)
+ {
+ value = new ListCollectionView(IList(value));
+ }
+ else if (value is XMLList)
+ {
+ value = new XMLListCollection(value as XMLList);
+ }
+ else if (value is XML)
+ {
+ var xl:XMLList = new XMLList();
+ xl += value;
+ value = new XMLListCollection(xl);
+ }
+ else
+ {
+ // convert it to an array containing this one item
+ var tmp:Array = [];
+ if (value != null)
+ tmp.push(value);
+ value = new ArrayCollection(tmp);
+ }
IComboBoxModel(model).dataProvider = value;
if (value && IComboBoxModel(model).selectedIndex == -1)
IComboBoxModel(model).selectedIndex = 0;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
index 1d723cc..ea2cad6 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/ListBase.as
@@ -19,12 +19,18 @@
package mx.controls.listClasses
{
+import mx.collections.ArrayCollection;
+import mx.collections.ICollectionView;
+import mx.collections.IList;
+import mx.collections.ListCollectionView;
+import mx.collections.XMLListCollection;
import mx.core.EdgeMetrics;
import mx.core.IFactory;
import mx.core.IUIComponent;
import mx.core.ScrollPolicy;
import mx.core.UIComponent;
import mx.core.mx_internal;
+import mx.events.CollectionEvent;
import mx.utils.UIDUtil;
import org.apache.royale.core.ContainerBaseStrandChildren;
@@ -208,6 +214,36 @@ use namespace mx_internal;
*/
public function set dataProvider(value:Object):void
{
+ if (value is Array)
+ {
+ value = new ArrayCollection(value as Array);
+ }
+ else if (value is ICollectionView)
+ {
+ value = ICollectionView(value);
+ }
+ else if (value is IList)
+ {
+ value = new ListCollectionView(IList(value));
+ }
+ else if (value is XMLList)
+ {
+ value = new XMLListCollection(value as XMLList);
+ }
+ else if (value is XML)
+ {
+ var xl:XMLList = new XMLList();
+ xl += value;
+ value = new XMLListCollection(xl);
+ }
+ else
+ {
+ // convert it to an array containing this one item
+ var tmp:Array = [];
+ if (value != null)
+ tmp.push(value);
+ value = new ArrayCollection(tmp);
+ }
(model as ISelectionModel).dataProvider = value;
}