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

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

goog.require('org.apache.royale.core.IBeadModel');
goog.require('org.apache.royale.core.IBeadView');
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.beads.models.DateChooserModel');
goog.require('org.apache.royale.jewel.beads.views.DateChooserView');
goog.require('org.apache.royale.jewel.supportClasses.datechooser.DateChooserTable');
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.DateChooserMouseController = function() {
};


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


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


/**
 * @private
 * @type {org.apache.royale.jewel.beads.models.DateChooserModel}
 */
org.apache.royale.jewel.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_model;


/**
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.jewel.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_tableHandler = function(event) {
  var /** @type {org.apache.royale.jewel.supportClasses.datechooser.DateChooserTable} */ table = org.apache.royale.utils.Language.as(event.target, org.apache.royale.jewel.supportClasses.datechooser.DateChooserTable);
  this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_model.selectedDate = org.apache.royale.utils.Language.as(table.selectedItemProperty, Date);
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.jewel.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_prevMonthClickHandler = function(event) {
  event.preventDefault();
  var /** @type {org.apache.royale.jewel.beads.models.DateChooserModel} */ model = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.jewel.beads.models.DateChooserModel);
  var /** @type {number} */ month = model.displayedMonth - 1;
  var /** @type {number} */ year = model.displayedYear;
  if (month < 0) {
    month = 11;
    year--;
  }
  model.displayedMonth = month;
  model.displayedYear = year;
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.jewel.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_nextMonthClickHandler = function(event) {
  event.preventDefault();
  var /** @type {org.apache.royale.jewel.beads.models.DateChooserModel} */ model = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.jewel.beads.models.DateChooserModel);
  var /** @type {number} */ month = model.displayedMonth + 1;
  var /** @type {number} */ year = model.displayedYear;
  if (month >= 12) {
    month = 0;
    year++;
  }
  model.displayedMonth = month;
  model.displayedYear = year;
};


org.apache.royale.jewel.beads.controllers.DateChooserMouseController.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController__strand = value;
  this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_model = org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.jewel.beads.models.DateChooserModel);
  var /** @type {org.apache.royale.jewel.beads.views.DateChooserView} */ view = org.apache.royale.utils.Language.as(value.getBeadByType(org.apache.royale.core.IBeadView), org.apache.royale.jewel.beads.views.DateChooserView);
  view.prevMonthButton.addEventListener(org.apache.royale.events.MouseEvent.CLICK, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_prevMonthClickHandler, this, 'prevMonthClickHandler'));
  view.nextMonthButton.addEventListener(org.apache.royale.events.MouseEvent.CLICK, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_nextMonthClickHandler, this, 'nextMonthClickHandler'));
  org.apache.royale.utils.Language.as(view.daysTable, org.apache.royale.events.IEventDispatcher, true).addEventListener(org.apache.royale.events.Event.CHANGE, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controllers_DateChooserMouseController_tableHandler, this, 'tableHandler'));
};


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


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



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