Ext.define('Ext.ux.folderExplorer.LogGrid', {
	extend: 'Ext.grid.Panel',
	alias: 'widget.folderExplorerLogGrid',
	initComponent: function() {
		var me = this;

		var modelName = 'folderExplorerLogRows';

		if (!Ext.ClassManager.isCreated(modelName)) {
			Ext.define(modelName, {
				extend: 'Ext.data.Model',
				proxy: {
					type: 'ajax',
					url: '/ip2-services/ip2Services.aspx?func=getFolderExplorerLogRows',
					reader: {
						type: 'json',
						rootProperty: 'rows'
					}
				}
			});
		}

		me.columns = [
			{ header: me.getI18N('message'), dataIndex: 'LTMSG', flex: 1 }
		];

		me.store = Ext.create('Ext.data.Store', {
			model: modelName,
			autoLoad: true,
			listeners: {
				beforeload: function(store) {
					store.proxy.extraParams.spreadsheet = me.record.data.path;
				}
			}
		});

		me.dockedItems = [{
			xtype: 'toolbar',
			dock: 'top',
			items: [{
				xtype: 'button',
				text: me.getI18N('refresh'),
				iconCls: 'pf-refresh',
				handler: function() {
					me.store.load();
				}
			}]
		}];

		me.callParent();
	},

	/* ----------------------------------------------------------------------------------------------------
		get I18N by key
	---------------------------------------------------------------------------------------------------- */
	getI18N: function(key) {
		return ip2.i18n(ip2.folderExplorer.getTextValue(key));
	}
});
