1 /** 2 * @fileOverview 3 * Copyright (c) 2013 Regione Autonoma della Sardegna 4 * Published under the GPL license.<br> 5 * See <a href="https://sardegnageoportale.it/webgis/license.txt">https://sardegnageoportale.it/webgis/license.txt</a> 6 * for the full text of the license. 7 * @version 0.1 8 */ 9 10 /** 11 * @namespace framework.plugins 12 */ 13 Ext.namespace("framework.plugins"); 14 15 /** 16 * Plugin for add group layer on the TOC. 17 * @name_ RASAddGroup 18 * @class Plugin for adding group to the TOC. 19 * @constructor 20 * @extends <a target="_blank" href="http://gxp.opengeo.org/master/doc/lib/plugins/Tool.html">gxp.plugins.Tool</a> 21 */ 22 framework.plugins.RASAddGroup = Ext.extend(gxp.plugins.Tool, 23 /** 24 * @lends framework.plugins.RASAddGroup.prototype 25 */ 26 { 27 /** 28 * framework_rasaddgroup plugin type. 29 * @public 30 * @type String 31 */ 32 ptype: "framework_rasaddgroup", 33 34 /** 35 * Text menu item (i18n). 36 * @public 37 * @type string 38 */ 39 addActionMenuText: "Add group", 40 41 /** 42 * Text tooltip item (i18n). 43 * @public 44 * @type string 45 */ 46 addActionTip: "Add group", 47 48 /** 49 * @private 50 * @param {Object} config configuration object 51 */ 52 constructor: function(config) { 53 this.addEvents( 54 /** api: event[sourceselected] 55 * Fired when a new source is selected. 56 * 57 * Listener arguments: 58 * 59 * * tool - :class:`gxp.plugins.AddLayers` This tool. 60 * * source - :class:`gxp.plugins.LayerSource` The selected source. 61 */ 62 "sourceselected", 63 "externalclick" 64 ); 65 this.addListener("externalclick",this.showWindosGroup); 66 framework.plugins.RASAddGroup.superclass.constructor.apply(this, arguments); 67 }, 68 69 /** 70 * Create and append addGroup action 71 * @public 72 * @returns {framework.plugins.RASAddGroup} Object with addGroup control inside 73 */ 74 addActions: function() { 75 var commonOptions = { 76 tooltip: this.addActionTip, 77 text: this.addActionText, 78 menuText: this.addActionMenuText, 79 iconCls: "gxp-icon-addlayers" 80 }; 81 var options; 82 83 options = Ext.apply(commonOptions, { 84 handler: this.showWindosGroup, 85 scope: this 86 }); 87 88 var actions = framework.plugins.RASAddGroup.superclass.addActions.apply(this, [options]); 89 90 return actions; 91 }, 92 93 /** 94 * Create form-popup for group name insert 95 * @private 96 */ 97 showWindosGroup: function() { 98 var self = this; 99 var win = new Ext.Window({ 100 title: this.addActionMenuText, 101 modal: true, 102 hideBorders: true, 103 width: 300, 104 items: [{xtype: "framework_paneladdgroup", 105 header: false, 106 listeners: { 107 "hide": function(cmp) { 108 if (!this.outputTarget) { 109 cmp.ownerCt.hide(); 110 } 111 }, 112 "groupselected": function(panel, groupName) { 113 var obj = self.target.tools['layerManager']; 114 obj.addGroup(groupName); 115 panel.hide(); 116 }, 117 scope: this 118 }}] 119 }).show(); 120 } 121 }), 122 Ext.preg(framework.plugins.RASAddGroup.prototype.ptype, framework.plugins.RASAddGroup);