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

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

goog.require('org.apache.royale.core.IRollOverModel');
goog.require('org.apache.royale.core.ISelectableItemRenderer');
goog.require('org.apache.royale.core.ISelectionModel');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.html.beads.DataContainerView');
goog.require('org.apache.royale.utils.Language');



/**
 * @constructor
 * @extends {org.apache.royale.html.beads.DataContainerView}
 */
org.apache.royale.html.beads.VirtualListView = function() {
  org.apache.royale.html.beads.VirtualListView.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.VirtualListView, org.apache.royale.html.beads.DataContainerView);


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


/**
 * @protected
 * @type {org.apache.royale.core.ISelectionModel}
 */
org.apache.royale.html.beads.VirtualListView.prototype.listModel;


/**
 * @protected
 * @type {number}
 */
org.apache.royale.html.beads.VirtualListView.prototype.lastSelectedIndex = -1;


/**
 * @asprivate
 * @protected
 * @override
 */
org.apache.royale.html.beads.VirtualListView.prototype.handleInitComplete = function(event) {
  this.listModel = org.apache.royale.utils.Language.as(this._strand.getBeadByType(org.apache.royale.core.ISelectionModel), org.apache.royale.core.ISelectionModel);
  this.listModel.addEventListener("selectedIndexChanged", org.apache.royale.utils.Language.closure(this.selectionChangeHandler, this, 'selectionChangeHandler'));
  this.listModel.addEventListener("rollOverIndexChanged", org.apache.royale.utils.Language.closure(this.rollOverIndexChangeHandler, this, 'rollOverIndexChangeHandler'));
  org.apache.royale.html.beads.VirtualListView.superClass_.handleInitComplete.apply(this, [ event] );
};


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.core.ISelectableItemRenderer
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.VirtualListView.prototype.selectionChangeHandler = function(event) {
  var /** @type {Object} */ ir = this.dataGroup.getItemRendererForIndex(this.lastSelectedIndex);
  if (ir)
    ir.selected = false;
  ir = this.dataGroup.getItemRendererForIndex(this.listModel.selectedIndex);
  if (ir)
    ir.selected = true;
  this.lastSelectedIndex = this.listModel.selectedIndex;
};


/**
 * @protected
 * @type {number}
 */
org.apache.royale.html.beads.VirtualListView.prototype.lastRollOverIndex = -1;


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.core.ISelectableItemRenderer
 * * @royaleignorecoercion org.apache.royale.core.IRollOverModel
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.VirtualListView.prototype.rollOverIndexChangeHandler = function(event) {
  var /** @type {Object} */ ir = this.dataGroup.getItemRendererForIndex(this.lastRollOverIndex);
  if (ir)
    ir.hovered = false;
  ir = this.dataGroup.getItemRendererForIndex(this.listModel.rollOverIndex);
  if (ir)
    ir.hovered = true;
  this.lastRollOverIndex = this.listModel.rollOverIndex;
};


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.VirtualListView.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {return {};},
    methods: function () {
      return {
        'VirtualListView': { type: '', declaredBy: 'org.apache.royale.html.beads.VirtualListView'}
      };
    }
  };
};