Repository: flex-sdk Updated Branches: refs/heads/develop b2aaf9da6 -> ece249f87
FLEX-34854 The spark SortField now extends the mx version, to prevent the need of changing both classes when a bug is fixed or a feature is implemented. NOTES: -this is a result of the mailing list discussion entitled 'Can we unify spark and mx Sort and SortField?'. -the compareFunction getter and setter have been kept only for the asdoc comment to show the differences between the spark and mx SortField. -the spark DataGrid was using AdvancedStyleClient to refer to spark SortFields instead of the interface, IAdvancedStyleClient. This needed to be corrected, because the spark SortField does not extend AdvancedStyleClient anymore. -SortField.stringCompare() and .xmlCompare() needed to be protected (they were private) so that they could be overridden in spark SortField. Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/71f87576 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/71f87576 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/71f87576 Branch: refs/heads/develop Commit: 71f8757626055ef989e1717b19c6004661d08ac6 Parents: b2aaf9d Author: Mihai Chira <[email protected]> Authored: Sun Jun 21 20:15:01 2015 +0100 Committer: Mihai Chira <[email protected]> Committed: Sun Jun 21 20:15:01 2015 +0100 ---------------------------------------------------------------------- .../framework/src/mx/collections/SortField.as | 24 +- .../AdvancedStyleClientImplementation.as | 144 ++++ .../spark/src/spark/collections/SortField.as | 671 +------------------ .../spark/src/spark/components/DataGrid.as | 130 ++-- 4 files changed, 254 insertions(+), 715 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/71f87576/frameworks/projects/framework/src/mx/collections/SortField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/src/mx/collections/SortField.as b/frameworks/projects/framework/src/mx/collections/SortField.as index 6604720..821690e 100644 --- a/frameworks/projects/framework/src/mx/collections/SortField.as +++ b/frameworks/projects/framework/src/mx/collections/SortField.as @@ -257,9 +257,10 @@ public class SortField extends EventDispatcher implements ISortField /** * The function that compares two items during a sort of items for the * associated collection. If you specify a <code>compareFunction</code> - * property in an ISort object, Flex ignores any - * <code>compareFunction</code> properties of the ISort's SortField - * objects. + * property in an <code>ISort</code> object, Flex ignores any + * <code>compareFunction</code> properties of the ISort's + * <code>SortField</code> objects. + * * <p>The compare function must have the following signature:</p> * * <p><code>function myCompare(a:Object, b:Object):int</code></p> @@ -267,11 +268,12 @@ public class SortField extends EventDispatcher implements ISortField * <p>This function must return the following values:</p> * * <ul> - * <li>-1, if <code>a</code> should appear before <code>b</code> in - * the sorted sequence</li> - * <li>0, if <code>a</code> equals <code>b</code></li> - * <li>1, if <code>a</code> should appear after <code>b</code> in the - * sorted sequence</li> + * <li>-1, if the <code>Object a</code> should appear before the + * <code>Object b</code> in the sorted sequence</li> + * <li>0, if the <code>Object a</code> equals the + * <code>Object b</code></li> + * <li>1, if the <code>Object a</code> should appear after the + * <code>Object b</code> in the sorted sequence</li> * </ul> * * <p>The default value is an internal compare function that can perform @@ -491,7 +493,7 @@ public class SortField extends EventDispatcher implements ISortField /** * @private - * A pretty printer for Sort that lists the sort fields and their + * A pretty printer for SortField that lists the sort fields and their * options. */ override public function toString():String @@ -805,7 +807,7 @@ public class SortField extends EventDispatcher implements ISortField * @playerversion AIR 1.1 * @productversion Flex 3 */ - private function stringCompare(a:Object, b:Object):int + protected function stringCompare(a:Object, b:Object):int { var fa:String = _name == null ? String(a) : String(getSortFieldValue(a)); var fb:String = _name == null ? String(b) : String(getSortFieldValue(b)); @@ -823,7 +825,7 @@ public class SortField extends EventDispatcher implements ISortField * @playerversion AIR 1.1 * @productversion Flex 3 */ - private function xmlCompare(a:Object, b:Object):int + protected function xmlCompare(a:Object, b:Object):int { var sa:String = _name == null ? a.toString() : getSortFieldValue(a).toString(); var sb:String = _name == null ? b.toString() : getSortFieldValue(b).toString(); http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/71f87576/frameworks/projects/spark/src/spark/collections/AdvancedStyleClientImplementation.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/spark/collections/AdvancedStyleClientImplementation.as b/frameworks/projects/spark/src/spark/collections/AdvancedStyleClientImplementation.as new file mode 100644 index 0000000..fa2f17f --- /dev/null +++ b/frameworks/projects/spark/src/spark/collections/AdvancedStyleClientImplementation.as @@ -0,0 +1,144 @@ +import mx.styles.AdvancedStyleClient; +import mx.styles.CSSStyleDeclaration; +import mx.styles.IAdvancedStyleClient; + +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +private var _advancedStyleClient:AdvancedStyleClient = new AdvancedStyleClient(); + +public function get id():String +{ + return _advancedStyleClient.id; +} + +public function get styleParent():IAdvancedStyleClient +{ + return _advancedStyleClient.styleParent; +} + +public function set styleParent(parent:IAdvancedStyleClient):void +{ + _advancedStyleClient.styleParent = parent; +} + +public function stylesInitialized():void +{ + _advancedStyleClient.stylesInitialized(); +} + +public function matchesCSSState(cssState:String):Boolean +{ + return _advancedStyleClient.matchesCSSState(cssState); +} + +public function matchesCSSType(cssType:String):Boolean +{ + return _advancedStyleClient.matchesCSSType(cssType); +} + +public function hasCSSState():Boolean +{ + return _advancedStyleClient.hasCSSState(); +} + +public function get className():String +{ + return _advancedStyleClient.className; +} + +public function get inheritingStyles():Object +{ + return _advancedStyleClient.inheritingStyles; +} + +public function set inheritingStyles(value:Object):void +{ + _advancedStyleClient.inheritingStyles = value; +} + +public function get nonInheritingStyles():Object +{ + return _advancedStyleClient.nonInheritingStyles; +} + +public function set nonInheritingStyles(value:Object):void +{ + _advancedStyleClient.nonInheritingStyles = value; +} + +public function get styleDeclaration():CSSStyleDeclaration +{ + return _advancedStyleClient.styleDeclaration; +} + +public function set styleDeclaration(value:CSSStyleDeclaration):void +{ + _advancedStyleClient.styleDeclaration = value; +} + +public function getStyle(styleProp:String):* +{ + return _getStyle(styleProp); +} + +public function setStyle(styleProp:String, newValue:*):void +{ + _setStyle(styleProp, newValue); +} + +public function clearStyle(styleProp:String):void +{ + _advancedStyleClient.clearStyle(styleProp); +} + +public function getClassStyleDeclarations():Array +{ + return _advancedStyleClient.getClassStyleDeclarations(); +} + +public function notifyStyleChangeInChildren(styleProp:String, recursive:Boolean):void +{ + _advancedStyleClient.notifyStyleChangeInChildren(styleProp, recursive) +} + +public function regenerateStyleCache(recursive:Boolean):void +{ + _advancedStyleClient.regenerateStyleCache(recursive); +} + +public function registerEffects(effects:Array):void +{ + _advancedStyleClient.registerEffects(effects); +} + +public function get styleName():Object +{ + return _advancedStyleClient.styleName; +} + +public function set styleName(value:Object):void +{ + _advancedStyleClient.styleName = value; +} + +public function styleChanged(styleProp:String):void +{ + _styleChanged(styleProp); +} http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/71f87576/frameworks/projects/spark/src/spark/collections/SortField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/spark/src/spark/collections/SortField.as b/frameworks/projects/spark/src/spark/collections/SortField.as index 00ba899..12568e9 100644 --- a/frameworks/projects/spark/src/spark/collections/SortField.as +++ b/frameworks/projects/spark/src/spark/collections/SortField.as @@ -21,13 +21,9 @@ package spark.collections { import flash.events.Event; - + import mx.styles.IAdvancedStyleClient; import mx.collections.ISortField; - import mx.collections.errors.SortError; import mx.core.FlexGlobals; - import mx.resources.IResourceManager; - import mx.resources.ResourceManager; - import mx.styles.AdvancedStyleClient; import mx.utils.ObjectUtil; import spark.globalization.SortingCollator; @@ -62,7 +58,7 @@ package spark.collections * Provides the sorting information required to establish a sort on a field * or property in a collection view. * - * SortField class is meant to be used with Sort class. + * The SortField class is meant to be used with the Sort class. * * Typically the sort is defined for collections of complex items, that * is items in which the sort is performed on properties of those objects. @@ -157,7 +153,7 @@ package spark.collections * @playerversion AIR 2.5 * @productversion Flex 4.5 */ -public class SortField extends AdvancedStyleClient implements ISortField +public class SortField extends mx.collections.SortField implements IAdvancedStyleClient { include "../core/Version.as"; @@ -193,22 +189,10 @@ public class SortField extends AdvancedStyleClient implements ISortField sortCompareType:String = null, customCompareFunction:Function = null) { - super(); - - _name = name; - _descending = descending; - _numeric = numeric; - _sortCompareType = sortCompareType; - - if(customCompareFunction != null) - { - compareFunction = customCompareFunction; - } - else if (updateSortCompareType() == false) - { - _compareFunction = stringCompare; - } + super(name, false, descending, numeric, sortCompareType, customCompareFunction); } + + include "AdvancedStyleClientImplementation.as"; //-------------------------------------------------------------------------- // @@ -218,13 +202,6 @@ public class SortField extends AdvancedStyleClient implements ISortField /** * @private - * Used for accessing localized Error messages. - */ - private var resourceManager:IResourceManager = - ResourceManager.getInstance(); - - /** - * @private * Cache for "locale" style. * * The code needs be able to find out if the locale style has been changed @@ -238,39 +215,6 @@ public class SortField extends AdvancedStyleClient implements ISortField // //-------------------------------------------------------------------------- - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function get arraySortOnOptions():int - { - if (usingCustomCompareFunction - || name == null - || _compareFunction == xmlCompare - || _compareFunction == dateCompare) - { - return -1; - } - var options:int = 0; - if (descending) options |= Array.DESCENDING; - if (numeric == true || _compareFunction == numericCompare) options |= Array.NUMERIC; - return options; - } - - //--------------------------------- - // compareFunction - //--------------------------------- - - /** - * @private - * Storage for the compareFunction property. - */ - private var _compareFunction:Function; - [Inspectable(category="General")] /** @@ -300,7 +244,7 @@ public class SortField extends AdvancedStyleClient implements ISortField * The string comparison is performed using the locale (language, * region and script) specific comparison method from the * <code>SortingCollator</code> class. - * This class uses the locale style to determine a locale + * This class uses the locale style to determine a locale. * Specify your own function only if you need a need a custom comparison * algorithm. This is normally only the case if a calculated field is * used in a display.</p> @@ -310,201 +254,21 @@ public class SortField extends AdvancedStyleClient implements ISortField * @playerversion AIR 2.5 * @productversion Flex 4.5 */ - public function get compareFunction():Function + override public function get compareFunction():Function { - return _compareFunction; + return super.compareFunction; } /** * @deprecated A future release of Apache Flex SDK will remove this function. Please use the constructor * argument instead. */ - public function set compareFunction(c:Function):void + override public function set compareFunction(c:Function):void { - _compareFunction = c; - _usingCustomCompareFunction = (c != null); + super.compareFunction = c; } - //--------------------------------- - // descending - //--------------------------------- - - /** - * @private - * Storage for the descending property. - */ - private var _descending:Boolean; - - [Inspectable(category="General")] - [Bindable("descendingChanged")] - - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function get descending():Boolean - { - return _descending; - } - /** - * @deprecated A future release of Apache Flex SDK will remove this function. Please use the constructor - * argument instead. - */ - public function set descending(value:Boolean):void - { - if (_descending != value) - { - _descending = value; - dispatchEvent(new Event("descendingChanged")); - } - } - - //--------------------------------- - // name - //--------------------------------- - - /** - * @private - * Storage for the name property. - */ - private var _name:String; - - [Inspectable(category="General")] - [Bindable("nameChanged")] - - /** - * @inheritDoc - * - * @default null - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function get name():String - { - return _name; - } - - /** - * @deprecated A future release of Apache Flex SDK will remove this function. Please use the constructor - * argument instead. - */ - public function set name(n:String):void - { - _name = n; - dispatchEvent(new Event("nameChanged")); - } - - //--------------------------------- - // numeric - //--------------------------------- - - /** - * @private - * Storage for the numeric property. - */ - private var _numeric:Object; - - [Inspectable(category="General")] - [Bindable("numericChanged")] - - /** - * @inheritDoc - * - * @default null - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function get numeric():Object - { - return _numeric; - } - - /** - * @deprecated A future release of Apache Flex SDK will remove this function. Please use the constructor - * argument instead. - */ - public function set numeric(value:Object):void - { - if (_numeric != value) - { - _numeric = value; - dispatchEvent(new Event("numericChanged")); - } - } - - - //--------------------------------- - // sortCompareType - //--------------------------------- - - // TODO: Currently the sortfield is independant of the column. Add in way to check when column._sortCompareType changes. - /** - * @private - */ - private var _sortCompareType:String = null; - - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 11.8 - * @playerversion AIR 3.8 - * @productversion Flex 4.11 - */ - [Bindable("sortCompareTypeChanged")] - public function get sortCompareType():String - { - return _sortCompareType; - } - - /** - * @deprecated A future release of Apache Flex SDK will remove this function. Please use the constructor - * argument instead. - */ - public function set sortCompareType(value:String):void - { - if (_sortCompareType != value) - { - _sortCompareType = value; - dispatchEvent(new Event("sortCompareTypeChanged")); - } - - - updateSortCompareType(); - } - - - //--------------------------------- - // usingCustomCompareFunction - //--------------------------------- - - private var _usingCustomCompareFunction:Boolean; - - /** - * @inheritDoc - * - * @see @compareFunction - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function get usingCustomCompareFunction():Boolean - { - return _usingCustomCompareFunction; - } //-------------------------------------------------------------------------- // @@ -514,11 +278,13 @@ public class SortField extends AdvancedStyleClient implements ISortField /** * @private + * + * Called by AdvancedStyleClientImplementation.as */ - override public function getStyle(styleProp:String):* + private function _getStyle(styleProp:String):* { if (styleProp != "locale") - return super.getStyle(styleProp); + return _advancedStyleClient.getStyle(styleProp); if ((localeStyle !== undefined) && (localeStyle !== null)) return localeStyle; @@ -537,15 +303,17 @@ public class SortField extends AdvancedStyleClient implements ISortField * Intercept style change for "locale". * * In the case that there is no associated UI component or the - * module factory of the UIComponent has not yet been intialized + * module factory of the UIComponent has not yet been initialized * style changes are only recorded but the styleChanged method * is not called. Overriding the setStyle method allows * the class to be updated immediately when the locale style is * set directly on this class instance. + * + * Called by AdvancedStyleClientImplementation.as */ - override public function setStyle(styleProp:String, newValue:*):void + private function _setStyle(styleProp:String, newValue:*):void { - super.setStyle(styleProp, newValue); + _advancedStyleClient.setStyle(styleProp, newValue); if (styleProp != "locale") return; @@ -565,6 +333,8 @@ public class SortField extends AdvancedStyleClient implements ISortField * updated the <code>change</code> event will be dispatched and * uses of the bindable methods or properties will be updated. * + * Called by AdvancedStyleClientImplementation.as + * * @param styleProp The name of the style property, or null if * all styles for this component have changed. * @@ -573,214 +343,12 @@ public class SortField extends AdvancedStyleClient implements ISortField * @playerversion AIR 2.5 * @productversion Flex 4.5 */ - override public function styleChanged(styleProp:String):void + private function _styleChanged(styleProp:String):void { localeChanged(); - super.styleChanged(styleProp); + _advancedStyleClient.styleChanged(styleProp); } - /** - * @private - * A pretty printer for Sort that lists the sort fields and their - * options. - */ - override public function toString():String - { - return ObjectUtil.toString(this); - } - - //-------------------------------------------------------------------------- - // - // Methods - // - //-------------------------------------------------------------------------- - - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function initializeDefaultCompareFunction(obj:Object):void - { - // if the compare function is not already set then we can set it - if (!usingCustomCompareFunction) - { - if (_sortCompareType) - { - //Attempt to set the compare function based on the sortCompareType - if (updateSortCompareType() == true) - { - return; - } - } - - if (numeric == true) - _compareFunction = numericCompare; - else if (numeric == false) - _compareFunction = stringCompare; - else - { - // we need to introspect the data a little bit - var value:Object; - if (_name) - { - try - { - value = obj[_name]; - } - catch(error:Error) - { - } - } - //this needs to be an == null check because !value will return true - //where value == 0 or value == false - if (value == null) - { - value = obj; - } - - var typ:String = typeof(value); - switch (typ) - { - case "string": - _compareFunction = stringCompare; - break; - case "object": - if (value is Date) - { - _compareFunction = dateCompare; - } - else - { - _compareFunction = stringCompare; - var test:String; - try - { - test = value.toString(); - } - catch(error2:Error) - { - } - if (!test || test == "[object Object]") - { - _compareFunction = nullCompare; - } - } - break; - case "xml": - _compareFunction = xmlCompare; - break; - case "boolean": - case "number": - _compareFunction = numericCompare; - break; - } - } // else - } // if - } - - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - public function reverse():void - { - descending = !descending; - } - - - /** - * @inheritDoc - * - * @langversion 3.0 - * @playerversion Flash 11.8 - * @playerversion AIR 3.8 - * @productversion Flex 4.11 - */ - public function updateSortCompareType():Boolean - { - if (!_sortCompareType) - { - return false; - } - - - //Lookup the sortCompareType by its SortFieldCompareTypes value and set the associated compare method. - switch(_sortCompareType) - { - case SortFieldCompareTypes.DATE: - { - _compareFunction = dateCompare; - - return true; - } - - case SortFieldCompareTypes.NULL: - { - _compareFunction = nullCompare; - - return true; - } - - case SortFieldCompareTypes.NUMERIC: - { - _compareFunction = numericCompare; - - return true; - } - - case SortFieldCompareTypes.STRING: - { - _compareFunction = stringCompare; - - return true; - } - - case SortFieldCompareTypes.XML: - { - _compareFunction = xmlCompare; - - return true; - } - } - - - return false; - } - - public function objectHasSortField(object:Object):Boolean - { - return getSortFieldValue(object) !== undefined; - } - - - //-------------------------------------------------------------------------- - // - // Protected Functions - // - //-------------------------------------------------------------------------- - - protected function getSortFieldValue(obj:Object):* - { - var result:Object = undefined; - - try - { - result = obj[_name]; - } - catch(error:Error) - { - } - - return result; - } //-------------------------------------------------------------------------- // @@ -855,152 +423,9 @@ public class SortField extends AdvancedStyleClient implements ISortField } } - private function nullCompare(a:Object, b:Object):int - { - var left:Object; - var right:Object; - - var found:Boolean = false; - - // return 0 (ie equal) if both are null - if (a == null && b == null) - { - return 0; - } - - // we need to introspect the data a little bit - if (_name) - { - try - { - left = a[_name]; - } - catch(error:Error) - { - } - - try - { - right = b[_name]; - } - catch(error:Error) - { - } - } - - // return 0 (ie equal) if both are null - if (left == null && right == null) - return 0; - - if (left == null && !_name) - left = a; - - if (right == null && !_name) - right = b; - - - var typeLeft:String = typeof(left); - var typeRight:String = typeof(right); - - - if (typeLeft == "string" || typeRight == "string") - { - found = true; - _compareFunction = stringCompare; - } - else if (typeLeft == "object" || typeRight == "object") - { - if (left is Date || right is Date) - { - found = true; - _compareFunction = dateCompare - } - } - else if (typeLeft == "xml" || typeRight == "xml") - { - found = true; - _compareFunction = xmlCompare; - } - else if (typeLeft == "number" || typeRight == "number" - || typeLeft == "boolean" || typeRight == "boolean") - { - found = true; - _compareFunction = numericCompare; - } - - if (found) - { - return _compareFunction(left, right); - } - else - { - var message:String = resourceManager.getString( - "collections", "noComparatorSortField", [ name ]); - throw new SortError(message); - } - } - - /** - * Pull the numbers from the objects and call the implementation. - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - private function numericCompare(a:Object, b:Object):int - { - var fa:Number; - try - { - fa = _name == null ? Number(a) : Number(a[_name]); - } - catch(error:Error) - { - } - - var fb:Number; - try - { - fb = _name == null ? Number(b) : Number(b[_name]); - } - catch(error:Error) - { - } - return ObjectUtil.numericCompare(fa, fb); - } - /** - * Pull the date objects from the values and compare them. - * - * @langversion 3.0 - * @playerversion Flash 10.1 - * @playerversion AIR 2.5 - * @productversion Flex 4.5 - */ - private function dateCompare(a:Object, b:Object):int - { - var fa:Date; - try - { - fa = _name == null ? a as Date : a[_name] as Date; - } - catch(error:Error) - { - } - - var fb:Date; - try - { - fb = _name == null ? b as Date : b[_name] as Date; - } - catch(error:Error) - { - } - return ObjectUtil.dateCompare(fa, fb); - } /** * Pull the strings from the objects and call the implementation. @@ -1010,25 +435,10 @@ public class SortField extends AdvancedStyleClient implements ISortField * @playerversion AIR 2.5 * @productversion Flex 4.5 */ - private function stringCompare(a:Object, b:Object):int + override protected function stringCompare(a:Object, b:Object):int { - var fa:String; - try - { - fa = _name == null ? String(a) : String(a[_name]); - } - catch(error:Error) - { - } - - var fb:String; - try - { - fb = _name == null ? String(b) : String(b[_name]); - } - catch(error:Error) - { - } + var fa:String = name == null ? String(a) : String(getSortFieldValue(a)); + var fb:String = name == null ? String(b) : String(getSortFieldValue(b)); return stringCollator.compare(fa, fb); } @@ -1043,25 +453,10 @@ public class SortField extends AdvancedStyleClient implements ISortField * @playerversion AIR 2.5 * @productversion Flex 4.5 */ - private function xmlCompare(a:Object, b:Object):int + override protected function xmlCompare(a:Object, b:Object):int { - var sa:String; - try - { - sa = _name == null ? a.toString() : a[_name].toString(); - } - catch(error:Error) - { - } - - var sb:String; - try - { - sb = _name == null ? b.toString() : b[_name].toString(); - } - catch(error:Error) - { - } + var sa:String = name == null ? a.toString() : getSortFieldValue(a).toString(); + var sb:String = name == null ? b.toString() : getSortFieldValue(b).toString(); if (numeric == true) { @@ -1086,12 +481,12 @@ public class SortField extends AdvancedStyleClient implements ISortField */ private function localeChanged():void { - const newlocaleStyle:* = super.getStyle("locale"); + const newLocaleStyle:* = _advancedStyleClient.getStyle("locale"); - if (localeStyle === newlocaleStyle) + if (localeStyle === newLocaleStyle) return; - localeStyle = newlocaleStyle; + localeStyle = newLocaleStyle; if (internalStringCollator) { http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/71f87576/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 6aefbe3..3d5a04f 100644 --- a/frameworks/projects/spark/src/spark/components/DataGrid.as +++ b/frameworks/projects/spark/src/spark/components/DataGrid.as @@ -19,72 +19,70 @@ package spark.components { -import flash.display.DisplayObject; -import flash.display.Graphics; -import flash.events.Event; -import flash.events.FocusEvent; -import flash.events.KeyboardEvent; -import flash.events.MouseEvent; -import flash.geom.Point; -import flash.geom.Rectangle; -import flash.ui.Keyboard; + import flash.display.DisplayObject; + import flash.display.Graphics; + import flash.events.Event; + import flash.events.FocusEvent; + import flash.events.KeyboardEvent; + import flash.events.MouseEvent; + import flash.geom.Point; + import flash.geom.Rectangle; + import flash.ui.Keyboard; -import mx.collections.ArrayCollection; -import mx.collections.ICollectionView; -import mx.collections.IList; -import mx.collections.ISort; -import mx.collections.ISortField; -import mx.core.DragSource; -import mx.core.EventPriority; -import mx.core.IFactory; -import mx.core.IFlexDisplayObject; -import mx.core.IIMESupport; -import mx.core.IUID; -import mx.core.IVisualElement; -import mx.core.InteractionMode; -import mx.core.LayoutDirection; -import mx.core.ScrollPolicy; -import mx.core.UIComponent; -import mx.core.mx_internal; -import mx.events.DragEvent; -import mx.events.FlexEvent; -import mx.events.SandboxMouseEvent; -import mx.events.TouchInteractionEvent; -import mx.managers.CursorManager; -import mx.managers.CursorManagerPriority; -import mx.managers.DragManager; -import mx.managers.IFocusManagerComponent; -import mx.styles.AdvancedStyleClient; -import mx.utils.ObjectUtil; -import mx.utils.UIDUtil; + import mx.collections.ArrayCollection; + import mx.collections.ICollectionView; + import mx.collections.IList; + import mx.collections.ISort; + import mx.collections.ISortField; + import mx.core.DragSource; + import mx.core.EventPriority; + import mx.core.IFactory; + import mx.core.IFlexDisplayObject; + import mx.core.IIMESupport; + import mx.core.IUID; + import mx.core.IVisualElement; + import mx.core.InteractionMode; + import mx.core.LayoutDirection; + import mx.core.ScrollPolicy; + import mx.core.UIComponent; + import mx.core.mx_internal; + import mx.events.DragEvent; + import mx.events.FlexEvent; + import mx.events.SandboxMouseEvent; + import mx.events.TouchInteractionEvent; + import mx.managers.CursorManager; + import mx.managers.CursorManagerPriority; + import mx.managers.DragManager; + import mx.managers.IFocusManagerComponent; + import mx.styles.IAdvancedStyleClient; + import mx.utils.ObjectUtil; + import mx.utils.UIDUtil; -import spark.collections.Sort; -import spark.components.gridClasses.CellPosition; -import spark.components.gridClasses.CellRegion; -import spark.components.gridClasses.DataGridEditor; -import spark.components.gridClasses.GridDoubleClickMode; -import spark.components.gridClasses.GridColumn; -import spark.components.gridClasses.GridHeaderLayout; -import spark.components.gridClasses.GridItemEditorActivationMouseEvent; -import spark.components.gridClasses.GridLayout; -import spark.components.gridClasses.GridSelection; -import spark.components.gridClasses.GridSelectionMode; -import spark.components.gridClasses.GridSortField; -import spark.components.gridClasses.GridView; -import spark.components.gridClasses.IDataGridElement; -import spark.components.gridClasses.IGridItemEditor; -import spark.components.supportClasses.IDataProviderEnhance; -import spark.components.supportClasses.RegExPatterns; -import spark.components.supportClasses.SkinnableContainerBase; -import spark.core.NavigationUnit; -import spark.events.GridCaretEvent; -import spark.events.GridEvent; -import spark.events.GridSelectionEvent; -import spark.events.GridSelectionEventKind; -import spark.events.GridSortEvent; -import spark.layouts.supportClasses.DropLocation; + import spark.collections.Sort; + import spark.components.gridClasses.CellPosition; + import spark.components.gridClasses.CellRegion; + import spark.components.gridClasses.DataGridEditor; + import spark.components.gridClasses.GridColumn; + import spark.components.gridClasses.GridItemEditorActivationMouseEvent; + import spark.components.gridClasses.GridLayout; + import spark.components.gridClasses.GridSelection; + import spark.components.gridClasses.GridSelectionMode; + import spark.components.gridClasses.GridSortField; + import spark.components.gridClasses.GridView; + import spark.components.gridClasses.IDataGridElement; + import spark.components.gridClasses.IGridItemEditor; + import spark.components.supportClasses.IDataProviderEnhance; + import spark.components.supportClasses.RegExPatterns; + import spark.components.supportClasses.SkinnableContainerBase; + import spark.core.NavigationUnit; + import spark.events.GridCaretEvent; + import spark.events.GridEvent; + import spark.events.GridSelectionEvent; + import spark.events.GridSelectionEventKind; + import spark.events.GridSortEvent; + import spark.layouts.supportClasses.DropLocation; -use namespace mx_internal; + use namespace mx_internal; //-------------------------------------- // Styles @@ -1022,7 +1020,7 @@ public class DataGrid extends SkinnableContainerBase * @playerversion AIR 2.5 * @productversion Flex 4.5 */ - public var grid:spark.components.Grid; + public var grid:Grid; //---------------------------------- // hoverIndicator @@ -4971,7 +4969,7 @@ public class DataGrid extends SkinnableContainerBase { for each (var oldSortField:ISortField in oldSortFields) { - var oldASC:AdvancedStyleClient = oldSortField as AdvancedStyleClient; + var oldASC:IAdvancedStyleClient = oldSortField as IAdvancedStyleClient; if (!oldASC || (oldASC.styleParent != this) || (sortFields.indexOf(oldASC) != -1)) continue; removeStyleClient(oldASC); @@ -4983,7 +4981,7 @@ public class DataGrid extends SkinnableContainerBase for each (var newSortField:ISortField in sortFields) { - var newASC:AdvancedStyleClient = newSortField as AdvancedStyleClient; + var newASC:IAdvancedStyleClient = newSortField as IAdvancedStyleClient; if (!newASC || (newASC.styleParent == this)) continue; addStyleClient(newASC);
