You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/12/21 19:05:22 UTC

svn commit: r1425063 [1/13] - in /incubator/flex/sdk/branches/develop: frameworks/ frameworks/projects/spark/ frameworks/projects/spark/src/ frameworks/projects/spark/src/spark/collections/ frameworks/projects/spark/src/spark/components/ frameworks/pro...

Author: cframpton
Date: Fri Dec 21 18:05:20 2012
New Revision: 1425063

URL: http://svn.apache.org/viewvc?rev=1425063&view=rev
Log:
FLEX-33328 - Merge Adobe.next bug fixes and new features into spark DataGrid.  The new features include the new properties lockedRowCount, lockedColumnCount, multiColumnSortingEnabled, and moving and sorting columns via the keyboard.  The DataGrid does size a bit differently mostly due to bug fixes. The skin changed because of new parts introduced for the locked rows and columns so custom skins need to be upgraded which is easy to do.  

The mustella tests for the existing features pass on OSX.  No mustella tests have been added yet for the new features.

The new features may need a bit more work but given all the existing tests pass the DataGrid should be pretty stable if you don't use any of the new features.

Added:
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/DataGridDragProxy.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderView.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensionsView.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderLayout.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridHeaderViewLayout.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditorActivationMouseEvent.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridView.as   (with props)
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridViewLayout.as   (with props)
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_focusIn_multiline_test_1.png   (with props)
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_focusIn_multiline_test_2.png   (with props)
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/DataGrid_itemEditor.compile
Removed:
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumnHeaderGroupLayout.as
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_focusIn_multiline_test.png
Modified:
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/defaults.css
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/SparkClasses.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/DataGrid.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/Grid.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/GridColumnHeaderGroup.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridColumn.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridDimensions.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridLayer.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridLayout.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/GridSelection.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/components/gridClasses/IGridItemEditor.as
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/skins/spark/DataGridSkin.mxml
    incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/skins/spark/DefaultGridHeaderRenderer.mxml
    incubator/flex/sdk/branches/develop/frameworks/projects/wireframe/src/spark/skins/wireframe/DataGridSkin.mxml
    incubator/flex/sdk/branches/develop/frameworks/spark-manifest.xml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Events/DataGrid_Events_basic01.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/complex_dataField_sort_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/dataFormatter_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/invalidateCell_dataIconChange.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/invalidateCell_rendererChange.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRendererFunction_differentRenderer_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRendererFunction_differentRenderer_test_checkBoxRenderer.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRendererFunction_differentRenderer_test_dropListRenderer.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRendererFunction_differentRenderer_test_labelRenderer.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRenderer_update_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRenderer_update_test_checkBoxRenderer.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRenderer_update_test_dropListRenderer.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/itemRenderer_update_test_labelRenderer.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/labelFunction_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/requestedRCs_Neg1_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/sparkSort_arrayList_test001_firstName.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/sparkSort_arrayList_test001_lastName.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/typicalItem_setter_noData_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/typicalItem_setter_smallWidth_test001_notypicalItem.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/typicalItem_winOver_RequestRCNeg1_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/typicalItem_winOver_RequestRCNeg1_test002_noTypicalItem.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Integrations/Baselines/typicalItem_winOver_RequestRC_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Interaction/DataGrid_keys_basic03.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/CHG_invisibleColumn_test001_c1invisible.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/CHG_invisibleColumn_test001_c1visible.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/CHG_invisibleColumn_test002_c1invisible.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_col1VisibleFalse_1.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_col1col2VisibleFalse.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_customSkin_selectionLayerTop.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_default_typItem_columnsAtRuntime1.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_gridIR_default.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_gridIR_typItem.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_preInit_misc.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_preInit_misc2.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_preInit_setSelectedCell.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_preInit_setSelectedCells.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_preInit_setSelectedIndex.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_preInit_setSelectedIndices.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_stateColumn_1.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_typicalItem_changedAtRuntimeExpWidth.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/DataGrid_Properties_typicalItem_reqRowCol_default.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_multiline_true_explicit_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_startEditMode_Tabbing.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_style_test_green.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_style_test_red.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_variableRowHeight_large.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Editable_variableRowHeight_small.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Mirroring_rtl_editor_test1.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC01.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC04.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC05.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC06.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC07_afterColumnChg.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC10.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC11.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC12.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC13.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Properties_dataProvider_XMLLC14.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_Columns_test001_ascending.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_Columns_test001_descending.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_Columns_test002_replace.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_Columns_test002_update.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_dataProvider_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_dataProvider_test001_reverse.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_onColumns_test001_ascending.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_onColumns_test001_descending.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_sortByColumns_sortInvalidUpdated.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_sortByColumns_sortUpdated.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_sortIndicator_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/Sort_sortIndicator_test001_2.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/column_withRenderer_test001_lastPage.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/column_withRenderer_test001_page1.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/dataProvider_nodata_test5.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/dataProvider_scrollbar_test1_scrollBar.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/dataProvider_scrollbar_test3_scrollBar.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/key_navigation_on_ComboBoxEditor_index2.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/key_navigation_on_ComboBoxEditor_index3.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/Baselines/key_tabbing_navigation.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/DataGrid_Properties_colResize.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/DataGrid_Properties_editable.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/DataGrid_Properties_sortable.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/DataGrid_Properties_visible.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Properties/DataGrid_dataProvider_test002.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/DataGrid_basic_001.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/DataGrid_itemEditor.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/assets/skins/CustomDataGridLargeGridLinesSkin.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/assets/skins/CustomDataGridLiveScrollingFalseSkin.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/assets/skins/CustomDataGridNoGridLinesSkin.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/assets/skins/CustomDataGridselLyrTopSkin.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/SWFs/components/DataGrid_editable_size.mxml
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_AlternatingRowColor_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_addRemoveRow_test_addFirstRow.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_addRemoveRow_test_removeFirstRow.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_getsetter_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_property_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_skin_rowChange_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_skin_rowChange_test_addRow.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_skin_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/rowBackground_update_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_borderAlpha_test001_zero.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_borderAlpha_test002_half.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_borderVisible_test001_hide.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_direction_locale_IR_test001.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_direction_locale_IR_test002.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_others_test.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_symbolColor_editor.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/Baselines/style_textAlign_test_start.png
    incubator/flex/sdk/branches/develop/mustella/tests/gumbo/components/DataGrid/Styles/DataGrid_Styles_basic.mxml

Modified: incubator/flex/sdk/branches/develop/frameworks/projects/spark/defaults.css
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/spark/defaults.css?rev=1425063&r1=1425062&r2=1425063&view=diff
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/spark/defaults.css (original)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/spark/defaults.css Fri Dec 21 18:05:20 2012
@@ -67,6 +67,8 @@ ComboBox
 
 DataGrid
 {
+    dragIndicatorClass: ClassReference("spark.components.gridClasses.DataGridDragProxy");
+    dropIndicatorSkin: ClassReference("spark.skins.spark.ListDropIndicator");
     skinClass: ClassReference("spark.skins.spark.DataGridSkin");
     stretchCursor: Embed(source="Assets.swf",symbol="cursorStretch");    
 }

Modified: incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/SparkClasses.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/SparkClasses.as?rev=1425063&r1=1425062&r2=1425063&view=diff
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/SparkClasses.as (original)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/SparkClasses.as Fri Dec 21 18:05:20 2012
@@ -44,6 +44,7 @@ import spark.components.IconPlacement; I
 import spark.components.calendarClasses.DateSelectorDisplayMode; DateSelectorDisplayMode;
 import spark.components.gridClasses.CellPosition; CellPosition;
 import spark.components.gridClasses.CellRegion; CellRegion;
+import spark.components.gridClasses.DataGridDragProxy; DataGridDragProxy;
 import spark.components.supportClasses.ListItemDragProxy; ListItemDragProxy;
 import spark.components.supportClasses.InteractionStateDetector; InteractionStateDetector;
 import spark.globalization.supportClasses.CalendarDate; CalendarDate;

Added: incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as?rev=1425063&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as (added)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as Fri Dec 21 18:05:20 2012
@@ -0,0 +1,405 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 flash.events.Event;
+import flash.events.EventDispatcher;
+
+import mx.collections.IList;
+import mx.events.CollectionEvent;
+import mx.events.CollectionEventKind;
+
+[ExcludeClass]
+
+/**
+ *  A "view" of a contiguous IList interval that begins at startIndex and extends for count items.
+ * 
+ *  The list item index parameter for IList methods like getItemAt(index) are defined relative to 
+ *  this SubListView.   For example the SubListView definition of getItemAt(0) is defined as 
+ *  list.getItemAt(startIndex).  Similarly returned index values and the location CollectionEvent 
+ *  property are defined relative to the SubListView.   In all other respects paraters, return values,
+ *  and events, have the same semantics as defined for IList.
+ *  
+ *  This class is internal to the Grid implementation.
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 11
+ *  @playerversion AIR 3
+ *  @productversion Flex 5.0* 
+ */
+public class SubListView extends EventDispatcher implements IList
+{
+    /**
+     *  Construct a SubListView and optionally specify the target list and the item interval
+     *  this SubListView spans.
+     */
+    public function SubListView(list:IList = null, startIndex:int = 0, count:int = -1)
+    {
+        super();
+        this.list = list;
+        this.startIndex = startIndex;
+        this.count = count;
+    }
+    
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+    
+    /**
+     *  @private
+     */
+    private function dispatchChangeEvent(type:String):void
+    {
+        if (hasEventListener(type))
+            dispatchEvent(new Event(type));
+    }
+    
+    /**
+     *  @private
+     */
+    private function dispatchCollectionResetEvent():void
+    {
+        if (hasEventListener(CollectionEvent.COLLECTION_CHANGE))
+            dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE, false, false, CollectionEventKind.RESET));            
+    }      
+    
+    //----------------------------------
+    //  list
+    //----------------------------------
+    
+    private var _list:IList;
+    
+    [Inspectable(category="General")]
+    [Bindable("listChanged")]
+    
+    /**
+     *  The IList to which all of IList methods are delegated.
+     * 
+     *  <p>If this property is null, the IList mutation methods, such as <code>setItemAt()</code>,
+     *  are no-ops. The IList query methods, such <code>getItemAt()</code>, return null
+     *  or zero (-1 for <code>getItemIndex()</code>), as appropriate.</p>
+     * 
+     *  @default null  
+     */
+    public function get list():IList
+    {
+        return _list;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set list(value:IList):void
+    {
+        if (_list == value)
+            return;
+        
+        if (_list)
+            _list.removeEventListener(CollectionEvent.COLLECTION_CHANGE, handleCollectionChangeEvent);
+        _list = value;
+        if (_list)
+            _list.addEventListener(CollectionEvent.COLLECTION_CHANGE, handleCollectionChangeEvent, false, 0, true);
+        
+        dispatchChangeEvent("listChanged");
+        dispatchCollectionResetEvent();
+    }
+	
+    //----------------------------------
+    //  startIndex
+    //----------------------------------
+    
+    private var _startIndex:int = 0;  // Typically this value is >= 0
+    
+    [Inspectable(category="General")]
+    [Bindable("startIndexChanged")]
+    
+    /**
+     *  The index of the first list item included by this SubListView.
+     * 
+     *  @default 0
+     */
+    public function get startIndex():int
+    {
+        return _startIndex;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set startIndex(value:int):void
+    {
+        if (_startIndex == value)
+            return;
+        
+        _startIndex = value;
+        
+        dispatchChangeEvent("startIndexChanged");
+        dispatchCollectionResetEvent();
+    }
+    
+    //----------------------------------
+    //  count
+    //----------------------------------
+    
+    private var _count:int = -1;  
+    
+    [Inspectable(category="General")]
+    [Bindable("countChanged")]
+    
+    /**
+     *  The number of items to be included in this SubListView or -1, which means
+     *  that all items, beginning with the one at startIndex, are to be included.
+     * 
+     *  @default -1
+     */
+    public function get count():int
+    {
+        return _count;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set count(value:int):void
+    {
+        if (_count == value)
+            return;
+        
+        _count = value;
+        
+        dispatchChangeEvent("countChanged");
+        dispatchCollectionResetEvent();
+    }
+    
+    
+    //--------------------------------------------------------------------------
+    //
+    //  CollectionEvent.COLLECTION_CHANGE Handlers
+    //
+    //-------------------------------------------------------------------------- 
+    
+    /**
+     *  @private
+     *  All "collectionChange" events are redispatched to the SubListView listeners.
+     */
+    private function handleCollectionChangeEvent(event:CollectionEvent):void
+    {
+        var viewEvent:CollectionEvent = null;
+        var location:int = event.location;
+        
+        switch (event.kind)
+        {
+            case CollectionEventKind.ADD:
+            case CollectionEventKind.REMOVE: 
+            {
+                viewEvent = handleModifyCollectionChangeEvent(event);
+                break;
+            }
+                
+            case CollectionEventKind.REPLACE:
+            case CollectionEventKind.UPDATE:
+            {
+                viewEvent = handleUpdateCollectionChangeEvent(event);
+                break;
+            }                
+                
+            case CollectionEventKind.MOVE:
+            {
+                // TBD: may require synthesizing add and/or remove events
+                break;
+            }
+                
+            default:  // refresh, reset, null
+            {
+                viewEvent = event;
+                break;
+            }
+        }		
+        
+        if (viewEvent)
+            dispatchEvent(viewEvent);
+    }
+    
+    /**
+     *  @private
+     */    
+    private function createCollectionEvent(kind:String):CollectionEvent
+    {
+        return new CollectionEvent(CollectionEvent.COLLECTION_CHANGE, false, false, kind);
+    }  
+    
+    /**
+     *  @private
+     *  This method is called after (the underlying) list has been modified via add/remove.
+     * 
+     *  The incoming event.location is the list modification start point, event.items is the 
+     *  array of items that were inserted/removed/replaced.
+     * 
+     *  Returned event (if any) is a refresh if the insert was "to the left of" this SubListView,
+     *  or a potentially truncated version of the insert was within the SubListView.
+     */
+    private function handleModifyCollectionChangeEvent(event:CollectionEvent):CollectionEvent
+    {
+        const viewEnd:int = startIndex + length;
+        
+        //  is "to the right of" the SubListView
+        
+        if (event.location >= viewEnd) 
+            return null;
+        
+        // Insert is "to the left of" the SubListView; entire SubListView shifts 
+        
+        if (event.location <= startIndex) 
+            return createCollectionEvent(CollectionEventKind.REFRESH);
+        
+        // Insert is within the SubListView
+        
+        const viewEvent:CollectionEvent = createCollectionEvent(event.kind);
+        viewEvent.location = event.location - startIndex;
+        
+        const items:Array = new Array();
+        viewEvent.items = items;
+        
+        var location:int = event.location;
+        for each (var item:Object in event.items)
+        {
+            items.push(item);
+            if (location++ >= viewEnd)
+                break;
+        }        
+
+        return viewEvent;
+    } 
+    
+    /**
+     *  @private
+     *  This method is called after (the underlying) list has been modified via update/replace.
+     *  This case is different than add/remove because the item locations do not change.
+     * 
+     *  The incoming event.location is the list modification start point, event.items is the 
+     *  array of PropertyChangeEvents that characterize the old and new item values.
+     * 
+     */
+    private function handleUpdateCollectionChangeEvent(event:CollectionEvent):CollectionEvent
+    {
+        const viewEnd:int = startIndex + length;
+        
+        // Update/replace doesn't overlap this SubListView
+        
+        if (((event.location + event.items.length) < startIndex) || (event.location >= viewEnd))
+            return null;
+        
+        const viewEvent:CollectionEvent = createCollectionEvent(event.kind);
+        var viewLocation:int = Math.max(startIndex, event.location);
+        viewEvent.location = viewLocation - startIndex;
+        
+        const items:Array = new Array();
+        viewEvent.items = items;
+        
+        for each (var item:Object in event.items)
+        {
+            items.push(item);
+            if (viewLocation++ >= viewEnd)
+                break;
+        }        
+        
+        return viewEvent;
+    } 
+        
+    //--------------------------------------------------------------------------
+    //
+    //  IList Implementation
+    //
+    //--------------------------------------------------------------------------
+    
+    [Bindable("collectionChange")]
+    
+    public function get length():int
+    {
+        if (count == -1)
+            return (list) ? list.length - startIndex : 0; 
+        
+        return count;
+    }
+    
+    public function addItem(item:Object):void
+    {
+        if (list)
+            list.addItem(item);
+    }
+    
+    public function addItemAt(item:Object, index:int):void
+    {
+        if (list)
+            list.addItemAt(item, index + startIndex);
+    }
+    
+    public function getItemAt(index:int, prefetch:int=0):Object
+    {
+        return (list) ? list.getItemAt(index + startIndex, prefetch) : null;
+    }
+    
+    public function getItemIndex(item:Object):int
+    {
+        if (!list || (count == 0))
+            return -1;
+        
+        const index:int = list.getItemIndex(item);
+        return ((index < startIndex) || (index >= (startIndex + length))) ? -1 : index - startIndex;
+    }
+    
+    public function itemUpdated(item:Object, property:Object=null, oldValue:Object=null, newValue:Object=null):void
+    {
+        if (list)
+            list.itemUpdated(item, property, oldValue, newValue);        
+    }
+    
+    public function removeAll():void
+    {
+        if (list)
+            list.removeAll();
+    }
+    
+    public function removeItemAt(index:int):Object
+    {
+        return (list) ? list.removeItemAt(startIndex + index) : null;
+    }
+    
+    public function setItemAt(item:Object, index:int):Object
+    {
+        return (list) ? list.setItemAt(item, startIndex + index) : null;
+    }
+    
+    public function toArray():Array
+    {
+        if (!list)
+            return [];
+        
+        const a:Array = new Array(length);
+		const aCount:int = Math.min(a.length, list.length - startIndex);
+        for(var i:int = 0; i < aCount; i++)
+            a[i] = list.getItemAt(i + startIndex);
+        return a;
+    }
+    
+}
+}

Propchange: incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/flex/sdk/branches/develop/frameworks/projects/spark/src/spark/collections/SubListView.as
------------------------------------------------------------------------------
    svn:mime-type = text/plain