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

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

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.UpdateListItemRendererForArrayListData = function() {
};


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


/**
 * @protected
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype._strand;


/**
 * @protected
 * @type {string}
 */
org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype.labelField;


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


/**
 * @private
 * @type {Object}
 */
org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_UpdateListItemRendererForArrayListData_dp;


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


/**
 *  Handles the itemUpdated event by updating the item.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @param {org.apache.royale.events.CollectionEvent} event
 */
org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype.handleItemUpdated = function(event) {
  var /** @type {org.apache.royale.core.ISelectableItemRenderer} */ ir = org.apache.royale.utils.Language.as(this.itemRendererParent.getItemRendererAt(event.index), org.apache.royale.core.ISelectableItemRenderer);
  this.setData(ir, event.item, event.index);
  this._strand.dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
};


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


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


/**
 * @asprivate
 * @protected
 * @param {org.apache.royale.core.ISelectableItemRenderer} itemRenderer
 * @param {Object} data
 * @param {number} index
 */
org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype.setData = function(itemRenderer, data, index) {
  itemRenderer.index = index;
  itemRenderer.data = data;
};


org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype.set__strand = function(value) {
  this._strand = value;
  value.addEventListener("initComplete", org.apache.royale.utils.Language.closure(this.initComplete, this, 'initComplete'));
};


org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.prototype.get__dataProviderModel = function() {
  if (this.org_apache_royale_jewel_beads_itemRenderers_UpdateListItemRendererForArrayListData__dataProviderModel == null) {
    this.org_apache_royale_jewel_beads_itemRenderers_UpdateListItemRendererForArrayListData__dataProviderModel = org.apache.royale.utils.Language.as(this._strand.getBeadByType(org.apache.royale.core.IDataProviderModel), org.apache.royale.core.IDataProviderModel);
  }
  return this.org_apache_royale_jewel_beads_itemRenderers_UpdateListItemRendererForArrayListData__dataProviderModel;
};


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


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


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData.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.UpdateListItemRendererForArrayListData'},
        'dataProviderModel': { type: 'org.apache.royale.core.IDataProviderModel', access: 'readonly', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData'},
        'itemRendererParent': { type: 'org.apache.royale.core.IItemRendererParent', access: 'readonly', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData'}
      };
    },
    methods: function () {
      return {
        'UpdateListItemRendererForArrayListData': { type: '', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.UpdateListItemRendererForArrayListData'}
      };
    }
  };
};