You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2020/12/13 10:10:24 UTC
[royale-asjs] 01/02: Add itemRendererFunction to spark DataGroup
This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit d2a3d56f21ad9c05b160f8b12e9c25f5b9bc5eb8
Author: Yishay Weiss <yi...@hotmail.com>
AuthorDate: Sun Dec 13 12:08:02 2020 +0200
Add itemRendererFunction to spark DataGroup
---
.../projects/Basic/src/main/royale/BasicClasses.as | 1 +
.../royale/html/beads/ItemRendererFunctionBead.as | 53 ++++++++++++++++++++++
.../DataItemRendererFactoryForIListData.as | 21 +++++++++
.../src/main/royale/spark/components/DataGroup.as | 18 ++++----
4 files changed, 84 insertions(+), 9 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index 1605f98..00f5c1f 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -42,6 +42,7 @@ internal class BasicClasses
import org.apache.royale.html.accessories.TextPromptBead; TextPromptBead;
import org.apache.royale.html.beads.AbsolutePositioningViewBeadBase; AbsolutePositioningViewBeadBase;
import org.apache.royale.html.beads.AlertView; AlertView;
+ import org.apache.royale.html.beads.ItemRendererFunctionBead; ItemRendererFunctionBead;
import org.apache.royale.html.beads.ColorSpectrumView; ColorSpectrumView;
import org.apache.royale.html.supportClasses.ColorPickerPopUp; ColorPickerPopUp;
import org.apache.royale.html.beads.controllers.AlertController; AlertController;
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ItemRendererFunctionBead.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ItemRendererFunctionBead.as
new file mode 100644
index 0000000..3975d88
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ItemRendererFunctionBead.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.html.beads
+{
+
+ import org.apache.royale.core.IBead;
+ import org.apache.royale.core.IStrand;
+
+ /**
+ * Helper bead for storing the item renderer function
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.8
+ */
+ public class ItemRendererFunctionBead implements IBead
+ {
+ private var _itemRendererFunction:Function;
+
+ public function set strand(value:IStrand):void
+ {
+ }
+
+ public function get itemRendererFunction():Function
+ {
+ return _itemRendererFunction;
+ }
+
+ public function set itemRendererFunction(value:Function):void
+ {
+ _itemRendererFunction = value;
+ }
+
+ }
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForIListData.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForIListData.as
index 57afc1d..4dd0a18 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForIListData.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForIListData.as
@@ -42,6 +42,8 @@ package mx.controls.listClasses
import org.apache.royale.html.List;
import org.apache.royale.html.beads.DataItemRendererFactoryForCollectionView;
import org.apache.royale.html.supportClasses.TreeListData;
+ import org.apache.royale.html.beads.ItemRendererFunctionBead;
+ import org.apache.royale.core.IIndexedItemRendererInitializer;
/**
* The DataItemRendererFactoryForHierarchicalData class reads a
@@ -114,6 +116,25 @@ package mx.controls.listClasses
{
return dp.getItemAt(index);
}
+
+ override protected function createAllItemRenderers(dataGroup:IItemRendererOwnerView):void
+ {
+ var itemRendererFunction:Function;
+ var functionBead:ItemRendererFunctionBead = _strand.getBeadByType(ItemRendererFunctionBead) as ItemRendererFunctionBead;
+ var rendererFunction:Function = functionBead ? functionBead.itemRendererFunction : null;
+ var n:int = dataProviderLength;
+ for (var i:int = 0; i < n; i++)
+ {
+ var data:Object = getItemAt(i);
+ var ir:IIndexedItemRenderer = rendererFunction ? rendererFunction(data) as IIndexedItemRenderer :
+ itemRendererFactory.createItemRenderer() as IIndexedItemRenderer;
+
+ dataGroup.addItemRenderer(ir, false);
+ (itemRendererInitializer as IIndexedItemRendererInitializer).initializeIndexedItemRenderer(ir, data, i);
+ ir.data = data;
+ }
+ }
+
}
}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as
index bc8cb2a..b5ffa41 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DataGroup.as
@@ -44,6 +44,7 @@ import spark.events.RendererExistenceEvent;
import mx.core.IVisualElement;
import mx.collections.IList;
import spark.components.supportClasses.GroupBase;
+import org.apache.royale.html.beads.ItemRendererFunctionBead;
import mx.core.IUIComponent;
import mx.core.mx_internal;
@@ -562,16 +563,15 @@ public class DataGroup extends GroupBase implements IItemRendererProvider, IStra
/**
* @private
*/
- public function set itemRendererFunction(value:Function):void // not implemeneted
+ public function set itemRendererFunction(value:Function):void
{
- //_itemRendererFunction = value;
- //
- //removeDataProviderListener();
- //removeAllItemRenderers();
- //invalidateProperties();
- //
- //itemRendererChanged = true;
- //typicalItemChanged = true;
+ var itemRendererFunctionBead:ItemRendererFunctionBead = getBeadByType(ItemRendererFunctionBead) as ItemRendererFunctionBead;
+ if (!itemRendererFunctionBead)
+ {
+ itemRendererFunctionBead = new ItemRendererFunctionBead();
+ addBead(itemRendererFunctionBead);
+ }
+ itemRendererFunctionBead.itemRendererFunction = value;
}
//----------------------------------