home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / collections / ModifiedCollectionView.as < prev    next >
Encoding:
Text File  |  2011-11-11  |  26.7 KB  |  847 lines

  1. package mx.collections
  2. {
  3.    import flash.events.Event;
  4.    import flash.utils.Dictionary;
  5.    import mx.collections.errors.CollectionViewError;
  6.    import mx.core.mx_internal;
  7.    import mx.events.CollectionEvent;
  8.    import mx.events.CollectionEventKind;
  9.    import mx.events.PropertyChangeEvent;
  10.    import mx.resources.IResourceManager;
  11.    import mx.resources.ResourceManager;
  12.    
  13.    use namespace mx_internal;
  14.    
  15.    public class ModifiedCollectionView implements ICollectionView
  16.    {
  17.       mx_internal static const VERSION:String = "4.5.0.20967";
  18.       
  19.       public static const REMOVED:String = "removed";
  20.       
  21.       public static const ADDED:String = "added";
  22.       
  23.       public static const REPLACED:String = "replaced";
  24.       
  25.       public static const REPLACEMENT:String = "replacement";
  26.       
  27.       private var resourceManager:IResourceManager = ResourceManager.getInstance();
  28.       
  29.       private var list:ICollectionView;
  30.       
  31.       private var deltaLength:int = 0;
  32.       
  33.       private var deltas:Array = [];
  34.       
  35.       private var removedItems:Dictionary = new Dictionary(true);
  36.       
  37.       private var addedItems:Dictionary = new Dictionary(true);
  38.       
  39.       private var replacedItems:Dictionary = new Dictionary(true);
  40.       
  41.       private var replacementItems:Dictionary = new Dictionary(true);
  42.       
  43.       private var itemWrappersByIndex:Array = [];
  44.       
  45.       private var itemWrappersByCollectionMod:Dictionary = new Dictionary(true);
  46.       
  47.       private var _showPreserved:Boolean = false;
  48.       
  49.       public function ModifiedCollectionView(param1:ICollectionView)
  50.       {
  51.          super();
  52.          this.list = param1;
  53.       }
  54.       
  55.       public function get length() : int
  56.       {
  57.          return this.list.length + (this._showPreserved ? this.deltaLength : 0);
  58.       }
  59.       
  60.       public function get filterFunction() : Function
  61.       {
  62.          return null;
  63.       }
  64.       
  65.       public function set filterFunction(param1:Function) : void
  66.       {
  67.       }
  68.       
  69.       public function disableAutoUpdate() : void
  70.       {
  71.       }
  72.       
  73.       public function createCursor() : IViewCursor
  74.       {
  75.          var _loc1_:IViewCursor = this.list.createCursor();
  76.          var _loc2_:Object = _loc1_.current;
  77.          return new ModifiedCollectionViewCursor(this,_loc1_,_loc2_);
  78.       }
  79.       
  80.       public function contains(param1:Object) : Boolean
  81.       {
  82.          return false;
  83.       }
  84.       
  85.       public function get sort() : ISort
  86.       {
  87.          return null;
  88.       }
  89.       
  90.       public function set sort(param1:ISort) : void
  91.       {
  92.       }
  93.       
  94.       public function itemUpdated(param1:Object, param2:Object = null, param3:Object = null, param4:Object = null) : void
  95.       {
  96.       }
  97.       
  98.       public function refresh() : Boolean
  99.       {
  100.          return false;
  101.       }
  102.       
  103.       public function enableAutoUpdate() : void
  104.       {
  105.       }
  106.       
  107.       public function hasEventListener(param1:String) : Boolean
  108.       {
  109.          return false;
  110.       }
  111.       
  112.       public function willTrigger(param1:String) : Boolean
  113.       {
  114.          return false;
  115.       }
  116.       
  117.       public function addEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
  118.       {
  119.       }
  120.       
  121.       public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
  122.       {
  123.       }
  124.       
  125.       public function dispatchEvent(param1:Event) : Boolean
  126.       {
  127.          return false;
  128.       }
  129.       
  130.       mx_internal function getBookmark(param1:ModifiedCollectionViewCursor) : ModifiedCollectionViewBookmark
  131.       {
  132.          var _loc4_:String = null;
  133.          var _loc2_:int = param1.mx_internal::currentIndex;
  134.          if(_loc2_ < 0 || _loc2_ > this.length)
  135.          {
  136.             _loc4_ = this.resourceManager.getString("collections","invalidIndex",[_loc2_]);
  137.             throw new CollectionViewError(_loc4_);
  138.          }
  139.          var _loc3_:Object = param1.current;
  140.          return new ModifiedCollectionViewBookmark(_loc3_,this,0,_loc2_,param1.internalCursor.bookmark,param1.internalIndex);
  141.       }
  142.       
  143.       mx_internal function getBookmarkIndex(param1:CursorBookmark) : int
  144.       {
  145.          var _loc3_:String = null;
  146.          if(!(param1 is ModifiedCollectionViewBookmark) || ModifiedCollectionViewBookmark(param1).mx_internal::view != this)
  147.          {
  148.             _loc3_ = this.resourceManager.getString("collections","bookmarkNotFound");
  149.             throw new CollectionViewError(_loc3_);
  150.          }
  151.          var _loc2_:ModifiedCollectionViewBookmark = ModifiedCollectionViewBookmark(param1);
  152.          return _loc2_.mx_internal::index;
  153.       }
  154.       
  155.       mx_internal function getWrappedItemUsingCursor(param1:ModifiedCollectionViewCursor, param2:int) : Object
  156.       {
  157.          var _loc6_:CollectionModification = null;
  158.          var _loc9_:Object = null;
  159.          var _loc3_:int = param2;
  160.          var _loc4_:Object = null;
  161.          var _loc5_:CollectionModification = null;
  162.          var _loc7_:Boolean = false;
  163.          var _loc8_:int = 0;
  164.          while(_loc8_ < this.deltas.length)
  165.          {
  166.             _loc6_ = this.deltas[_loc8_];
  167.             if(_loc3_ < _loc6_.index)
  168.             {
  169.                break;
  170.             }
  171.             if(_loc6_.modificationType == CollectionModification.REPLACE)
  172.             {
  173.                if(_loc3_ == _loc6_.index && _loc6_.showOldReplace && this._showPreserved)
  174.                {
  175.                   _loc5_ = _loc6_;
  176.                   break;
  177.                }
  178.                if(_loc3_ == _loc6_.index + 1 && _loc6_.showOldReplace && _loc6_.showNewReplace && this._showPreserved)
  179.                {
  180.                   _loc3_--;
  181.                   _loc7_ = true;
  182.                   break;
  183.                }
  184.                if(_loc3_ == _loc6_.index && (!_loc6_.showOldReplace && _loc6_.showNewReplace || !this._showPreserved))
  185.                {
  186.                   _loc7_ = true;
  187.                   break;
  188.                }
  189.                _loc3_ -= _loc6_.modCount;
  190.             }
  191.             else if(this.isActive(_loc6_))
  192.             {
  193.                if(_loc3_ == _loc6_.index && _loc6_.isRemove)
  194.                {
  195.                   _loc5_ = _loc6_;
  196.                   break;
  197.                }
  198.                if(_loc3_ >= _loc6_.index)
  199.                {
  200.                   _loc3_ -= _loc6_.modCount;
  201.                }
  202.             }
  203.             _loc8_++;
  204.          }
  205.          if(_loc5_)
  206.          {
  207.             _loc4_ = _loc5_.item;
  208.          }
  209.          else
  210.          {
  211.             param1.internalCursor.seek(CursorBookmark.CURRENT,_loc3_ - param1.internalIndex);
  212.             _loc4_ = param1.internalCursor.current;
  213.             param1.internalIndex = _loc3_;
  214.          }
  215.          if(_loc6_ && _loc3_ == _loc6_.index && _loc6_.modificationType == CollectionModification.ADD)
  216.          {
  217.             _loc9_ = this.getUniqueItemWrapper(_loc4_,_loc6_,_loc3_);
  218.          }
  219.          else
  220.          {
  221.             _loc9_ = this.getUniqueItemWrapper(_loc4_,_loc5_,_loc3_);
  222.          }
  223.          return _loc9_;
  224.       }
  225.       
  226.       public function get showPreservedState() : Boolean
  227.       {
  228.          return this._showPreserved;
  229.       }
  230.       
  231.       public function set showPreservedState(param1:Boolean) : void
  232.       {
  233.          this._showPreserved = param1;
  234.       }
  235.       
  236.       public function getSemantics(param1:ItemWrapper) : String
  237.       {
  238.          if(this.removedItems[param1])
  239.          {
  240.             return ModifiedCollectionView.REMOVED;
  241.          }
  242.          if(this.addedItems[param1])
  243.          {
  244.             return ModifiedCollectionView.ADDED;
  245.          }
  246.          if(this.replacedItems[param1])
  247.          {
  248.             return ModifiedCollectionView.REPLACED;
  249.          }
  250.          if(this.replacementItems[param1])
  251.          {
  252.             return ModifiedCollectionView.REPLACEMENT;
  253.          }
  254.          return null;
  255.       }
  256.       
  257.       public function processCollectionEvent(param1:CollectionEvent, param2:int, param3:int) : void
  258.       {
  259.          switch(param1.kind)
  260.          {
  261.             case CollectionEventKind.ADD:
  262.                this.integrateAddedElements(param1,param2,param3);
  263.                break;
  264.             case CollectionEventKind.REMOVE:
  265.                this.integrateRemovedElements(param1,param2,param3);
  266.                break;
  267.             case CollectionEventKind.REPLACE:
  268.                this.integrateReplacedElements(param1,param2,param3);
  269.          }
  270.       }
  271.       
  272.       public function removeItem(param1:ItemWrapper) : void
  273.       {
  274.          var _loc2_:CollectionModification = this.removedItems[param1] as CollectionModification;
  275.          if(!_loc2_)
  276.          {
  277.             _loc2_ = this.replacedItems[param1] as CollectionModification;
  278.             if(_loc2_)
  279.             {
  280.                delete this.replacedItems[param1];
  281.                _loc2_.stopShowingReplacedValue();
  282.                --this.deltaLength;
  283.                if(_loc2_.modCount == 0)
  284.                {
  285.                   this.removeModification(_loc2_);
  286.                }
  287.             }
  288.          }
  289.          else if(this.removeModification(_loc2_))
  290.          {
  291.             delete this.removedItems[param1];
  292.             --this.deltaLength;
  293.          }
  294.       }
  295.       
  296.       public function addItem(param1:ItemWrapper) : void
  297.       {
  298.          var _loc2_:CollectionModification = this.addedItems[param1] as CollectionModification;
  299.          if(!_loc2_)
  300.          {
  301.             _loc2_ = this.replacementItems[param1] as CollectionModification;
  302.             if(_loc2_)
  303.             {
  304.                _loc2_.startShowingReplacementValue();
  305.                ++this.deltaLength;
  306.                if(_loc2_.modCount == 0)
  307.                {
  308.                   this.removeModification(_loc2_);
  309.                }
  310.             }
  311.          }
  312.          else if(this.removeModification(_loc2_))
  313.          {
  314.             ++this.deltaLength;
  315.          }
  316.       }
  317.       
  318.       private function isActive(param1:CollectionModification) : Boolean
  319.       {
  320.          return this._showPreserved;
  321.       }
  322.       
  323.       private function removeModification(param1:CollectionModification) : Boolean
  324.       {
  325.          var _loc2_:int = 0;
  326.          while(_loc2_ < this.deltas.length)
  327.          {
  328.             if(this.deltas[_loc2_] == param1)
  329.             {
  330.                this.deltas.splice(_loc2_,1);
  331.                return true;
  332.             }
  333.             _loc2_++;
  334.          }
  335.          return false;
  336.       }
  337.       
  338.       private function integrateRemovedElements(param1:CollectionEvent, param2:int, param3:int) : void
  339.       {
  340.          var _loc9_:CollectionModification = null;
  341.          var _loc10_:CollectionModification = null;
  342.          var _loc4_:int = 0;
  343.          var _loc5_:int = 0;
  344.          var _loc6_:int = 0;
  345.          var _loc7_:int = int(param1.items.length);
  346.          var _loc8_:int = 0;
  347.          while(_loc4_ < this.deltas.length && _loc5_ < _loc7_)
  348.          {
  349.             _loc9_ = CollectionModification(this.deltas[_loc4_]);
  350.             _loc10_ = new CollectionModification(param1.location,param1.items[_loc5_],CollectionModification.REMOVE);
  351.             this.removedItems[this.getUniqueItemWrapper(param1.items[_loc5_],_loc10_,0)] = _loc10_;
  352.             if(_loc8_ != 0)
  353.             {
  354.                _loc9_.index += _loc8_;
  355.             }
  356.             if(_loc9_.isRemove && _loc9_.index <= _loc10_.index || !_loc9_.isRemove && _loc9_.index < _loc10_.index)
  357.             {
  358.                _loc4_++;
  359.             }
  360.             else
  361.             {
  362.                if(!_loc9_.isRemove && _loc9_.index == _loc10_.index)
  363.                {
  364.                   this.deltas.splice(_loc4_ + _loc5_,1);
  365.                }
  366.                else
  367.                {
  368.                   this.deltas.splice(_loc4_ + _loc5_,0,_loc10_);
  369.                   _loc4_++;
  370.                }
  371.                _loc8_--;
  372.                _loc5_++;
  373.             }
  374.          }
  375.          while(_loc4_ < this.deltas.length)
  376.          {
  377.             _loc9_ = CollectionModification(this.deltas[_loc4_++]);
  378.             _loc9_.index += _loc8_;
  379.          }
  380.          while(_loc5_ < _loc7_)
  381.          {
  382.             this.deltas.push(_loc10_ = new CollectionModification(param1.location,param1.items[_loc5_],CollectionModification.REMOVE));
  383.             this.removedItems[this.getUniqueItemWrapper(param1.items[_loc5_],_loc10_,0)] = _loc10_;
  384.             _loc5_++;
  385.          }
  386.          this.deltaLength += param1.items.length - _loc6_;
  387.       }
  388.       
  389.       private function integrateAddedElements(param1:CollectionEvent, param2:int, param3:int) : void
  390.       {
  391.          var _loc9_:CollectionModification = null;
  392.          var _loc10_:CollectionModification = null;
  393.          var _loc4_:int = 0;
  394.          var _loc5_:int = 0;
  395.          var _loc6_:Boolean = false;
  396.          var _loc7_:int = int(param1.items.length);
  397.          var _loc8_:int = 0;
  398.          while(_loc4_ < this.deltas.length && _loc5_ < _loc7_)
  399.          {
  400.             _loc9_ = CollectionModification(this.deltas[_loc4_]);
  401.             _loc10_ = new CollectionModification(param1.location + _loc5_,null,CollectionModification.ADD);
  402.             this.addedItems[this.getUniqueItemWrapper(param1.items[_loc5_],_loc10_,0)] = _loc10_;
  403.             if(_loc9_.isRemove && _loc9_.index <= _loc10_.index || !_loc9_.isRemove && _loc9_.index < _loc10_.index)
  404.             {
  405.                _loc4_++;
  406.             }
  407.             else
  408.             {
  409.                this.deltas.splice(_loc4_ + _loc5_,0,_loc10_);
  410.                _loc8_++;
  411.                _loc5_++;
  412.                _loc4_++;
  413.             }
  414.          }
  415.          while(_loc4_ < this.deltas.length)
  416.          {
  417.             _loc9_ = CollectionModification(this.deltas[_loc4_++]);
  418.             _loc9_.index += _loc8_;
  419.          }
  420.          while(_loc5_ < _loc7_)
  421.          {
  422.             this.deltas.push(_loc10_ = new CollectionModification(param1.location + _loc5_,null,CollectionModification.ADD));
  423.             this.addedItems[this.getUniqueItemWrapper(param1.items[_loc5_],_loc10_,0)] = _loc10_;
  424.             _loc5_++;
  425.          }
  426.          this.deltaLength -= param1.items.length;
  427.       }
  428.       
  429.       private function integrateReplacedElements(param1:CollectionEvent, param2:int, param3:int) : void
  430.       {
  431.          var _loc9_:Object = null;
  432.          var _loc10_:Object = null;
  433.          var _loc11_:CollectionModification = null;
  434.          var _loc12_:CollectionModification = null;
  435.          var _loc4_:int = 0;
  436.          var _loc5_:int = 0;
  437.          var _loc6_:Boolean = false;
  438.          var _loc7_:int = int(param1.items.length);
  439.          var _loc8_:int = 0;
  440.          while(_loc4_ < this.deltas.length && _loc5_ < _loc7_)
  441.          {
  442.             _loc9_ = PropertyChangeEvent(param1.items[_loc5_]).oldValue;
  443.             _loc10_ = PropertyChangeEvent(param1.items[_loc5_]).newValue;
  444.             _loc11_ = CollectionModification(this.deltas[_loc4_]);
  445.             _loc12_ = new CollectionModification(param1.location + _loc5_,_loc9_,CollectionModification.REPLACE);
  446.             if(_loc11_.isRemove && _loc11_.index <= _loc12_.index || !_loc11_.isRemove && _loc11_.index < _loc12_.index)
  447.             {
  448.                _loc4_++;
  449.             }
  450.             else if((_loc11_.modificationType == CollectionModification.ADD || _loc11_.modificationType == CollectionModification.REPLACE) && _loc11_.index == _loc12_.index)
  451.             {
  452.                _loc4_++;
  453.                _loc5_++;
  454.             }
  455.             else
  456.             {
  457.                this.deltas.splice(_loc4_ + _loc5_,0,_loc12_);
  458.                this.replacedItems[this.getUniqueItemWrapper(_loc9_,_loc12_,param1.location + _loc5_)] = _loc12_;
  459.                this.replacementItems[this.getUniqueItemWrapper(_loc10_,_loc12_,param1.location + _loc5_,true)] = _loc12_;
  460.                _loc5_++;
  461.                _loc4_++;
  462.             }
  463.          }
  464.          while(_loc5_ < _loc7_)
  465.          {
  466.             _loc9_ = PropertyChangeEvent(param1.items[_loc5_]).oldValue;
  467.             _loc10_ = PropertyChangeEvent(param1.items[_loc5_]).newValue;
  468.             this.deltas.push(_loc12_ = new CollectionModification(param1.location + _loc5_,_loc9_,CollectionModification.REPLACE));
  469.             this.replacedItems[this.getUniqueItemWrapper(_loc9_,_loc12_,param1.location + _loc5_)] = _loc12_;
  470.             this.replacementItems[this.getUniqueItemWrapper(_loc10_,_loc12_,param1.location + _loc5_,true)] = _loc12_;
  471.             _loc5_++;
  472.          }
  473.       }
  474.       
  475.       private function getUniqueItemWrapper(param1:Object, param2:CollectionModification, param3:int, param4:Boolean = false) : Object
  476.       {
  477.          if(Boolean(param2) && (param2.isRemove || param2.modificationType == CollectionModification.REPLACE && !param4))
  478.          {
  479.             if(!this.itemWrappersByCollectionMod[param2])
  480.             {
  481.                this.itemWrappersByCollectionMod[param2] = new ItemWrapper(param1);
  482.             }
  483.             return this.itemWrappersByCollectionMod[param2];
  484.          }
  485.          if(Boolean(param2) && param2.modificationType == CollectionModification.ADD)
  486.          {
  487.             param3 = param2.index;
  488.          }
  489.          if(!this.itemWrappersByIndex[param3])
  490.          {
  491.             this.itemWrappersByIndex[param3] = new ItemWrapper(param1);
  492.          }
  493.          return this.itemWrappersByIndex[param3];
  494.       }
  495.    }
  496. }
  497.  
  498. import flash.events.EventDispatcher;
  499. import mx.collections.errors.CollectionViewError;
  500. import mx.collections.errors.CursorError;
  501. import mx.collections.errors.ItemPendingError;
  502. import mx.core.mx_internal;
  503. import mx.events.FlexEvent;
  504. import mx.resources.IResourceManager;
  505. import mx.resources.ResourceManager;
  506.  
  507. use namespace mx_internal;
  508.  
  509. class ModifiedCollectionViewCursor extends EventDispatcher implements IViewCursor
  510. {
  511.    private static const BEFORE_FIRST_INDEX:int = -1;
  512.    
  513.    private static const AFTER_LAST_INDEX:int = -2;
  514.    
  515.    private var _view:ModifiedCollectionView;
  516.    
  517.    public var internalCursor:IViewCursor;
  518.    
  519.    mx_internal var currentIndex:int;
  520.    
  521.    public var internalIndex:int;
  522.    
  523.    private var currentValue:Object;
  524.    
  525.    private var invalid:Boolean;
  526.    
  527.    private var resourceManager:IResourceManager;
  528.    
  529.    public function ModifiedCollectionViewCursor(param1:ModifiedCollectionView, param2:IViewCursor, param3:Object)
  530.    {
  531.       var view:ModifiedCollectionView = param1;
  532.       var cursor:IViewCursor = param2;
  533.       var current:Object = param3;
  534.       this.resourceManager = ResourceManager.getInstance();
  535.       super();
  536.       this._view = view;
  537.       this.internalCursor = cursor;
  538.       if(cursor.beforeFirst && !current)
  539.       {
  540.          this.internalIndex = BEFORE_FIRST_INDEX;
  541.       }
  542.       else if(cursor.afterLast && !current)
  543.       {
  544.          this.internalIndex = AFTER_LAST_INDEX;
  545.       }
  546.       else
  547.       {
  548.          this.internalIndex = 0;
  549.       }
  550.       this.mx_internal::currentIndex = view.length > 0 ? 0 : int(AFTER_LAST_INDEX);
  551.       if(this.mx_internal::currentIndex == 0)
  552.       {
  553.          try
  554.          {
  555.             this.setCurrent(current,false);
  556.          }
  557.          catch(e:ItemPendingError)
  558.          {
  559.             mx_internal::currentIndex = BEFORE_FIRST_INDEX;
  560.             setCurrent(null,false);
  561.          }
  562.       }
  563.    }
  564.    
  565.    public function get view() : ICollectionView
  566.    {
  567.       this.checkValid();
  568.       return this._view;
  569.    }
  570.    
  571.    [Bindable("cursorUpdate")]
  572.    public function get current() : Object
  573.    {
  574.       this.checkValid();
  575.       return this.currentValue;
  576.    }
  577.    
  578.    [Bindable("cursorUpdate")]
  579.    public function get bookmark() : CursorBookmark
  580.    {
  581.       this.checkValid();
  582.       if(this.view.length == 0 || Boolean(this.beforeFirst))
  583.       {
  584.          return CursorBookmark.FIRST;
  585.       }
  586.       if(this.afterLast)
  587.       {
  588.          return CursorBookmark.LAST;
  589.       }
  590.       return ModifiedCollectionView(this.view).mx_internal::getBookmark(this);
  591.    }
  592.    
  593.    [Bindable("cursorUpdate")]
  594.    public function get beforeFirst() : Boolean
  595.    {
  596.       this.checkValid();
  597.       return this.mx_internal::currentIndex == BEFORE_FIRST_INDEX || this.view.length == 0;
  598.    }
  599.    
  600.    [Bindable("cursorUpdate")]
  601.    public function get afterLast() : Boolean
  602.    {
  603.       this.checkValid();
  604.       return this.mx_internal::currentIndex == AFTER_LAST_INDEX || this.view.length == 0;
  605.    }
  606.    
  607.    public function findAny(param1:Object) : Boolean
  608.    {
  609.       return false;
  610.    }
  611.    
  612.    public function findFirst(param1:Object) : Boolean
  613.    {
  614.       return false;
  615.    }
  616.    
  617.    public function findLast(param1:Object) : Boolean
  618.    {
  619.       return false;
  620.    }
  621.    
  622.    public function insert(param1:Object) : void
  623.    {
  624.    }
  625.    
  626.    public function moveNext() : Boolean
  627.    {
  628.       if(this.afterLast)
  629.       {
  630.          return false;
  631.       }
  632.       var _loc1_:int = !!this.beforeFirst ? 0 : int(this.mx_internal::currentIndex + 1);
  633.       if(_loc1_ >= this.view.length)
  634.       {
  635.          _loc1_ = int(AFTER_LAST_INDEX);
  636.          this.setCurrent(null);
  637.       }
  638.       else
  639.       {
  640.          this.setCurrent(ModifiedCollectionView(this.view).mx_internal::getWrappedItemUsingCursor(this,_loc1_));
  641.       }
  642.       this.mx_internal::currentIndex = _loc1_;
  643.       return !this.afterLast;
  644.    }
  645.    
  646.    public function movePrevious() : Boolean
  647.    {
  648.       if(this.beforeFirst)
  649.       {
  650.          return false;
  651.       }
  652.       var _loc1_:int = !!this.afterLast ? int(this.view.length - 1) : int(this.mx_internal::currentIndex - 1);
  653.       if(_loc1_ == -1)
  654.       {
  655.          _loc1_ = int(BEFORE_FIRST_INDEX);
  656.          this.setCurrent(null);
  657.       }
  658.       else
  659.       {
  660.          this.setCurrent(ModifiedCollectionView(this.view).mx_internal::getWrappedItemUsingCursor(this,_loc1_));
  661.       }
  662.       this.mx_internal::currentIndex = _loc1_;
  663.       return !this.beforeFirst;
  664.    }
  665.    
  666.    public function remove() : Object
  667.    {
  668.       return null;
  669.    }
  670.    
  671.    public function seek(param1:CursorBookmark, param2:int = 0, param3:int = 0) : void
  672.    {
  673.       var newIndex:int;
  674.       var newCurrent:Object;
  675.       var message:String = null;
  676.       var mcvBookmark:ModifiedCollectionViewBookmark = null;
  677.       var bookmark:CursorBookmark = param1;
  678.       var offset:int = param2;
  679.       var prefetch:int = param3;
  680.       this.checkValid();
  681.       if(this.view.length == 0)
  682.       {
  683.          this.mx_internal::currentIndex = AFTER_LAST_INDEX;
  684.          this.setCurrent(null,false);
  685.          return;
  686.       }
  687.       newIndex = int(this.mx_internal::currentIndex);
  688.       if(bookmark == CursorBookmark.FIRST)
  689.       {
  690.          newIndex = 0;
  691.          this.internalIndex = 0;
  692.          this.internalCursor.seek(CursorBookmark.FIRST);
  693.       }
  694.       else if(bookmark == CursorBookmark.LAST)
  695.       {
  696.          newIndex = this.view.length - 1;
  697.          this.internalCursor.seek(CursorBookmark.LAST);
  698.       }
  699.       else if(bookmark != CursorBookmark.CURRENT)
  700.       {
  701.          try
  702.          {
  703.             mcvBookmark = bookmark as ModifiedCollectionViewBookmark;
  704.             newIndex = ModifiedCollectionView(this.view).mx_internal::getBookmarkIndex(bookmark);
  705.             if(!mcvBookmark || newIndex < 0)
  706.             {
  707.                this.setCurrent(null);
  708.                message = this.resourceManager.getString("collections","bookmarkInvalid");
  709.                throw new CursorError(message);
  710.             }
  711.             this.internalIndex = mcvBookmark.mx_internal::internalIndex;
  712.             this.internalCursor.seek(mcvBookmark.mx_internal::internalBookmark);
  713.          }
  714.          catch(bmError:CollectionViewError)
  715.          {
  716.             message = resourceManager.getString("collections","bookmarkInvalid");
  717.             throw new CursorError(message);
  718.          }
  719.       }
  720.       newIndex += offset;
  721.       newCurrent = null;
  722.       if(newIndex >= this.view.length)
  723.       {
  724.          this.mx_internal::currentIndex = AFTER_LAST_INDEX;
  725.       }
  726.       else if(newIndex < 0)
  727.       {
  728.          this.mx_internal::currentIndex = BEFORE_FIRST_INDEX;
  729.       }
  730.       else
  731.       {
  732.          newCurrent = ModifiedCollectionView(this.view).mx_internal::getWrappedItemUsingCursor(this,newIndex);
  733.          this.mx_internal::currentIndex = newIndex;
  734.       }
  735.       this.setCurrent(newCurrent);
  736.    }
  737.    
  738.    private function checkValid() : void
  739.    {
  740.       var _loc1_:String = null;
  741.       if(this.invalid)
  742.       {
  743.          _loc1_ = this.resourceManager.getString("collections","invalidCursor");
  744.          throw new CursorError(_loc1_);
  745.       }
  746.    }
  747.    
  748.    private function setCurrent(param1:Object, param2:Boolean = true) : void
  749.    {
  750.       this.currentValue = param1;
  751.       if(param2)
  752.       {
  753.          dispatchEvent(new FlexEvent(FlexEvent.CURSOR_UPDATE));
  754.       }
  755.    }
  756. }
  757.  
  758. class ModifiedCollectionViewBookmark extends CursorBookmark
  759. {
  760.    mx_internal var index:int;
  761.    
  762.    mx_internal var view:ModifiedCollectionView;
  763.    
  764.    mx_internal var viewRevision:int;
  765.    
  766.    mx_internal var internalBookmark:CursorBookmark;
  767.    
  768.    mx_internal var internalIndex:int;
  769.    
  770.    public function ModifiedCollectionViewBookmark(param1:Object, param2:ModifiedCollectionView, param3:int, param4:int, param5:CursorBookmark, param6:int)
  771.    {
  772.       super(param1);
  773.       this.mx_internal::view = param2;
  774.       this.mx_internal::viewRevision = param3;
  775.       this.mx_internal::index = param4;
  776.       this.mx_internal::internalBookmark = param5;
  777.       this.mx_internal::internalIndex = param6;
  778.    }
  779.    
  780.    override public function getViewIndex() : int
  781.    {
  782.       return this.mx_internal::view.mx_internal::getBookmarkIndex(this);
  783.    }
  784. }
  785.  
  786. class CollectionModification
  787. {
  788.    public static const REMOVE:String = "remove";
  789.    
  790.    public static const ADD:String = "add";
  791.    
  792.    public static const REPLACE:String = "replace";
  793.    
  794.    public var index:int;
  795.    
  796.    public var item:Object = null;
  797.    
  798.    public var modificationType:String = null;
  799.    
  800.    private var _modCount:int = 0;
  801.    
  802.    public var showOldReplace:Boolean = true;
  803.    
  804.    public var showNewReplace:Boolean = false;
  805.    
  806.    public function CollectionModification(param1:int, param2:Object, param3:String)
  807.    {
  808.       super();
  809.       this.index = param1;
  810.       this.modificationType = param3;
  811.       if(param3 != CollectionModification.ADD)
  812.       {
  813.          this.item = param2;
  814.       }
  815.       if(param3 == CollectionModification.REMOVE)
  816.       {
  817.          this._modCount = 1;
  818.       }
  819.       else if(param3 == CollectionModification.ADD)
  820.       {
  821.          this._modCount = -1;
  822.       }
  823.    }
  824.    
  825.    public function get isRemove() : Boolean
  826.    {
  827.       return this.modificationType == CollectionModification.REMOVE;
  828.    }
  829.    
  830.    public function startShowingReplacementValue() : void
  831.    {
  832.       this.showNewReplace = true;
  833.       ++this._modCount;
  834.    }
  835.    
  836.    public function stopShowingReplacedValue() : void
  837.    {
  838.       this.showOldReplace = false;
  839.       --this._modCount;
  840.    }
  841.    
  842.    public function get modCount() : int
  843.    {
  844.       return this._modCount;
  845.    }
  846. }
  847.