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  * @requires plugins/Tool.js
 12  * @require GeoExt/widgets/Action.js
 13  */
 14 
 15 /**
 16  * @namespace framework.plugins
 17  */
 18 Ext.namespace("framework.plugins");
 19 
 20 /** 
 21  *  Provides actions for OpenLayers.Control array in input. 
 22  *  Every control object should have the fieds : menuText,iconCls,tooltip,control,enableToggle,allowDepress,toggleGroup
 23  *  @name_ ToolsAction
 24  *  @class Provides actions for OpenLayers.Control array in input.
 25  *  @constructor
 26  *  @extends <a target="_blank" href="http://gxp.opengeo.org/master/doc/lib/plugins/Tool.html">gxp.plugins.Tool</a>
 27  */
 28 framework.plugins.ToolsAction = Ext.extend(gxp.plugins.Tool,
 29         /** 
 30          * @lends framework.plugins.ToolsAction.prototype 
 31          */
 32                 {
 33                     /**
 34                      * framework_toolsaction plugin type.
 35                      * @public
 36                      * @type String
 37                      */
 38                     ptype: "framework_toolsaction",
 39                     /**
 40                      * Array of Controls.
 41                      * Every control should have the fieds : menuText,iconCls,tooltip,control,enableToggle,allowDepress,toggleGroup
 42                      * @public
 43                      * @type String
 44                      */
 45                     controls: null,
 46                     /**
 47                      * @private
 48                      * @param {Object} config configuration object
 49                      */
 50                     constructor: function(config) {
 51                         framework.plugins.ToolsAction.superclass.constructor.apply(this, arguments);
 52                     },
 53                     /**
 54                      * Create and append actions for OpenLayers.Control array in input
 55                      * @public
 56                      * @returns {framework.plugins.ToolsAction} Object with controls inside
 57                      */
 58                     addActions: function() {
 59 
 60                         var actions = [];
 61                         if (this.controls) {
 62                             for (var i = 0; i < this.controls.length; i++) {
 63                                 if (this.controls[i].control){
 64                                     actions.unshift(new GeoExt.Action({
 65                                         menuText: this.controls[i].menuText,
 66                                         iconCls: this.controls[i].iconCls,
 67                                         tooltip: this.controls[i].tooltip,
 68                                         control: this.controls[i].control,
 69                                         map: this.target.mapPanel.map,
 70                                         enableToggle: this.controls[i].enableToggle ? this.controls[i].enableToggle : false,
 71                                         allowDepress: this.controls[i].allowDepress ? this.controls[i].allowDepress : false,
 72                                         toggleGroup: this.controls[i].toggleGroup
 73                                     }));
 74                                 }else if (this.controls[i].handler){
 75                                     actions.unshift(new GeoExt.Action({
 76                                         menuText: this.controls[i].menuText,
 77                                         iconCls: this.controls[i].iconCls,
 78                                         tooltip: this.controls[i].tooltip,
 79                                         handler: this.controls[i].handler,
 80                                         map: this.target.mapPanel.map
 81                                     }));
 82                                 }
 83                             }
 84                         }
 85                         return framework.plugins.ToolsAction.superclass.addActions.apply(this, [actions]);
 86                     }
 87 
 88                 });
 89 
 90         Ext.preg(framework.plugins.ToolsAction.prototype.ptype, framework.plugins.ToolsAction);
 91