You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by mi...@apache.org on 2015/07/25 15:04:36 UTC

[2/2] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34837 Making sure that sorting with complex fields is the same as with simple fields in terms of locale awareness. For this I created a spark ComplexSortField which extends the spark SortField (and

FLEX-34837
Making sure that sorting with complex fields is the same as with simple fields in terms of locale awareness. For this I created a spark ComplexSortField which extends the spark SortField (and is thus locale-aware) and adds in the functionality for complex fields. Then GridSortFieldComplex could extend this version, to make sure that locale is handled correctly.


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

Branch: refs/heads/develop
Commit: 0cb12ee3f57015f4a7c8cae1e6992ccc85c55f85
Parents: 3a1769b
Author: Mihai Chira <mi...@apache.org>
Authored: Sat Jul 25 15:02:34 2015 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Sat Jul 25 15:02:34 2015 +0200

----------------------------------------------------------------------
 .../src/spark/collections/ComplexSortField.as   | 53 ++++++++++++++++++++
 .../gridClasses/GridSortFieldComplex.as         |  6 +--
 frameworks/spark-manifest.xml                   |  3 ++
 3 files changed, 59 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/0cb12ee3/frameworks/projects/spark/src/spark/collections/ComplexSortField.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/collections/ComplexSortField.as b/frameworks/projects/spark/src/spark/collections/ComplexSortField.as
new file mode 100644
index 0000000..2444101
--- /dev/null
+++ b/frameworks/projects/spark/src/spark/collections/ComplexSortField.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 spark.collections {
+    import mx.collections.IComplexSortField;
+    import mx.utils.ObjectUtil;
+
+    public class ComplexSortField extends SortField implements IComplexSortField {
+        private var _nameParts:Array;
+
+        public function ComplexSortField(name:String = null, descending:Boolean = false, numeric:Object = null, sortCompareType:String = null, customCompareFunction:Function = null)
+        {
+            super(name, descending, numeric, sortCompareType, customCompareFunction);
+            _nameParts = name ? name.split(".") : [];
+        }
+
+        public function get nameParts():Array
+        {
+            return _nameParts;
+        }
+
+        override public function objectHasSortField(object:Object):Boolean
+        {
+            return object && nameParts && nameParts.length && object.hasOwnProperty(nameParts[0]);
+        }
+
+        override protected function getSortFieldValue(obj:Object):*
+        {
+            return ObjectUtil.getValue(obj, _nameParts);
+        }
+
+        override public function get arraySortOnOptions():int
+        {
+            return -1;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/0cb12ee3/frameworks/projects/spark/src/spark/components/gridClasses/GridSortFieldComplex.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/gridClasses/GridSortFieldComplex.as b/frameworks/projects/spark/src/spark/components/gridClasses/GridSortFieldComplex.as
index e4f9bad..a8f54f2 100644
--- a/frameworks/projects/spark/src/spark/components/gridClasses/GridSortFieldComplex.as
+++ b/frameworks/projects/spark/src/spark/components/gridClasses/GridSortFieldComplex.as
@@ -19,7 +19,7 @@
 
 package spark.components.gridClasses {
 
-    import mx.collections.ComplexSortField;
+    import spark.collections.ComplexSortField;
     import mx.utils.ObjectUtil;
 
     [ExcludeClass]
@@ -45,10 +45,10 @@ package spark.components.gridClasses {
          *  @productversion Flex 4.5
          */
 
-        public function GridSortFieldComplex(column:GridColumn, name:String = null, descending:Boolean = false, numeric:Object = null)
+        public function GridSortFieldComplex(column:GridColumn, name:String = null, descending:Boolean = false, numeric:Object = null, sortCompareType:String = null, customCompareFunction:Function = null)
         {
             _column = column;
-            super(name, false, descending, numeric)
+            super(name, descending, numeric, sortCompareType, customCompareFunction);
         }
 
 

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/0cb12ee3/frameworks/spark-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/spark-manifest.xml b/frameworks/spark-manifest.xml
index 5ae7f02..bf2eaa3 100644
--- a/frameworks/spark-manifest.xml
+++ b/frameworks/spark-manifest.xml
@@ -101,6 +101,8 @@
     <component id="GraphicElement" class="spark.primitives.supportClasses.GraphicElement"/>
     <component id="Grid" class="spark.components.Grid"/>
     <component id="GridColumn" class="spark.components.gridClasses.GridColumn"/>
+    <component id="GridSortFieldSimple" class="spark.components.gridClasses.GridSortFieldSimple"/>
+    <component id="GridSortFieldComplex" class="spark.components.gridClasses.GridSortFieldComplex"/>
     <component id="GridItemEditor" class="spark.components.gridClasses.GridItemEditor" />
     <component id="GridItemRenderer" class="spark.components.gridClasses.GridItemRenderer"/>
     <component id="GridLayer" class="spark.components.gridClasses.GridLayer"/>
@@ -179,6 +181,7 @@
     <component id="SliderBase" class="spark.components.supportClasses.SliderBase"/>
     <component id="Sort" class="spark.collections.Sort"/>
     <component id="SortField" class="spark.collections.SortField"/>
+    <component id="ComplexSortField" class="spark.collections.ComplexSortField"/>
     <component id="SortingCollator" class="spark.globalization.SortingCollator"/>
     <component id="Spacer" class="mx.controls.Spacer" lookupOnly="true"/>
     <component id="SparkButtonSkin" class="spark.skins.SparkButtonSkin"/>