BodySelection.js 2.23 KB
Ext.define('treps.controller.Bodies.BodySelection', {
	extend: 'Ext.app.Controller',

	requires: [
		'treps.controller.Bodies.BodiesManager'
	],

	views: [
		'Steps.TransformationDefinition.BodySelectionPanel',
		'treps.view.Bodies.BodiesCombo'
	],

	refs: [
        {
            ref: 'bodiesCenterCombo',
			selector: '#centercombo'
		},
        {
            ref: 'bodiesScCombo',
			selector: '#sccombo'
		}
	],

    init: function() {
        var me = this;
		
		//console.log('BodySelection init '+this.getView('Steps.TransformationDefinition.BodySelectionPanel'));
		
    },

	initStore: function(start,stop,onReady)
	{
		var me = this;
		this.getView('Steps.TransformationDefinition.BodySelectionPanel').create();
		console.log("bodies centr combo: "+me.getBodiesCenterCombo());
		console.log("bodies sc combo: "+me.getBodiesScCombo());
		//if(isSc) {
		treps.controller.Bodies.BodiesManager.loadBodiesStore(treps.model.Session.get('id'),'true',start, stop,
			function(store) {
				//console.log(me);
				me.getBodiesScCombo().store = store;
				if (onReady != null) {
					treps.controller.Bodies.BodiesManager.loadBodiesStore(treps.model.Session.get('id'),'false',start, stop,
						function(store) {
							//console.log(me);
							me.getBodiesCenterCombo().store = store;
							if (onReady != null) {
								onReady.call(me, store);
							}
						}
					);
				}
			}
		);
	//} else {
//}
	},
	
	getBodySelWin: function(pTitle) {
		var me = this;
		console.log(this.getView('Steps.TransformationDefinition.BodySelectionPanel'));
		return Ext.create('Ext.window.Window', {
			title: pTitle,
			layout: 'fit',
			modal: true,
			maximizable: false,
			collapsible:false,
			floating:true,
			closable:false,
			centered:true,
			//items:[{xtype:'bodies_panel'}]
		});
	},

	//get 'id name' string of selected sc
	getScBody: function() {
		return this.getBodiesScCombo().getValue()+' '+this.getBodiesScCombo().getRawValue();
	},

	setScBody: function(body) {
		this.getBodiesScCombo().setValue(body);
	},
	
	//get 'id name' string of selected natural body
	getCenterBody: function() {
		return this.getBodiesCenterCombo().getValue()+' '+this.getBodiesCenterCombo().getRawValue();
	},

	setCenterBody: function(body) {
		this.getBodiesCenterCombo().setValue(body);
	}

});