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

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

goog.require('org.apache.royale.core.IComboBoxModel');
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.jewel.List');
goog.require('org.apache.royale.jewel.beads.controls.combobox.IComboBoxView');
goog.require('org.apache.royale.jewel.beads.views.ComboBoxPopUpView');
goog.require('org.apache.royale.jewel.supportClasses.combobox.ComboBoxPopUp');
goog.require('org.apache.royale.core.IBeadController');
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.IBeadController}
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController = function() {
};


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


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


/**
 * @private
 * @type {org.apache.royale.jewel.List}
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.org_apache_royale_jewel_beads_controllers_ComboBoxController_list;


/**
 * @private
 * @type {org.apache.royale.core.IComboBoxModel}
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.org_apache_royale_jewel_beads_controllers_ComboBoxController_model;


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


/**
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @param {org.apache.royale.events.Event=} event
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.finishSetup = function(event) {
  event = typeof event !== 'undefined' ? event : null;
  this.viewBead.button.addEventListener(org.apache.royale.events.MouseEvent.CLICK, org.apache.royale.utils.Language.closure(this.clickHandler, this, 'clickHandler'));
  this.viewBead.textinput.addEventListener(org.apache.royale.events.MouseEvent.CLICK, org.apache.royale.utils.Language.closure(this.clickHandler, this, 'clickHandler'));
};


/**
 *  @royaleignorecoercion org.apache.royale.core.UIBase
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.clickHandler = function(event) {
  event.stopImmediatePropagation();
  this.viewBead.popUpVisible = true;
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_popup = org.apache.royale.utils.Language.as(this.viewBead.popup, org.apache.royale.jewel.supportClasses.combobox.ComboBoxPopUp);
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_popup.addEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.removePopUpWhenClickOutside, this, 'removePopUpWhenClickOutside'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_controllers_ComboBoxController_popup.view, org.apache.royale.jewel.beads.views.ComboBoxPopUpView).list;
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.addEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.addEventListener(org.apache.royale.events.Event.CHANGE, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controllers_ComboBoxController_changeHandler, this, 'changeHandler'));
};


/**
 * @private
 * @type {org.apache.royale.jewel.supportClasses.combobox.ComboBoxPopUp}
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.org_apache_royale_jewel_beads_controllers_ComboBoxController_popup;


/**
 * @protected
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.handleControlMouseDown = function(event) {
  event.stopImmediatePropagation();
};


/**
 *  @royaleignorecoercion org.apache.royale.core.UIBase
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @protected
 * @param {org.apache.royale.events.MouseEvent=} event
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.removePopUpWhenClickOutside = function(event) {
  event = typeof event !== 'undefined' ? event : null;
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_popup.removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.removePopUpWhenClickOutside, this, 'removePopUpWhenClickOutside'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.removeEventListener(org.apache.royale.events.Event.CHANGE, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controllers_ComboBoxController_changeHandler, this, 'changeHandler'));
  this.viewBead.popUpVisible = false;
};


/**
 *  @royaleignorecoercion org.apache.royale.core.UIBase
 *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.org_apache_royale_jewel_beads_controllers_ComboBoxController_changeHandler = function(event) {
  event.stopImmediatePropagation();
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_popup.removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.removePopUpWhenClickOutside, this, 'removePopUpWhenClickOutside'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.removeEventListener(org.apache.royale.events.MouseEvent.MOUSE_DOWN, org.apache.royale.utils.Language.closure(this.handleControlMouseDown, this, 'handleControlMouseDown'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.removeEventListener(org.apache.royale.events.Event.CHANGE, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controllers_ComboBoxController_changeHandler, this, 'changeHandler'));
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_model.selectedItem = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_controllers_ComboBoxController_list.getBeadByType(org.apache.royale.core.IComboBoxModel), org.apache.royale.core.IComboBoxModel, true).selectedItem;
  this.viewBead.popUpVisible = false;
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController__strand.dispatchEvent(new org.apache.royale.events.Event(org.apache.royale.events.Event.CHANGE));
};


org.apache.royale.jewel.beads.controllers.ComboBoxController.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController__strand = value;
  this.org_apache_royale_jewel_beads_controllers_ComboBoxController_model = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_controllers_ComboBoxController__strand.getBeadByType(org.apache.royale.core.IComboBoxModel), org.apache.royale.core.IComboBoxModel);
  this.viewBead = this.org_apache_royale_jewel_beads_controllers_ComboBoxController__strand.getBeadByType(org.apache.royale.jewel.beads.controls.combobox.IComboBoxView);
  if (this.viewBead) {
    this.finishSetup();
  } else {
    this.org_apache_royale_jewel_beads_controllers_ComboBoxController__strand.addEventListener("viewChanged", org.apache.royale.utils.Language.closure(this.finishSetup, this, 'finishSetup'));
  }
};


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


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



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