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

goog.provide('org.apache.royale.html.beads.TextItemRendererFactoryForArrayData');

goog.require('org.apache.royale.core.IItemRendererClassFactory');
goog.require('org.apache.royale.core.IItemRendererParent');
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.Event');
goog.require('org.apache.royale.events.EventDispatcher');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.events.ItemRendererEvent');
goog.require('org.apache.royale.html.beads.IListView');
goog.require('org.apache.royale.html.beads.ITextItemRenderer');
goog.require('org.apache.royale.utils.loadBeadFromValuesManager');
goog.require('org.apache.royale.core.IBead');
goog.require('org.apache.royale.core.IDataProviderItemRendererMapper');
goog.require('org.apache.royale.utils.Language');



/**
 *  Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @constructor
 * @extends {org.apache.royale.events.EventDispatcher}
 * @implements {org.apache.royale.core.IBead}
 * @implements {org.apache.royale.core.IDataProviderItemRendererMapper}
 * @param {Object=} target
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData = function(target) {
  target = typeof target !== 'undefined' ? target : null;
  org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.base(this, 'constructor', target);
};
goog.inherits(org.apache.royale.html.beads.TextItemRendererFactoryForArrayData, org.apache.royale.events.EventDispatcher);


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


/**
 * @private
 * @type {org.apache.royale.core.ISelectionModel}
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_selectionModel;


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand;


/**
 * @royaleignorecoercion org.apache.royale.core.IItemRendererClassFactory
 * @royaleignorecoercion org.apache.royale.core.ISelectionModel
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_finishSetup = function(event) {
  this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_selectionModel = this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand.getBeadByType(org.apache.royale.core.ISelectionModel);
  this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_selectionModel.addEventListener("dataProviderChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_dataProviderChangeHandler, this, 'dataProviderChangeHandler'));
  if (!this.itemRendererFactory) {
    this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__itemRendererFactory = org.apache.royale.utils.loadBeadFromValuesManager(org.apache.royale.core.IItemRendererClassFactory, "iItemRendererClassFactory", this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand);
  }
  this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_dataProviderChangeHandler(null);
};


/**
 * @private
 * @type {Object}
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__itemRendererFactory;


/**
 *  The IItemRendererParent that should parent the ITextItemRenderers
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 *  @royaleignorecoercion Array
 *  @royaleignorecoercion org.apache.royale.html.beads.ITextItemRenderer
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 *  @royaleignorecoercion org.apache.royale.core.IStrandWithModelView
 *  @royaleignorecoercion org.apache.royale.html.beads.IListView
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_dataProviderChangeHandler = function(event) {
  var /** @type {Array} */ dp = this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_selectionModel.dataProvider;
  if (!dp)
    return;
  var /** @type {Object} */ view = this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand.view;
  var /** @type {org.apache.royale.core.IItemRendererParent} */ dataGroup = view.dataGroup;
  dataGroup.removeAllItemRenderers();
  var /** @type {number} */ n = dp.length;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    var /** @type {Object} */ tf = this.itemRendererFactory.createItemRenderer(dataGroup);
    tf.index = i;
    dataGroup.addItemRenderer(tf, false);
    if (this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_selectionModel.labelField) {
      tf.labelField = this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_selectionModel.labelField;
    }
    tf.data = dp[i];
    var /** @type {org.apache.royale.events.ItemRendererEvent} */ newEvent = new org.apache.royale.events.ItemRendererEvent(org.apache.royale.events.ItemRendererEvent.CREATED);
    newEvent.itemRenderer = tf;
    this.dispatchEvent(newEvent);
  }
  this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand.dispatchEvent(new org.apache.royale.events.Event("itemsCreated"));
};


org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand = value;
  value.addEventListener("initComplete", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData_finishSetup, this, 'finishSetup'));
};


org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.get__itemRendererFactory = function() {
  if (!this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__itemRendererFactory)
    this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__itemRendererFactory = org.apache.royale.utils.loadBeadFromValuesManager(org.apache.royale.core.IItemRendererClassFactory, "iItemRendererClassFactory", this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__strand);
  return this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__itemRendererFactory;
};


org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.set__itemRendererFactory = function(value) {
  this.org_apache_royale_html_beads_TextItemRendererFactoryForArrayData__itemRendererFactory = value;
};


Object.defineProperties(org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype, /** @lends {org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.set__strand},
/**
  * @export
  * @type {org.apache.royale.core.IItemRendererClassFactory} */
itemRendererFactory: {
get: org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.get__itemRendererFactory,
set: org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.prototype.set__itemRendererFactory}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.TextItemRendererFactoryForArrayData.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.html.beads.TextItemRendererFactoryForArrayData'},
        'itemRendererFactory': { type: 'org.apache.royale.core.IItemRendererClassFactory', access: 'readwrite', declaredBy: 'org.apache.royale.html.beads.TextItemRendererFactoryForArrayData'}
      };
    },
    methods: function () {
      return {
        'TextItemRendererFactoryForArrayData': { type: '', declaredBy: 'org.apache.royale.html.beads.TextItemRendererFactoryForArrayData', parameters: function () { return [  { index: 1, type: 'Object', optional: true } ]; }}
      };
    },
    metadata: function () { return [  ]; }
  };
};