ExportManager.js 1.23 KB
Ext.define('treps.controller.Export.ExportManager', {
	singleton : true,

        constructor: function() {
        },

	loadStructuresStore: function(onAfterLoad) {
		var me = this;

		var store = this.getStructuresStore();

		if (store != null)
			store.removeAll();
		else
			store = Ext.create('treps.store.Structures');

		store.load(
			{
				scope: me,
				callback: function(records, operation, success)
				{
					if (!success)
					{
						treps.Messages.showError("Cannot get export structures list");
						return;
					}

					if (onAfterLoad != null)
						onAfterLoad.call(me,store);
				}
			});	
	},

	loadFormatsStore: function(onAfterLoad) {
		var me = this;

		var store = this.getFormatsStore();

		if (store != null)
			store.removeAll();
		else
			store = Ext.create('treps.store.Formats');

		store.load(
			{
				scope: me,
				callback: function(records, operation, success)
				{
					if (!success)
					{
						treps.Messages.showError("Cannot get file format list");
						return;
					}

					if (onAfterLoad != null)
						onAfterLoad.call(me,store);
 				}
			});
	},

	getStructuresStore : function()
	{
		return Ext.getStore('StructuresStore');
	},

	getFormatsStore : function()
	{
		return Ext.getStore('FormatsStore');
	}
});