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

goog.provide('org.apache.royale.jewel.beads.views.TableView');

goog.require('org.apache.royale.core.ISelectableItemRenderer');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.jewel.beads.models.TableModel');
goog.require('org.apache.royale.jewel.beads.views.ListView');
goog.require('org.apache.royale.jewel.supportClasses.table.TFoot');
goog.require('org.apache.royale.jewel.supportClasses.table.THead');
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
 * @extends {org.apache.royale.jewel.beads.views.ListView}
 */
org.apache.royale.jewel.beads.views.TableView = function() {
  org.apache.royale.jewel.beads.views.TableView.base(this, 'constructor');
};
goog.inherits(org.apache.royale.jewel.beads.views.TableView, org.apache.royale.jewel.beads.views.ListView);


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


/**
 * @protected
 * @type {org.apache.royale.jewel.beads.models.TableModel}
 */
org.apache.royale.jewel.beads.views.TableView.prototype.model;


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.core.ISelectionModel
 * @protected
 * @override
 */
org.apache.royale.jewel.beads.views.TableView.prototype.handleInitComplete = function(event) {
  this.model = org.apache.royale.utils.Language.as(this._strand.getBeadByType(org.apache.royale.jewel.beads.models.TableModel), org.apache.royale.jewel.beads.models.TableModel);
  this.model.addEventListener("selectedIndexChanged", org.apache.royale.utils.Language.closure(this.selectionChangeHandler, this, 'selectionChangeHandler'));
  this.model.addEventListener("rollOverIndexChanged", org.apache.royale.utils.Language.closure(this.rollOverIndexChangeHandler, this, 'rollOverIndexChangeHandler'));
  org.apache.royale.utils.Language.as(this._strand, org.apache.royale.events.IEventDispatcher, true).addEventListener("itemsCreated", org.apache.royale.utils.Language.closure(this.itemsCreatedHandler, this, 'itemsCreatedHandler'));
  org.apache.royale.jewel.beads.views.TableView.superClass_.handleInitComplete.apply(this, [ event] );
};


/**
 * @asprivate
 * Ensure the list selects the selectedItem if someone is set by the user at creation time
 * @protected
 * @override
 */
org.apache.royale.jewel.beads.views.TableView.prototype.itemsCreatedHandler = function(event) {
  org.apache.royale.jewel.beads.views.TableView.superClass_.itemsCreatedHandler.apply(this, [ event] );
  if (this.listModel.selectedIndex != -1)
    this.selectionChangeHandler(null);
};


/**
 * @export
 * @type {org.apache.royale.jewel.supportClasses.table.THead}
 */
org.apache.royale.jewel.beads.views.TableView.prototype.thead;


/**
 * @export
 * @type {org.apache.royale.jewel.supportClasses.table.TFoot}
 */
org.apache.royale.jewel.beads.views.TableView.prototype.tfoot;


/**
 * @asprivate
 * @royaleignorecoercion org.apache.royale.core.ISelectableItemRenderer
 * @protected
 * @override
 */
org.apache.royale.jewel.beads.views.TableView.prototype.selectionChangeHandler = function(event) {
  var /** @type {Object} */ ir = this.dataGroup.getItemRendererAt(this.lastSelectedIndex);
  if (ir)
    ir.selected = false;
  ir = this.dataGroup.getItemRendererAt(this.listModel.selectedIndex);
  if (ir)
    ir.selected = true;
  this.lastSelectedIndex = this.listModel.selectedIndex;
};


org.apache.royale.jewel.beads.views.TableView.prototype.set__strand = function(value) {
  org.apache.royale.jewel.beads.views.TableView.superClass_.set__strand.apply(this, [ value] );
};


Object.defineProperties(org.apache.royale.jewel.beads.views.TableView.prototype, /** @lends {org.apache.royale.jewel.beads.views.TableView.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.views.TableView.prototype.set__strand}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.views.TableView.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {
      return {
        'thead': { type: 'org.apache.royale.jewel.supportClasses.table.THead'},
        'tfoot': { type: 'org.apache.royale.jewel.supportClasses.table.TFoot'}
      };
    },
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.views.TableView'}
      };
    },
    methods: function () {
      return {
        'TableView': { type: '', declaredBy: 'org.apache.royale.jewel.beads.views.TableView'}
      };
    }
  };
};