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

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

goog.require('org.apache.royale.collections.ICollectionView');
goog.require('org.apache.royale.core.IListPresentationModel');
goog.require('org.apache.royale.core.ISelectableItemRenderer');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.jewel.beads.itemRenderers.DataItemRendererFactoryForCollectionView');
goog.require('org.apache.royale.jewel.itemRenderers.DropDownListItemRenderer');



/**
 * @constructor
 * @extends {org.apache.royale.jewel.beads.itemRenderers.DataItemRendererFactoryForCollectionView}
 * @param {Object=} target
 */
org.apache.royale.jewel.beads.itemRenderers.DropDownListItemRendererFactoryForCollectionView = function(target) {
  target = typeof target !== 'undefined' ? target : null;
  org.apache.royale.jewel.beads.itemRenderers.DropDownListItemRendererFactoryForCollectionView.base(this, 'constructor', target);
};
goog.inherits(org.apache.royale.jewel.beads.itemRenderers.DropDownListItemRendererFactoryForCollectionView, org.apache.royale.jewel.beads.itemRenderers.DataItemRendererFactoryForCollectionView);


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


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.collections.ICollectionView
 * @royaleignorecoercion org.apache.royale.core.IListPresentationModel
 * @royaleignorecoercion org.apache.royale.core.ISelectableItemRenderer
 * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @override
 */
org.apache.royale.jewel.beads.itemRenderers.DropDownListItemRendererFactoryForCollectionView.prototype.dataProviderChangeHandler = function(event) {
  if (!this.dataProviderModel)
    return;
  var /** @type {Object} */ dp = this.dataProviderModel.dataProvider;
  if (!dp)
    return;
  this.dataGroup.removeAllItemRenderers();
  var /** @type {Object} */ presentationModel = this._strand.getBeadByType(org.apache.royale.core.IListPresentationModel);
  this.labelField = this.dataProviderModel.labelField;
  var /** @type {Object} */ ir;
  var /** @type {Object} */ item;
  var /** @type {number} */ offset = 1;
  if (offset == 1) {
    ir = this.itemRendererFactory.createItemRenderer(this.dataGroup);
    item = org.apache.royale.jewel.itemRenderers.DropDownListItemRenderer.OPTION_DISABLED;
    this.fillRenderer(0, item, ir, presentationModel);
  }
  var /** @type {number} */ n = dp.length;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    ir = this.itemRendererFactory.createItemRenderer(this.dataGroup);
    item = dp.getItemAt(i);
    this.fillRenderer(i + offset, item, ir, presentationModel);
  }
  this._strand.dispatchEvent(new org.apache.royale.events.Event("itemsCreated"));
};


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.itemRenderers.DropDownListItemRendererFactoryForCollectionView.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {return {};},
    methods: function () {
      return {
        'DropDownListItemRendererFactoryForCollectionView': { type: '', declaredBy: 'org.apache.royale.jewel.beads.itemRenderers.DropDownListItemRendererFactoryForCollectionView', parameters: function () { return [  { index: 1, type: 'Object', optional: true } ]; }}
      };
    }
  };
};