FramesSelection.js 1.51 KB
Ext.define('treps.controller.Frames.FramesSelection', {
	extend: 'Ext.app.Controller',

	requires: [
		'treps.controller.Frames.FramesManager'
	],

	views: [
		'Steps.TransformationDefinition.TransformationDefinitionPanel'
	],

	refs: [
                {
                        ref: 'sourceCombo',
                        selector: '#srcSysFrame'
                },
		{
			ref: 'destCombo',
			selector: '#destSysFrame'
		}
	],

        init: function() {
                var me = this;
        },

	initStore: function(onReady)
	{
		var me = this;

		treps.controller.Frames.FramesManager.loadFramesStore(
			function(store)
			{
				me.getSourceCombo().store = store;
				me.getDestCombo().store   = store;
				if (onReady != null)
					onReady.call(me, store);
                        });
	},

	getSrcFrame: function() {
		return this.getSourceCombo().getValue();
	},

	getDstFrame: function() {
		return this.getDestCombo().getValue();
	},

	setSrcFrame: function(srcFrame) {
		this.getSourceCombo().setValue(srcFrame);
	},

	isValid: function() {
		var srcFrame = this.getSrcFrame();
		var dstFrame = this.getDstFrame();

		if ((srcFrame == null) && (dstFrame == null))
		{
			treps.Messages.showError('Please select a source frame and a destination frame');
			return false;
		}
		else if (srcFrame == null)
		{
			treps.Messages.showError('Please select a source frame');
			return false;
		}
		else if (dstFrame == null)
		{
			treps.Messages.showError('Please select a destination frame');
			return false;
		}

		return true;
	}
});