class WODA {


    constructor() {
        this.what = {};
        this.overview = {};
        this.details = {};
        this.actions = {};
        this.templateMaxDepth = 3;
        this.name = "The Last App you will ever need";
        this.type = "WODA";

        window["TheLastApp"] = this;
        UcpComponentSupport.registerAppInitFunction(
            this.init.bind(this)
        );

    }

    init(controller) {

        var whatPanel = UcpComponentSupport.lookupView("WhatPanel[0]");
        if (whatPanel != null) {
            this.what = whatPanel.controller.singleton;
            this.what.controller._eventSupport.addEventListener("select", this, this.handleSelection.bind(this));

            this.what.whatPanel = whatPanel;
        }

        var overviewPanel = UcpComponentSupport.lookupView("OverviewPanel[0]");
        if (overviewPanel != null) {
            this.overview = overviewPanel.controller.singleton;
            this.overview.controller._eventSupport.addEventListener("select", this, this.handleSelection.bind(this));
            this.overview.overviewPanel = overviewPanel;

        }

        var detailsPanel = UcpComponentSupport.lookupView("DetailsPanel[0]");
        if (detailsPanel != null) {
            this.details = detailsPanel.controller.singleton;
            this.details.controller._eventSupport.addEventListener("select", this, this.handleSelection.bind(this));

            this.details.detailsPanel = detailsPanel;
        }



        return this;
    }


    handleSelection(event, item) {
        var This = event.target;
        if (event.source != This.overview)
            This.overview.select(item);

        This.details.selectedItem = item;
        This.actions.selectedItem = item;

    }

    goToRepository() {
        window.location.href = "http://structr.cerulean.it:6082/WODA-i7/b305af4c135f4ef0bdecb328e09d6362";
    }
    goStructrRepository() {
        window.location.href = "http://structr.cerulean.it:6082/WODA-i7/21a808a48b7745b2b2f7076d6ec4be09 ";
    }

}