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

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

goog.require('org.apache.royale.collections.ArrayList');
goog.require('org.apache.royale.core.ISelectionModel');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.html.supportClasses.DataProviderNotifierBase');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @constructor
 * @extends {org.apache.royale.html.supportClasses.DataProviderNotifierBase}
 */
org.apache.royale.html.beads.DataProviderChangeNotifier = function() {
  org.apache.royale.html.beads.DataProviderChangeNotifier.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.DataProviderChangeNotifier, org.apache.royale.html.supportClasses.DataProviderNotifierBase);


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


/**
 * @protected
 * @override
 */
org.apache.royale.html.beads.DataProviderChangeNotifier.prototype.destinationChangedHandler = function(event) {
  var /** @type {Object} */ object = this.document[this.sourceID];
  if (this.dataProvider) {
    if (object[this.propertyName] == this.dataProvider)
      return;
    this.detachEventListeners();
  }
  this.dataProvider = org.apache.royale.utils.Language.as(object[this.propertyName], org.apache.royale.collections.ArrayList);
  this.attachEventListeners();
};


/**
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.DataProviderChangeNotifier.prototype.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges = function(event) {
  var /** @type {org.apache.royale.core.ISelectionModel} */ selectionModel = org.apache.royale.utils.Language.as(this._strand.getBeadByType(org.apache.royale.core.ISelectionModel), org.apache.royale.core.ISelectionModel);
  selectionModel.dispatchEvent(new org.apache.royale.events.Event("dataProviderChanged"));
};


/**
 * @protected
 */
org.apache.royale.html.beads.DataProviderChangeNotifier.prototype.attachEventListeners = function() {
  this.dataProvider.addEventListener("itemAdded", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
  this.dataProvider.addEventListener("itemRemoved", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
  this.dataProvider.addEventListener("itemUpdated", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
  this.dataProvider.addEventListener("collectionChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
};


/**
 * @protected
 */
org.apache.royale.html.beads.DataProviderChangeNotifier.prototype.detachEventListeners = function() {
  this.dataProvider.removeEventListener("itemAdded", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
  this.dataProvider.removeEventListener("itemRemoved", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
  this.dataProvider.removeEventListener("itemUpdated", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
  this.dataProvider.removeEventListener("collectionChanged", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_DataProviderChangeNotifier_handleDataProviderChanges, this, 'handleDataProviderChanges'));
};


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



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