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

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

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.UIBase');
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.html.supportClasses.DataItemRenderer');
goog.require('org.apache.royale.jewel.beads.models.TableModel');
goog.require('org.apache.royale.jewel.supportClasses.table.TableCell');
goog.require('org.apache.royale.jewel.supportClasses.table.TableRow');
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.RemoveTableRowForArrayListData = function() {
};


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


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveTableRowForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__strand;


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


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


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


/**
 * @private
 * @type {org.apache.royale.events.IEventDispatcher}
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveTableRowForArrayListData.prototype.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData_dp;


/**
 * @asprivate
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveTableRowForArrayListData.prototype.dataProviderChangeHandler = function(event) {
  if (this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData_dp) {
    this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData_dp.removeEventListener(org.apache.royale.events.CollectionEvent.ITEM_REMOVED, org.apache.royale.utils.Language.closure(this.handleItemRemoved, this, 'handleItemRemoved'));
  }
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData_dp = org.apache.royale.utils.Language.as(this.model.dataProvider, org.apache.royale.events.IEventDispatcher);
  if (!this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData_dp)
    return;
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData_dp.addEventListener(org.apache.royale.events.CollectionEvent.ITEM_REMOVED, org.apache.royale.utils.Language.closure(this.handleItemRemoved, this, 'handleItemRemoved'));
};


/**
 *  Handles the itemRemoved event by removing the item.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @protected
 * @param {org.apache.royale.events.CollectionEvent} event
 */
org.apache.royale.jewel.beads.itemRenderers.RemoveTableRowForArrayListData.prototype.handleItemRemoved = function(event) {
  var /** @type {org.apache.royale.html.supportClasses.DataItemRenderer} */ ir;
  var /** @type {org.apache.royale.jewel.supportClasses.table.TableCell} */ cell;
  var /** @type {org.apache.royale.jewel.supportClasses.table.TableRow} */ processedRow = org.apache.royale.utils.Language.as(org.apache.royale.utils.Language.as(this.itemRendererParent, org.apache.royale.core.UIBase).getElementAt(event.index), org.apache.royale.jewel.supportClasses.table.TableRow);
  while (processedRow.numElements > 0) {
    cell = org.apache.royale.utils.Language.as(processedRow.getElementAt(0), org.apache.royale.jewel.supportClasses.table.TableCell);
    ir = org.apache.royale.utils.Language.as(cell.getElementAt(0), org.apache.royale.html.supportClasses.DataItemRenderer);
    this.itemRendererParent.removeItemRenderer(ir);
    cell.removeElement(ir);
    processedRow.removeElement(cell);
  }
  org.apache.royale.utils.Language.as(this.itemRendererParent, org.apache.royale.core.UIBase).removeElement(processedRow);
  var /** @type {number} */ len = this.itemRendererParent.numItemRenderers;
  for (var /** @type {number} */ i = event.index; i < len; i++) {
    ir = org.apache.royale.utils.Language.as(this.itemRendererParent.getItemRendererAt(i), org.apache.royale.html.supportClasses.DataItemRenderer);
    ir.index = i;
    ir.rowIndex = i;
  }
  org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__strand, org.apache.royale.events.IEventDispatcher).dispatchEvent(new org.apache.royale.events.Event("layoutNeeded"));
};


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


org.apache.royale.jewel.beads.itemRenderers.RemoveTableRowForArrayListData.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__strand = value;
  org.apache.royale.utils.Language.as(value, org.apache.royale.events.IEventDispatcher, true).addEventListener("initComplete", org.apache.royale.utils.Language.closure(this.initComplete, this, 'initComplete'));
};


org.apache.royale.jewel.beads.itemRenderers.RemoveTableRowForArrayListData.prototype.get__itemRendererParent = function() {
  if (this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__itemRendererParent == null) {
    var /** @type {org.apache.royale.html.beads.IListView} */ listView = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__strand.getBeadByType(org.apache.royale.html.beads.IListView), org.apache.royale.html.beads.IListView);
    this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__itemRendererParent = listView.dataGroup;
  }
  return this.org_apache_royale_jewel_beads_itemRenderers_RemoveTableRowForArrayListData__itemRendererParent;
};


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


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



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