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

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

goog.require('org.apache.royale.collections.ITreeData');
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.ItemClickedEvent');
goog.require('org.apache.royale.html.beads.controllers.ListSingleSelectionMouseController');
goog.require('org.apache.royale.utils.Language');



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


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


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


/**
 * @asprivate
 * @protected
 * @override
 */
org.apache.royale.html.beads.controllers.TreeSingleSelectionMouseController.prototype.selectedHandler = function(event) {
  var /** @type {org.apache.royale.collections.ITreeData} */ treeData = org.apache.royale.utils.Language.as(this.listModel.dataProvider, org.apache.royale.collections.ITreeData);
  if (treeData == null)
    return;
  var /** @type {Object} */ node = event.data;
  if (treeData.hasChildren(node)) {
    if (treeData.isOpen(node)) {
      treeData.closeNode(node);
    } else {
      treeData.openNode(node);
    }
  }
  this.listModel.selectedItem = node;
  org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_TreeSingleSelectionMouseController__strand, org.apache.royale.events.IEventDispatcher, true).dispatchEvent(new org.apache.royale.events.Event("change"));
};


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


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


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



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