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

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

goog.require('org.apache.royale.core.IBeadModel');
goog.require('org.apache.royale.core.IMenu');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.events.ItemClickedEvent');
goog.require('org.apache.royale.html.CascadingMenu');
goog.require('org.apache.royale.html.beads.controllers.MenuSelectionMouseController');
goog.require('org.apache.royale.html.beads.models.CascadingMenuModel');
goog.require('org.apache.royale.utils.Language');



/**
 * Constructor.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @constructor
 * @extends {org.apache.royale.html.beads.controllers.MenuSelectionMouseController}
 */
org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController = function() {
  org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController.base(this, 'constructor');
};
goog.inherits(org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController, org.apache.royale.html.beads.controllers.MenuSelectionMouseController);


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


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


/**
 * @asprivate
 * 
 * Replaces the selectedHandler from the super class to handle the presentation of
 * submenus. If an element has the submenu indicator, a new CascadingMenu is presented.
 * If the element is a regular element, then the super class's handler is called.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9
 * @protected
 * @override
 */
org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController.prototype.selectedHandler = function(event) {
  var /** @type {Object} */ node = event.data;
  var /** @type {org.apache.royale.html.beads.models.CascadingMenuModel} */ model = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_CascadingMenuSelectionMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.html.beads.models.CascadingMenuModel);
  if (node.hasOwnProperty(model.submenuField)) {
    var /** @type {org.apache.royale.core.IUIBase} */ component = org.apache.royale.utils.Language.as(event.target, org.apache.royale.core.IUIBase);
    var /** @type {org.apache.royale.core.IMenu} */ menu = new org.apache.royale.html.CascadingMenu();
    menu.dataProvider = node[model.submenuField];
    menu.labelField = model.labelField;
    menu.parentMenuBar = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_CascadingMenuSelectionMouseController__strand, org.apache.royale.core.IMenu).parentMenuBar;
    menu.show(component, component.width, 0);
  } else {
    org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController.superClass_.selectedHandler.apply(this, [ event] );
    this.hideOpenMenus();
  }
};


org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_controllers_CascadingMenuSelectionMouseController__strand = value;
  org.apache.royale.html.beads.controllers.CascadingMenuSelectionMouseController.superClass_.set__strand.apply(this, [ value] );
};


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


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



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