/// class PD.Manage.Modules.ViewDesignFeature

/**
@class ViewDesignFeature
@constructor
@namespace PD.Manage.Modules
@extends Web.UI.FeatureSets.MacroEditorBase
**/
PD.Manage.Modules.ViewDesignFeature =
ProspectDirector.Web.UI.FeatureSets.MacroEditorBase.extend({

    //==============================
    // FIELDS
    //==============================

    _area: null,
    _viewGrid: null,
    
    //==============================
    // INITIALIZERS
    //==============================

    _init_controls: function () {
        this._init_area();
        this._init_grid();
    },

    _init_area: function () {

        this._area = new PD.Web.UI.Controls.Control({
            container: this.get_container(),
            template: [
                "<div style='height:100%;'>",
                    "<div data-id='toolbar-area' style='position:absolute;height:30px;top:10px;left:10px;right:10px;border-width:0px;overflow:hidden;'>",
                    "</div>",
                    "<div data-id='grid-area' style='position:absolute;top:50px;left:10px;bottom:10px;right:10px;border:1px solid #DDDDDD;'></div>",
                "</div>",
            ]
        });

    },

    _init_grid: function () {

        var that = this;

        this._viewGrid = new PD.Web.UI.Controls.ViewGrid({
            insertAt: "[data-id=grid-area]",
            height: "100%",
            viewStateId: that.get_data()["viewStateId"],
            defaultSelectionEnabled: false,
            ready: function () {
                that._init_toolbar();
            }
        });

        this._area.get_children().add(this._viewGrid);

    },

    _init_toolbar: function () {

        var grid = this._viewGrid;

        this._toolbar = new PD.Web.UI.Controls.Toolbar({
            insertAt: "[data-id=toolbar-area]",
            segments: [
                new PD.Manage.Modules.ViewDesignToolbar(function () {
                    return {
                        viewGrid: grid
                    }
                })
            ]
        });

        this._area.get_children().add(this._toolbar);

    },

    //==============================
    // PUBLIC METHODS
    //==============================

    activate: function () {
        this._init_controls();
    },

    commit: function () {
    },

    size: function () {
        if (this._viewGrid) {
            this._viewGrid.redraw();
        }
    },

    render: function () {
        return "<div id='" + this.getId() + "' style='padding:10px;'></div>";
    }

});