Changeset 1188

Show
Ignore:
Timestamp:
07/01/09 02:49:38 (4 years ago)
Author:
tschaub
Message:

Using GeoExt.Action instead of MapTool*.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js

    r1186 r1188  
    66 * @requires GeoExplorer/util.js 
    77 * @requires GeoExplorer/GroupContainer.js 
    8  * @requires GeoExplorer/MapToolSplitToggle.js 
    98 * @requires GeoExplorer/CapabilitiesGrid.js 
    109 * @requires GeoExplorer/NewSourceWindow.js 
     
    10961095        this.mapPanel.layers.on("remove", updateInfo, this); 
    10971096 
    1098         // create length measure control 
    1099         var measureLength = this.createMeasureTool( 
    1100             OpenLayers.Handler.Path, 'Length'); 
    1101         this.map.addControl(measureLength); 
    1102          
    1103         // create area measure control 
    1104         var measureArea = this.createMeasureTool( 
    1105             OpenLayers.Handler.Polygon, 'Area'); 
    1106         this.map.addControl(measureArea); 
    1107  
     1097        // create split button for measure controls 
     1098        var activeIndex = 0; 
     1099        var measureSplit = new Ext.SplitButton({ 
     1100            iconCls: "icon-measure-length", 
     1101            tooltip: "Measure", 
     1102            enableToggle: true, 
     1103            toggleGroup: toolGroup, // Ext doesn't respect this, registered with ButtonToggleMgr below 
     1104            allowDepress: false, // Ext doesn't respect this, handler deals with it 
     1105            handler: function(button, event) { 
     1106                // allowDepress should deal with this first condition 
     1107                if(!button.pressed) { 
     1108                    button.toggle(); 
     1109                } else { 
     1110                    button.menu.items.itemAt(activeIndex).setChecked(true); 
     1111                } 
     1112            }, 
     1113            listeners: { 
     1114                toggle: function(button, pressed) { 
     1115                    // toggleGroup should handle this 
     1116                    if(!pressed) { 
     1117                        button.menu.items.each(function(i) { 
     1118                            i.setChecked(false); 
     1119                        }); 
     1120                    } 
     1121                }, 
     1122                render: function(button) { 
     1123                    // toggleGroup should handle this 
     1124                    Ext.ButtonToggleMgr.register(button); 
     1125                } 
     1126            }, 
     1127            menu: new Ext.menu.Menu({ 
     1128                items: [ 
     1129                    new Ext.menu.CheckItem( 
     1130                        new GeoExt.Action({ 
     1131                            text: "Length", 
     1132                            iconCls: "icon-measure-length", 
     1133                            map: this.map, 
     1134                            toggleGroup: toolGroup, 
     1135                            group: toolGroup, 
     1136                            allowDepress: false, 
     1137                            map: this.map, 
     1138                            control: this.createMeasureControl( 
     1139                                OpenLayers.Handler.Path, "Length" 
     1140                            ) 
     1141                        }) 
     1142                    ), 
     1143                    new Ext.menu.CheckItem( 
     1144                        new GeoExt.Action({ 
     1145                            text: "Area", 
     1146                            iconCls: "icon-measure-area", 
     1147                            map: this.map, 
     1148                            toggleGroup: toolGroup, 
     1149                            group: toolGroup, 
     1150                            allowDepress: false, 
     1151                            map: this.map, 
     1152                            control: this.createMeasureControl( 
     1153                                OpenLayers.Handler.Polygon, "Area" 
     1154                            ) 
     1155                        }) 
     1156                    ) 
     1157                ] 
     1158            }) 
     1159        }); 
     1160        measureSplit.menu.items.each(function(item, index) { 
     1161            item.on({checkchange: function(item, checked) { 
     1162                measureSplit.toggle(checked); 
     1163                if(checked) { 
     1164                    activeIndex = index; 
     1165                    measureSplit.setIconClass(item.iconCls); 
     1166                } 
     1167            }}); 
     1168        }); 
     1169     
    11081170        var tools = [ 
    11091171            navAction, 
    11101172            infoButton, 
    1111             new GeoExplorer.MapToolSplitToggle({ 
    1112                 tooltip: "Measure", 
    1113                 iconCls: "icon-measure-length", 
    1114                 defaultTool: measureLength, 
    1115                 allowDepress: false, 
    1116                 tools: [ 
    1117                     {text: 'Length', tool: measureLength, iconCls: 'icon-measure-length'},  
    1118                     {text: 'Area', tool: measureArea, iconCls: 'icon-measure-area'} 
    1119                 ], 
    1120                 enableToggle: true, 
    1121                 toggleGroup: toolGroup  
    1122             }), 
     1173            measureSplit, 
    11231174            "-", 
    11241175            new Ext.Button({ 
     
    11661217    }, 
    11671218 
    1168     /** private: method[createMeasureTool] 
     1219    /** private: method[createMeasureControl] 
    11691220     * :param: handlerType: the :class:`OpenLayers.Handler` for the measurement 
    11701221     *     operation 
     
    11741225     * control 
    11751226     */ 
    1176     createMeasureTool: function(handlerType, title) { 
     1227    createMeasureControl: function(handlerType, title) { 
    11771228         
    11781229        var styleMap = new OpenLayers.StyleMap({ 
  • apps/opengeo/geoexplorer/trunk/src/script/app/loader.js

    r1165 r1188  
    11(function() { 
    22 
    3     // Since the applications are located one directory down from 
    4     // the base, all these includes must be prefixed by a ../ 
    53    var jsfiles = new Array( 
    64        "../../src/script/app/GeoExplorer.js", 
    75        "../../src/script/app/GeoExplorer/util.js", 
    8         "../../src/script/app/GeoExplorer/MapToolToggle.js", 
    9         "../../src/script/app/GeoExplorer/MapToolSplitToggle.js", 
    10         "../../src/script/app/GeoExplorer/MapToolMenu.js", 
    116        "../../src/script/app/GeoExplorer/Wizard.js", 
    127        "../../src/script/app/GeoExplorer/LayerMenuItem.js", 
  • apps/opengeo/geoexplorer/trunk/src/theme/app/geoexplorer.css

    r1184 r1188  
    5252} 
    5353 
    54 .x-btn .icon-measure-length, .icon-measure-length { 
    55     background-image: url(img/geosilk/ruler.png); 
    56 
    57  
    58 .x-btn .icon-measure-area, .icon-measure-area { 
    59    background-image: url(img/geosilk/ruler_square.png); 
     54.x-btn .icon-measure { 
     55    background-image: url(img/geosilk/measure.png); 
     56
     57 
     58.icon-measure-length { 
     59    background-image: url(img/geosilk/ruler.png) !important; 
     60
     61 
     62.icon-measure-area { 
     63   background-image: url(img/geosilk/ruler_square.png) !important; 
    6064} 
    6165