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

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

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.events.MouseEvent');
goog.require('org.apache.royale.html.beads.IComboBoxView');
goog.require('org.apache.royale.core.IBeadController');
goog.require('org.apache.royale.utils.Language');



/**
 * @constructor
 * @implements {org.apache.royale.core.IBeadController}
 */
org.apache.royale.html.beads.controllers.ComboBoxController = function() {
};


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


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.controllers.ComboBoxController.prototype.org_apache_royale_html_beads_controllers_ComboBoxController__strand;


/**
 * @protected
 * @type {org.apache.royale.html.beads.IComboBoxView}
 */
org.apache.royale.html.beads.controllers.ComboBoxController.prototype.viewBead;


/**
 * @protected
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.controllers.ComboBoxController.prototype.finishSetup = function(event) {
  if (this.viewBead == null) {
    this.viewBead = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_ComboBoxController__strand.getBeadByType(org.apache.royale.html.beads.IComboBoxView), org.apache.royale.html.beads.IComboBoxView);
  }
  org.apache.royale.utils.Language.as(this.viewBead.popupButton, org.apache.royale.events.IEventDispatcher, true).addEventListener("click", org.apache.royale.utils.Language.closure(this.handleButtonClick, this, 'handleButtonClick'));
  org.apache.royale.utils.Language.as(this.viewBead.textInputField, org.apache.royale.events.IEventDispatcher, true).addEventListener("click", org.apache.royale.utils.Language.closure(this.handleButtonClick, this, 'handleButtonClick'));
};


/**
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.controllers.ComboBoxController.prototype.handleButtonClick = function(event) {
  this.viewBead.popUpVisible = !this.viewBead.popUpVisible;
  org.apache.royale.utils.Language.as(this.viewBead.popUp, org.apache.royale.events.IEventDispatcher, true).addEventListener("change", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_controllers_ComboBoxController_handleListChange, this, 'handleListChange'));
};


/**
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.controllers.ComboBoxController.prototype.org_apache_royale_html_beads_controllers_ComboBoxController_handleListChange = function(event) {
  this.viewBead.popUpVisible = false;
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_ComboBoxController__strand, org.apache.royale.events.IEventDispatcher, true).dispatchEvent(new org.apache.royale.events.Event("change"));
};


org.apache.royale.html.beads.controllers.ComboBoxController.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_controllers_ComboBoxController__strand = value;
  this.viewBead = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_ComboBoxController__strand.getBeadByType(org.apache.royale.html.beads.IComboBoxView), org.apache.royale.html.beads.IComboBoxView);
  if (this.viewBead) {
    this.finishSetup(null);
  } else {
    org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_ComboBoxController__strand, org.apache.royale.events.IEventDispatcher, true).addEventListener("viewChanged", org.apache.royale.utils.Language.closure(this.finishSetup, this, 'finishSetup'));
  }
};


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


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.controllers.ComboBoxController.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.html.beads.controllers.ComboBoxController'}
      };
    },
    methods: function () {
      return {
        'ComboBoxController': { type: '', declaredBy: 'org.apache.royale.html.beads.controllers.ComboBoxController'}
      };
    }
  };
};