Ext.define("Portfolio.entity.plugin.Chart", {

    extend: "Ext.plugin.Abstract",

	alias: [
        "plugin.entity-grid-chart"
    ],

	config: {
        grid: null,
    },
    
    constructor: function(o_config) {

        var i_self = this;
        i_self.initConfig(o_config);
    },

	init: function(i_grid) {

		var i_self = this;
        i_self.setGrid(i_grid);
        i_self.addButton();
	},

	addButton: function() {

        var i_self = this;
        var i_grid = i_self.getGrid();

        var i_menu = i_grid.headerCt.getMenu();

		i_menu.on({
			beforeshow: {
				fn: function(i_menu) {

					var i_chart = i_menu.getComponent("button-chart");

					if (!i_chart) {

                        i_chart = Ext.widget("menuitem", {
                            itemId: "button-chart",
                            text: ip2.i18n({
                                da: "Charts",
                                en: "Charts"
                            }),
                            iconCls: "pf-chart_candlestick",
                            handler: function(i_button) {
                                
                                Ext.Msg.alert("Test", "This is from plugin");
                            }
                        });

						i_menu.add(i_chart);
					}
				}
			}
		});
	}
});
