flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mkess...@apache.org
Subject git commit: [flex-sdk] - FLEX-33526: Added the findRowIndices method to allow array values.
Date Sun, 28 Apr 2013 02:02:30 GMT
Updated Branches:
  refs/heads/develop 9084f8164 -> ec1ac280b


FLEX-33526: Added the findRowIndices method to allow array values.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/ec1ac280
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/ec1ac280
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/ec1ac280

Branch: refs/heads/develop
Commit: ec1ac280b7f0124169fd4efe82191bd170c7ae7c
Parents: 9084f81
Author: Mark Kessler <KesslerConsulting@gmail.com>
Authored: Sat Apr 27 21:58:40 2013 -0400
Committer: Mark Kessler <KesslerConsulting@gmail.com>
Committed: Sat Apr 27 21:59:58 2013 -0400

----------------------------------------------------------------------
 .../spark/src/spark/components/DataGrid.as         |   21 +++++
 .../projects/spark/src/spark/components/Grid.as    |   60 +++++++++++++++
 .../supportClasses/IDataProviderEnhance.as         |   11 +++
 .../spark/components/supportClasses/ListBase.as    |   60 +++++++++++++++
 4 files changed, 152 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ec1ac280/frameworks/projects/spark/src/spark/components/DataGrid.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/DataGrid.as b/frameworks/projects/spark/src/spark/components/DataGrid.as
index 85e4b43..933935c 100644
--- a/frameworks/projects/spark/src/spark/components/DataGrid.as
+++ b/frameworks/projects/spark/src/spark/components/DataGrid.as
@@ -3983,6 +3983,27 @@ public class DataGrid extends SkinnableContainerBase
 
 
     /**
+    *  @copy spark.components.Grid#findRowIndices()
+    *
+    *  @langversion 3.0
+    *  @playerversion Flash 11.1
+    *  @playerversion AIR 3.4
+    *  @productversion Flex 4.10
+    */
+    public function findRowIndices(field:String, values:Array, patternType:String = RegExPatterns.EXACT):Array
+    {
+        if (grid)
+        {
+            return grid.findRowIndices(field, values, patternType);
+        }
+        else
+        {
+            return [];
+        }
+    }
+
+
+    /**
      *  @copy spark.components.Grid#invalidateCell()
      *  
      *  @langversion 3.0

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ec1ac280/frameworks/projects/spark/src/spark/components/Grid.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/Grid.as b/frameworks/projects/spark/src/spark/components/Grid.as
index 94a16fe..be40673 100644
--- a/frameworks/projects/spark/src/spark/components/Grid.as
+++ b/frameworks/projects/spark/src/spark/components/Grid.as
@@ -4809,6 +4809,66 @@ public class Grid extends Group implements IDataGridElement, IDataProviderEnhanc
 
 
     /**
+    *  This will search through a dataprovider checking the given field and for the given
values and return an array of indices that matched.
+    *
+    *  @langversion 3.0
+    *  @playerversion Flash 11.1
+    *  @playerversion AIR 3.4
+    *  @productversion Flex 4.10
+    */
+    public function findRowIndices(field:String, values:Array, patternType:String = RegExPatterns.EXACT):Array
+    {
+        var currentObject:Object = null;
+        var regexList:Array = [];
+        var matchedIndices:Array = [];
+        var dataProviderTotal:uint = 0;
+        var valuesTotal:uint = values.length;
+        var loopingDataProviderIndex:uint = 0;
+        var loopingValuesIndex:uint = 0;
+
+
+        if (dataProvider && dataProvider.length > 0 && valuesTotal >
0)
+        {
+            dataProviderTotal = dataProvider.length;
+
+
+            //Set the regex patterns in an array once.
+            for (loopingValuesIndex = 0; loopingValuesIndex < valuesTotal; loopingValuesIndex++)
+            {
+                regexList.push(RegExPatterns.createRegExp(values[loopingValuesIndex], patternType));
+            }
+
+
+            //Loop through dataprovider
+            for (loopingDataProviderIndex; loopingDataProviderIndex < dataProviderTotal;
loopingDataProviderIndex++)
+            {
+                currentObject = dataProvider.getItemAt(loopingDataProviderIndex);
+
+                if (currentObject.hasOwnProperty(field) == false)
+                {
+                    continue;
+                }
+
+                //Loop through regex patterns from the values array.
+                for (loopingValuesIndex = 0; loopingValuesIndex < valuesTotal; loopingValuesIndex++)
+                {
+                    if (currentObject[field].search(regexList[loopingValuesIndex]) != -1)
+                    {
+                        matchedIndices.push(loopingDataProviderIndex);
+
+                        break;
+                    }
+                }
+            }
+
+        }
+
+
+        return matchedIndices;
+    }
+
+
+    /**
     *  This will search through a dataprovider checking the given field and will set the
selectedIndex to a matching value.
     *  It can start the search from the startingIndex;
     *

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ec1ac280/frameworks/projects/spark/src/spark/components/supportClasses/IDataProviderEnhance.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/IDataProviderEnhance.as
b/frameworks/projects/spark/src/spark/components/supportClasses/IDataProviderEnhance.as
index 45dba4f..456bdeb 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/IDataProviderEnhance.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/IDataProviderEnhance.as
@@ -89,6 +89,17 @@ package spark.components.supportClasses
 
 
         /**
+        *  This will search through a dataprovider checking the given field and for the given
values and return an array of indexes that matched.
+        *
+        *  @langversion 3.0
+        *  @playerversion Flash 11.1
+        *  @playerversion AIR 3.4
+        *  @productversion Flex 4.10
+        */
+        function findRowIndices(field:String, values:Array, patternType:String = RegExPatterns.EXACT):Array;
+
+
+        /**
         *  Changes the selectedIndex to the first row of the dataProvider.
         *
         *  @langversion 3.0

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ec1ac280/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as b/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
index 37e3233..5f737f4 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
@@ -1271,6 +1271,66 @@ public class ListBase extends SkinnableDataContainer implements IDataProviderEnh
 
 
     /**
+    *  This will search through a dataprovider checking the given field and for the given
values and return an array of indices that matched.
+    *
+    *  @langversion 3.0
+    *  @playerversion Flash 11.1
+    *  @playerversion AIR 3.4
+    *  @productversion Flex 4.10
+    */
+    public function findRowIndices(field:String, values:Array, patternType:String = RegExPatterns.EXACT):Array
+    {
+        var currentObject:Object = null;
+        var regexList:Array = [];
+        var matchedIndices:Array = [];
+        var dataProviderTotal:uint = 0;
+        var valuesTotal:uint = values.length;
+        var loopingDataProviderIndex:uint = 0;
+        var loopingValuesIndex:uint = 0;
+
+
+        if (dataProvider && dataProvider.length > 0 && valuesTotal >
0)
+        {
+            dataProviderTotal = dataProvider.length;
+
+
+            //Set the regex patterns in an array once.
+            for (loopingValuesIndex = 0; loopingValuesIndex < valuesTotal; loopingValuesIndex++)
+            {
+                regexList.push(RegExPatterns.createRegExp(values[loopingValuesIndex], patternType));
+            }
+
+
+            //Loop through dataprovider
+            for (loopingDataProviderIndex; loopingDataProviderIndex < dataProviderTotal;
loopingDataProviderIndex++)
+            {
+                currentObject = dataProvider.getItemAt(loopingDataProviderIndex);
+
+                if (currentObject.hasOwnProperty(field) == false)
+                {
+                    continue;
+                }
+
+                //Loop through regex patterns from the values array.
+                for (loopingValuesIndex = 0; loopingValuesIndex < valuesTotal; loopingValuesIndex++)
+                {
+                    if (currentObject[field].search(regexList[loopingValuesIndex]) != -1)
+                    {
+                        matchedIndices.push(loopingDataProviderIndex);
+
+                        break;
+                    }
+                }
+            }
+
+        }
+
+
+        return matchedIndices;
+    }
+
+
+    /**
      *  Called when an item is selected or deselected. 
      *  Subclasses must override this method to display the selection.
      *


Mime
View raw message