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 that make a menu of plugins in input. 17 * Plugins must have a event and listner for 'externalclick' 18 * @name_ MenuPlugins 19 * @class Plugin that make a menu of plugins 20 * @constructor 21 * @extends <a target="_blank" href="http://gxp.opengeo.org/master/doc/lib/plugins/Tool.html">gxp.plugins.Tool</a> 22 */ 23 framework.plugins.MenuPlugins = Ext.extend(gxp.plugins.Tool, 24 /** 25 * @lends framework.plugins.MenuPlugins.prototype 26 */ 27 { 28 /** 29 * framework_rasaddgroup plugin type. 30 * @public 31 * @type String 32 */ 33 ptype: "framework_menuplugins", 34 35 /** 36 * Text menu item (i18n). 37 * @public 38 * @type string 39 */ 40 addActionMenuText: "Add", 41 42 /** 43 * Text tooltip item (i18n). 44 * @public 45 * @type string 46 */ 47 addActionTip: "Add", 48 49 /** 50 * Button image 51 * @public 52 * @type string 53 */ 54 iconCls:null, 55 56 /** 57 * @private 58 * @param {Object} config configuration object 59 */ 60 constructor: function(config) { 61 this.addEvents( 62 /** api: event[sourceselected] 63 * Fired when a new source is selected. 64 * 65 * Listener arguments: 66 * 67 * * tool - :class:`gxp.plugins.AddLayers` This tool. 68 * * source - :class:`gxp.plugins.LayerSource` The selected source. 69 */ 70 "sourceselected" 71 ); 72 framework.plugins.MenuPlugins.superclass.constructor.apply(this, arguments); 73 }, 74 75 /** 76 * Create menu with plugins in input 77 * @public 78 * @returns {framework.plugins.MenuPlugins} Object with MenuPlugins control inside 79 */ 80 addActions: function() { 81 var self = this; 82 var items =[]; 83 for(var i=0;i<this.plugins.length;i++){ 84 var plugin = this.plugins[i]; 85 plugin.target = this.target; 86 plugin.index = i; 87 items.push(new GeoExt.Action({ 88 text: plugin.addActionMenuText, 89 iconCls: plugin.iconCls, 90 disabled: false, 91 handler:function(){ 92 self.plugins[this.index].fireEvent('externalclick'); 93 }, 94 scope:plugin 95 })); 96 } 97 this.button = new Ext.SplitButton({ 98 iconCls: this.iconCls, 99 tooltip: this.addActionTip, 100 buttonText: this.addActionMenuText, 101 toggleGroup: this.toggleGroup, 102 scope: this, 103 menu:items 104 }); 105 return framework.plugins.MenuPlugins.superclass.addActions.apply(this, [this.button]); 106 } 107 }); 108 Ext.preg(framework.plugins.MenuPlugins.prototype.ptype, framework.plugins.MenuPlugins);