cs.pro.TranslatePanel = Ext.extend(Ext.form.FormPanel, {

	initComponent: function()
	{
		this.translateOptions = new cs.pro.TranslateOptions();

		Ext.apply(this, {
			title: 'Translate',
			frame: true,
			autoHeight: true,
			items:[
				this.translateOptions
			]
		});

		cs.pro.TranslatePanel.superclass.initComponent.apply(this, arguments);
	}
});

cs.pro.TranslateOptions = Ext.extend(Ext.form.FieldSet, {

	getTranslate: function()
	{
		var file;
		if((file = cs.pro.viewport.getSelectedFile()) == false) return;
		Ext.Ajax.request({
			url: 'json/pro_job_translate',
			params: {
				file: file.get('id'),
				type: this.ownerCt.getForm().getValues(false).filetype
			},
			callback: this.gotTranslate,
			scope: this
		});
	},

	gotTranslate: function(options, success, response)
	{
		if(response = cs.common.lib.errorFilter(success, response, this.getResurface))
		{
			cs.pro.viewport.addTab(response.filename, 'translate', response.job);
		}
	},

	initComponent: function()
	{
		this.begin = new Ext.Button({
			text: 'Process Selected File',
			handler: this.getTranslate,
			scope: this
		});
		
		this.radios = new Ext.form.RadioGroup({
			fieldLabel: 'Translate to',
			labelSeparator: ':',
			columns: 1,
			items: [
				{
					checked: true,
					name: 'filetype',
					boxLabel: 'stl &ndash; Stereo Lithography File',
					inputValue: 'stl'
				},
				{
					name: 'filetype',
					boxLabel: 'ply &ndash; Polygon Model Format',
					inputValue: 'ply'
				},
				{
					name: 'filetype',
					boxLabel: 'dxf &ndash; Drawing Interchange Format',
					inputValue: 'dxf'
				},
				{
					name: 'filetype',
					boxLabel: 'wrl &ndash; VRML',
					inputValue: 'wrl'
				},
				{
					name: 'filetype',
					boxLabel: 'obj &ndash; 3D Object',
					inputValue: 'obj'
				}
			]
		});
		
		Ext.apply(this, {
			title: 'Processing Options',
			autoHeight: true,
			items: [
				this.radios
			],
			buttons: [
				this.begin
			]
		});

		cs.pro.TranslateOptions.superclass.initComponent.apply(this, arguments);
	}
});
