PlotIntervalRefPlug.js 3.22 KB
/**
  * Project      :  AMDA-NG
  * Name         : PlotIntervalRefPlug.js
  * @plugin 	  amdaPlotComp.PlotIntervalRefPlug
  * @extends 	  Ext.util.Observable 
  * @ptype 	 	  plotIntervalRefPlugin
  * @brief		 Shows references for Interval
  * @author Furkan
  * @version $Id: PlotIntervalRefPlug.js
  ********************************************************************************
  *    FT Id     :   Date   : Name - Description
  *******************************************************************************
  *  :          
  */


Ext.define('amdaPlotComp.PlotIntervalRefPlug', {
	extend: 'Ext.util.Observable',
	alias: 'plugin.plotIntervalRefPlugin',

	id: 'plot-intervalref-plug',
	win: null,
	form: null,
	interactiveId: '',
	actionDone: '',
	durationDone: 0,

	constructor: function (config) {
		Ext.apply(this, config);
		this.callParent(arguments);
	},

	onDestroy: function () {
		this.win = null;
	},

	init: function (cmp) {
		this.hostCmp = cmp;
	},

	/**
	 *  creation of the window
	 */
	show: function (interactiveId, links, xPos, yPos) {
		if (!this.win) {
			this.win = new Ext.Window({
				id: 'plot-intervalref-win-' + this.hostCmp.ownerCt.getId(), // Plot window ID                                                   
				width: 265,
				x: 0, y: 0,
				baseCls: 'x-panel',
				title: 'Catalogue references',
				layout: 'fit',
				constrain: true,
				collapsible: true,
				resizable: false,
				ghost: false,
				renderTo: this.hostCmp.ownerCt.body,
				items: this.getFormConfig(links),
				listeners: {
					scope: this,
					beforeclose: function () {
						this.hostCmp.panelImage.stopZoom();
						Ext.PluginManager.unregister(this);
					}
				},
				getConstrainVector: function (constrainTo) {
					var me = this;
					if (me.constrain || me.constrainHeader) {
						constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
						return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
					}
				}
			});

			this.win.on('destroy', this.onDestroy, this);

			Ext.PluginManager.register(this);
		}

		this.interactiveId = interactiveId;
		this.win.show();
		this.win.setPosition(xPos, yPos - 250);
	},

	close: function () {
		if (this.win == null)
			return;
		this.win.close();
	},
	/**
	 *        Main form
	 */
	getFormConfig: function (links) {
		this.form = new Ext.form.FormPanel({
			frame: true,
			width: 265,
			height: 80,
			layout: {
				type: 'vbox',
				pack: 'start',
				align: 'stretch'
			},
			fieldDefaults: {
				labelWidth: 60
			},
			items: [
				{
					xtype: 'fieldcontainer',
					layout: 'hbox',
					fieldLabel: 'Select the reference from the list',
					labelAlign: 'top',
					bodyStyle: { background: '#dfe8f6' },
					border: false,
					items: [
						{
							xtype: 'combo',
							name: 'referencelink',
							store: links,
							editable: false,
							width: 250,
							value: 'References',
							triggerAction: 'all'
						}
					],
				}],
			buttons: [

				{
					text: 'Open in new tab',
					scope: this,
					handler: function () {
						var referencelink = this.form.getForm().findField('referencelink');
						window.open(referencelink.getValue(), "_blank");
					}
				}
			]

		});
		return this.form;
	}
});