text: /*globals define, WebGMEGlobal*/
  /*jshint browser: true*/
  
  /**
   * Generated by VisualizerGenerator 1.7.0 from webgme on Sat Apr 16 2016 20:15:47 GMT-0500 (CDT).
   */
  
  define(["css!./styles/SecondaryWidget.css"], function () {
    "use strict";
  
    var SecondaryWidget,
      WIDGET_CLASS = "secondary";
  
    SecondaryWidget = function (logger, container) {
      this._logger = logger.fork("Widget");
  
      this._el = container;
  
      this.nodes = {};
      this._initialize();
  
      this._logger.debug("ctor finished");
    };
  
    SecondaryWidget.prototype._initialize = function () {
      var width = this._el.width(),
        height = this._el.height(),
        self = this;
  
      // set widget class
      this._el.addClass(WIDGET_CLASS);
  
      // Create a dummy header
      this._el.append("<h3>Secondary Events:</h3>");
  
      // Registering to events can be done with jQuery (as normal)
      this._el.on("dblclick", function (event) {
        event.stopPropagation();
        event.preventDefault();
        self.onBackgroundDblClick();
      });
    };
  
    SecondaryWidget.prototype.onWidgetContainerResize = function (width, height) {
      console.log("Widget is resizing...");
    };
  
    // Adding/Removing/Updating items
    SecondaryWidget.prototype.addNode = function (desc) {
      if (desc) {
        // Add node to a table of nodes
        var node = document.createElement("div"),
          label = "children";
  
        if (desc.childrenIds.length === 1) {
          label = "child";
        }
  
        this.nodes[desc.id] = desc;
        node.innerHTML =
          'Adding node "' +
          desc.name +
          '" (click to view). It has ' +
          desc.childrenIds.length +
          " " +
          label +
          ".";
  
        this._el.append(node);
        node.onclick = this.onNodeClick.bind(this, desc.id);
      }
    };
  
    SecondaryWidget.prototype.removeNode = function (gmeId) {
      var desc = this.nodes[gmeId];
      this._el.append('<div>Removing node "' + desc.name + '"</div>');
      delete this.nodes[gmeId];
    };
  
    SecondaryWidget.prototype.updateNode = function (desc) {
      if (desc) {
        console.log("Updating node:", desc);
        this._el.append('<div>Updating node "' + desc.name + '"</div>');
      }
    };
  
    /* * * * * * * * Visualizer event handlers * * * * * * * */
  
    SecondaryWidget.prototype.onNodeClick = function (id) {
      // This currently changes the active node to the given id and
      // this is overridden in the controller.
    };
  
    SecondaryWidget.prototype.onBackgroundDblClick = function () {
      this._el.append("<div>Background was double-clicked!!</div>");
    };
  
    /* * * * * * * * Visualizer life cycle callbacks * * * * * * * */
    SecondaryWidget.prototype.destroy = function () {};
  
    SecondaryWidget.prototype.onActivate = function () {
      console.log("SecondaryWidget has been activated");
    };
  
    SecondaryWidget.prototype.onDeactivate = function () {
      console.log("SecondaryWidget has been deactivated");
    };
  
    return SecondaryWidget;
  });
  