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

goog.provide('org.apache.royale.jewel.beads.models.ArrayListSelectionModel');

goog.require('org.apache.royale.collections.IArrayList');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.EventDispatcher');
goog.require('org.apache.royale.core.IRollOverModel');
goog.require('org.apache.royale.jewel.beads.models.IJewelSelectionModel');
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.events.EventDispatcher}
 * @implements {org.apache.royale.jewel.beads.models.IJewelSelectionModel}
 * @implements {org.apache.royale.core.IRollOverModel}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel = function() {
  org.apache.royale.jewel.beads.models.ArrayListSelectionModel.base(this, 'constructor');
};
goog.inherits(org.apache.royale.jewel.beads.models.ArrayListSelectionModel, org.apache.royale.events.EventDispatcher);


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


/**
 * @private
 * @type {boolean}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dispatchChangeOnDataChange;


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__strand;


/**
 * @private
 * @type {boolean}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__processingInteractiveChange = false;


/**
 * @export
 * @param {boolean} value
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.setProcessingInteractiveChange = function(value) {
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__processingInteractiveChange = value;
};


/**
 * @private
 * @type {org.apache.royale.collections.IArrayList}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider;


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = -1;


/**
 * @private
 * @type {number}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__rollOverIndex = -1;


/**
 * @private
 * @type {string}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__labelField = null;


/**
 * @private
 * @type {Object}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem;


/**
 * @private
 * @type {string}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedString;


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__dispatchChangeOnDataProviderChange = function(value) {
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dispatchChangeOnDataChange = true;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__strand = value;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__processingInteractiveChange = function() {
  return this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__processingInteractiveChange;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__dataProvider = function() {
  return this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__dataProvider = function(value) {
  if (value == this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider)
    return;
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider = org.apache.royale.utils.Language.as(value, org.apache.royale.collections.IArrayList);
  var /** @type {boolean} */ itemChanged;
  
/**
 * @const
 * @type {number}
 */
var oldIndex = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex;
  if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider) {
    if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem) {
      this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.getItemIndex(this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem);
      if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex == -1) {
        this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem = null;
        itemChanged = true;
      }
    } else {
      if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex != -1) {
        if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex < this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.length) {
          this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.getItemAt(this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex);
          itemChanged = true;
        } else {
          this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = -1;
        }
      }
    }
  } else {
    itemChanged = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem != null;
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem = null;
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = -1;
  }
  this.dispatchEvent(new org.apache.royale.events.Event("dataProviderChanged"));
  if (itemChanged)
    this.dispatchEvent(new org.apache.royale.events.Event("selectedItemChanged"));
  if (oldIndex != this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex)
    this.dispatchEvent(new org.apache.royale.events.Event("selectedIndexChanged"));
  if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dispatchChangeOnDataChange && (itemChanged || oldIndex != this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex))
    this.dispatchEvent(new org.apache.royale.events.Event("change"));
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__labelField = function() {
  return this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__labelField;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__labelField = function(value) {
  if (value != this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__labelField) {
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__labelField = value;
    this.dispatchEvent(new org.apache.royale.events.Event("labelFieldChanged"));
  }
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__selectedIndex = function() {
  return this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__selectedIndex = function(value) {
  if (!this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider) {
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = value;
    return;
  }
  if (value == this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex)
    return;
  
/**
 * @const
 * @type {Object}
 */
var oldItem = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem;
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = Number(value < this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.length ? value : this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.length - 1);
  if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex != -1) {
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.getItemAt(this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex);
  } else {
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem = null;
  }
  if (oldItem != this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem)
    this.dispatchEvent(new org.apache.royale.events.Event("selectedItemChanged"));
  this.dispatchEvent(new org.apache.royale.events.Event("selectedIndexChanged"));
  if (!this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__processingInteractiveChange) {
    this.dispatchEvent(new org.apache.royale.events.Event("change"));
  }
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__rollOverIndex = function() {
  return this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__rollOverIndex;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__rollOverIndex = function(value) {
  if (value != this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__rollOverIndex) {
    this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__rollOverIndex = value;
    this.dispatchEvent(new org.apache.royale.events.Event("rollOverIndexChanged"));
  }
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__selectedItem = function() {
  return this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem;
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__selectedItem = function(value) {
  if (value == this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem)
    return;
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem = value;
  if (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider) {
    
/**
 * @const
 * @type {boolean}
 */
var indexChanged = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex != (this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.getItemIndex(value));
    this.dispatchEvent(new org.apache.royale.events.Event("selectedItemChanged"));
    if (indexChanged)
      this.dispatchEvent(new org.apache.royale.events.Event("selectedIndexChanged"));
    if (!this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__processingInteractiveChange) {
      this.dispatchEvent(new org.apache.royale.events.Event("change"));
    }
  }
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__selectedString = function() {
  return String(this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedItem);
};


org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__selectedString = function(value) {
  this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedString = value;
  var /** @type {number} */ n = this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.length;
  for (var /** @type {number} */ i = 0; i < n; i++) {
    if (String(this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__dataProvider.getItemAt(i)) == value) {
      this.org_apache_royale_jewel_beads_models_ArrayListSelectionModel__selectedIndex = i;
      break;
    }
  }
  this.dispatchEvent(new org.apache.royale.events.Event("selectedItemChanged"));
  this.dispatchEvent(new org.apache.royale.events.Event("selectedIndexChanged"));
};


Object.defineProperties(org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype, /** @lends {org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype} */ {
/**
  * @export
  * @type {boolean} */
dispatchChangeOnDataProviderChange: {
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__dispatchChangeOnDataProviderChange},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__strand},
/**
  * @export
  * @type {boolean} */
processingInteractiveChange: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__processingInteractiveChange},
/**
  * @export
  * @type {Object} */
dataProvider: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__dataProvider,
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__dataProvider},
/**
  * @export
  * @type {string} */
labelField: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__labelField,
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__labelField},
/**
  * @export
  * @type {number} */
selectedIndex: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__selectedIndex,
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__selectedIndex},
/**
  * @export
  * @type {number} */
rollOverIndex: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__rollOverIndex,
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__rollOverIndex},
/**
  * @export
  * @type {Object} */
selectedItem: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__selectedItem,
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__selectedItem},
/**
  * @export
  * @type {string} */
selectedString: {
get: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.get__selectedString,
set: org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.set__selectedString}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.models.ArrayListSelectionModel.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'dispatchChangeOnDataProviderChange': { type: 'Boolean', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'dataProvider': { type: 'Object', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel', metadata: function () { return [ { name: 'Bindable', args: [ { key: '', value: 'dataProviderChanged' } ] } ]; }},
        'labelField': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'selectedIndex': { type: 'int', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'rollOverIndex': { type: 'int', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'selectedItem': { type: 'Object', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'selectedString': { type: 'String', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'}
      };
    },
    methods: function () {
      return {
        'ArrayListSelectionModel': { type: '', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel'},
        'setProcessingInteractiveChange': { type: 'void', declaredBy: 'org.apache.royale.jewel.beads.models.ArrayListSelectionModel', parameters: function () { return [  { index: 1, type: 'Boolean', optional: false } ]; }}
      };
    }
  };
};