/**
 * Generated by Apache Royale Compiler from org\apache\royale\jewel\beads\itemRenderers\RemoveListItemRendererForArrayListData.as
 * org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData');

goog.require('org.apache.royale.core.IDataProviderModel');
goog.require('org.apache.royale.core.IItemRendererParent');
goog.require('org.apache.royale.core.ISelectableItemRenderer');
goog.require('org.apache.royale.core.ISelectionModel');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IStrandWithModelView');
goog.require('org.apache.royale.events.CollectionEvent');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.html.beads.IListView');
goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.utils.Language');



/**
 *  Constructor
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @constructor
 * @implements {org.apache.royale.core.IBead}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData = function() {
};


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData', org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData);


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand;


/**
 *  finish setup
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.initComplete = function(event) {
  org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand, org.apache.royale.events.IEventDispatcher, true).removeEventListener("initComplete", org.apache.royale.utils.Language.closure(this.initComplete, this, 'initComplete'));
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__dataProviderModel = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand.getBeadByType(org.apache.royale.core.ISelectionModel), org.apache.royale.core.ISelectionModel);
  this.dataProviderModel.addEventListener("dataProviderChanged", org.apache.royale.utils.Language.closure(this.dataProviderChangeHandler, this, 'dataProviderChangeHandler'));
  this.dataProviderChangeHandler(null);
};


/**
 * @private
 * @type {org.apache.royale.events.IEventDispatcher}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData_dp;


/**
 * @asprivate
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.dataProviderChangeHandler = function(event) {
  if (this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData_dp) {
    this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData_dp.removeEventListener(org.apache.royale.events.CollectionEvent.ITEM_REMOVED, org.apache.royale.utils.Language.closure(this.handleItemRemoved, this, 'handleItemRemoved'));
  }
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData_dp = org.apache.royale.utils.Language.as(this.dataProviderModel.dataProvider, org.apache.royale.events.IEventDispatcher);
  if (!this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData_dp)
    return;
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData_dp.addEventListener(org.apache.royale.events.CollectionEvent.ITEM_REMOVED, org.apache.royale.utils.Language.closure(this.handleItemRemoved, this, 'handleItemRemoved'));
};


/**
 *  Handles the itemRemoved event by removing the item.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 *  @royaleignorecoercion org.apache.royale.core.ISelectableItemRenderer
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @param {org.apache.royale.events.CollectionEvent} event
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.handleItemRemoved = function(event) {
  var /** @type {Object} */ ir = this.itemRendererParent.getItemRendererAt(event.index);
  this.itemRendererParent.removeItemRenderer(ir);
  var /** @type {number} */ n = this.itemRendererParent.numItemRenderers;
  for (var /** @type {number} */ i = event.index; i < n; i++) {
    ir = this.itemRendererParent.getItemRendererAt(i);
    ir.index = i;
  }
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand.dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
};


/**
 * @private
 * @type {org.apache.royale.core.IDataProviderModel}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__dataProviderModel;


/**
 * @private
 * @type {org.apache.royale.core.IItemRendererParent}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__itemRendererParent;


org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand = value;
  org.apache.royale.utils.Language.as(value, org.apache.royale.events.IEventDispatcher, true).addEventListener("initComplete", org.apache.royale.utils.Language.closure(this.initComplete, this, 'initComplete'));
};


org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.get__dataProviderModel = function() {
  if (this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__dataProviderModel == null) {
    this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__dataProviderModel = this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand.getBeadByType(org.apache.royale.core.IDataProviderModel);
  }
  return this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__dataProviderModel;
};


org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.get__itemRendererParent = function() {
  if (this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__itemRendererParent == null) {
    var /** @type {org.apache.royale.html.beads.IListView} */ view = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__strand.view, org.apache.royale.html.beads.IListView);
    this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__itemRendererParent = view.dataGroup;
  }
  return this.org_apache_royale_jewel_beads_itemRenderers_RemoveListItemRendererForArrayListData__itemRendererParent;
};


Object.defineProperties(org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype, /** @lends {org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.set__strand},
/**
  * @export
  * @type {org.apache.royale.core.IDataProviderModel} */
dataProviderModel: {
get: org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.get__dataProviderModel},
/**
  * @export
  * @type {org.apache.royale.core.IItemRendererParent} */
itemRendererParent: {
get: org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.get__itemRendererParent}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'RemoveListItemRendererForArrayListData', qName: 'org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData', kind: 'class' }], interfaces: [org.apache.royale.core.IBead] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData'},
        'dataProviderModel': { type: 'org.apache.royale.core.IDataProviderModel', access: 'readonly', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData'},
        'itemRendererParent': { type: 'org.apache.royale.core.IItemRendererParent', access: 'readonly', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData'}
      };
    },
    methods: function () {
      return {
        'RemoveListItemRendererForArrayListData': { type: '', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.RemoveListItemRendererForArrayListData'}
      };
    }
  };
};