This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new ee55098  basic-LabelFunction: implement labelFunction functionality on 
a bead (LabelFunction)
ee55098 is described below

commit ee550983869e9d6a8fb36418c8adda362bc15366
Author: Carlos Rovira <[email protected]>
AuthorDate: Mon Aug 10 13:46:19 2020 +0200

    basic-LabelFunction: implement labelFunction functionality on a bead 
(LabelFunction)
---
 .../Basic/src/main/resources/basic-manifest.xml    |  5 +-
 .../org/apache/royale/html/beads/LabelFunction.as  | 95 ++++++++++++++++++++++
 .../projects/Core/src/main/royale/CoreClasses.as   |  1 +
 .../org/apache/royale/core/ILabelFunction.as       | 68 ++++++++++++++++
 4 files changed, 168 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 497e843..96b6535 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -296,6 +296,9 @@
     <component id="UIGraphicsBase" 
class="org.apache.royale.display.UIGraphicsBase"/>
        
        <component id="CollectionSelectedItemByField" 
class="org.apache.royale.html.beads.CollectionSelectedItemByField"/>      
-    <component id="ErrorImage" 
class="org.apache.royale.html.beads.ErrorImage"/>       
+    <component id="ErrorImage" 
class="org.apache.royale.html.beads.ErrorImage"/>
+
+    <component id="LabelFunction" 
class="org.apache.royale.html.beads.LabelFunction"/>
+
        
 </componentPackage>
diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/LabelFunction.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/LabelFunction.as
new file mode 100644
index 0000000..eb0b8f2
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/LabelFunction.as
@@ -0,0 +1,95 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.Bead;
+       import org.apache.royale.core.ILabelFunction;
+       
+       /**
+        *  The LabelFunction bead is a specialty bead that can be used with
+        *  item renderer based components and gives label function capability 
to them
+     *  
+     *  The renderer needs to have support for labelFunction in order to work 
properly
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion Royale 0.10.0
+        */
+       public class LabelFunction extends Bead implements ILabelFunction
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.10.0
+                */
+               public function LabelFunction()
+               {
+               }
+
+               private var _labelFunction:Function;
+        /**
+         *  A user-supplied function to run on each item to determine its 
label.  
+         *  By default, the list looks for a property named <code>label</code> 
+         *  on each data provider item and displays it.
+         *  However, some data sets do not have a <code>label</code> property
+         *  nor do they have another property that can be used for displaying.
+         *  An example is a data set that has lastName and firstName fields
+         *  but you want to display full names.
+         *
+         *  <p>You can supply a <code>labelFunction</code> that finds the 
+         *  appropriate fields and returns a displayable string. The 
+         *  <code>labelFunction</code> is also good for handling formatting 
and 
+         *  localization. </p>
+         *
+         *  <p>For most components, the label function takes a single argument
+         *  which is the item in the data provider and returns a String.</p>
+         *  <pre>
+         *  myLabelFunction(item:Object):String</pre>
+         *
+         *  <p>The method signature for the data grid classes is:</p>
+         *  <pre>
+         *  myLabelFunction(item:Object, column:DataGridColumn):String</pre>
+         * 
+         *  <p>where <code>item</code> contains the DataGrid item object, and
+         *  <code>column</code> specifies the DataGrid column.</p>
+         *
+         *  @default null
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.10.0
+         */
+        public function get labelFunction():Function
+        {
+            return _labelFunction;
+        }
+        /**
+         *  @private
+         */
+        public function set labelFunction(value:Function):void
+        {
+            _labelFunction = value;
+        }
+       }
+}
diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as 
b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index d4b8e63..bbd1b88 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -125,6 +125,7 @@ internal class CoreClasses
        import org.apache.royale.core.IIndexedItemRenderer; 
IIndexedItemRenderer;
        import org.apache.royale.core.IIndexedItemRendererInitializer; 
IIndexedItemRendererInitializer;
        import org.apache.royale.core.ILabelFieldItemRenderer; 
ILabelFieldItemRenderer;
+       import org.apache.royale.core.ILabelFunction; ILabelFunction;
        import org.apache.royale.core.IOwnerViewItemRenderer; 
IOwnerViewItemRenderer;
        import org.apache.royale.core.ILayoutChild; ILayoutChild;
        import org.apache.royale.core.ILayoutHost; ILayoutHost;
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ILabelFunction.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ILabelFunction.as
new file mode 100644
index 0000000..f1ff6af
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/ILabelFunction.as
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.core
+{
+       /**
+     *  The ILabelFunction interface is the interface used at Item Renderer 
level to detect if there's a bead 
+        *  on the strand that wants to use an external label function to 
format labels.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.10.0
+     */
+       public interface ILabelFunction extends IBead
+       {
+               /**
+         *  A user-supplied function to run on each item to determine its 
label.  
+         *  By default, the list looks for a property named <code>label</code> 
+         *  on each data provider item and displays it.
+         *  However, some data sets do not have a <code>label</code> property
+         *  nor do they have another property that can be used for displaying.
+         *  An example is a data set that has lastName and firstName fields
+         *  but you want to display full names.
+         *
+         *  <p>You can supply a <code>labelFunction</code> that finds the 
+         *  appropriate fields and returns a displayable string. The 
+         *  <code>labelFunction</code> is also good for handling formatting 
and 
+         *  localization. </p>
+         *
+         *  <p>For most components, the label function takes a single argument
+         *  which is the item in the data provider and returns a String.</p>
+         *  <pre>
+         *  myLabelFunction(item:Object):String</pre>
+         *
+         *  <p>The method signature for the data grid classes is:</p>
+         *  <pre>
+         *  myLabelFunction(item:Object, column:DataGridColumn):String</pre>
+         * 
+         *  <p>where <code>item</code> contains the DataGrid item object, and
+         *  <code>column</code> specifies the DataGrid column.</p>
+         *
+         *  @default null
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 9
+         *  @playerversion AIR 1.1
+         *  @productversion Royale 0.10.0
+         */
+               function get labelFunction():Function;
+               function set labelFunction(value:Function):void;
+       }
+}

Reply via email to