[Commits] r839 - in apps/opengeo/geoexplorer/trunk: . lib lib/GeoExplorer
commits at geoext.org
commits at geoext.org
Thu May 21 21:57:31 CEST 2009
Author: tcoulter
Date: 2009-05-21 21:57:30 +0200 (Thu, 21 May 2009)
New Revision: 839
Added:
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/CapabilitiesGrid.js
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolMenu.js
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolSplitToggle.js
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolToggle.js
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/RowExpander.js
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Viewer.js
Removed:
apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js
apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js
apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js
apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js
apps/opengeo/geoexplorer/trunk/lib/RowExpander.js
apps/opengeo/geoexplorer/trunk/lib/Viewer.js
Modified:
apps/opengeo/geoexplorer/trunk/debug.html
Log:
Start of resource refactoring. Structuring files like our other projects.
Modified: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/debug.html 2009-05-21 19:57:30 UTC (rev 839)
@@ -23,13 +23,14 @@
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="theme/ie.css"/><![endif]-->
- <script type="text/javascript" src="lib/RowExpander.js"></script>
- <script type="text/javascript" src="lib/CapabilitiesGrid.js"></script>
- <script type="text/javascript" src="lib/Viewer.js"></script>
+
+ <script type="text/javascript" src="lib/GeoExplorer/RowExpander.js"></script>
+ <script type="text/javascript" src="lib/GeoExplorer/CapabilitiesGrid.js"></script>
+ <script type="text/javascript" src="lib/GeoExplorer/Viewer.js"></script>
<script type="text/javascript" src="lib/GeoExplorer.js"></script>
- <script type="text/javascript" src="lib/MapToolMenu.js"></script>
- <script type="text/javascript" src="lib/MapToolSplitToggle.js"></script>
- <script type="text/javascript" src="lib/MassGetFeatureInfo.js"></script>
+ <script type="text/javascript" src="lib/GeoExplorer/MapToolMenu.js"></script>
+ <script type="text/javascript" src="lib/GeoExplorer/MapToolSplitToggle.js"></script>
+ <script type="text/javascript" src="lib/GeoExplorer/MassGetFeatureInfo.js"></script>
<script>
Ext.BLANK_IMAGE_URL = "theme/img/blank.gif";
Deleted: apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -1,120 +0,0 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- *
- * Requires RowExpander.js from Ext examples
- */
-
-/**
- * Class: CapabilitiesGrid
- * Create a new grid displaying the WMS cabilities of a URL,
- * or the contents of a <GeoExt.data.WMSCapabilitiesStore>. The user can
- * add layers to a passed in <GeoExt.MapPanel> from the grid.
- *
- * Extends:
- * - <Ext.grid.GridPanel>
- */
-
-/**
- * Constructor: CapabilitiesGrid
- * Creates a panel with a map inside it.
- *
- * Parameters:
- * config - {Object} A config object. In addition to the config options
- * of its parent class, this object can receive specific options,
- * see the API properties to know about these specific options.
- */
-
-var CapabilitiesGrid = Ext.extend(Ext.grid.GridPanel, {
-
- store: null,
-
- cm: null,
-
- /**
- * APIProperty: mapPanel
- * {<GeoExt.MapPanel>} A MapPanel to which layers can be added
- * via this grid.
- */
- mapPanel : null,
-
- /**
- * APIProperty: url
- * {String} An OWS url to which the GetCapabilities request is sent.
- * Necessary if a store is not passed in as a configuration option.
- */
- url: null,
-
- autoExpandColumn: "title",
-
- /**
- * Method: initComponent
- *
- * Initializes the CapabilitiesGrid. Creates and loads a WMS
- * Capabilities store from the url property if one is not passed as a
- * configuration option.
- */
- initComponent: function(){
-
- if(!this.store){
- this.store = new GeoExt.data.WMSCapabilitiesStore({
- url: this.url + "?service=wms&request=GetCapabilities"
- });
-
- this.store.load();
- }
-
- var expander = new Ext.grid.RowExpander({
- tpl : new Ext.Template(
- '<p><b>Abstract:</b> {abstract}</p>'
- )
- });
-
- this.plugins = expander;
-
- this.cm = new Ext.grid.ColumnModel([
- expander,
- {header: "Name", dataIndex: "name", width: 180, sortable: true},
- {id: "title", header: "Title", dataIndex: "title", sortable: true},
- {header: "Queryable", dataIndex: "queryable"}
- ]);
-
- CapabilitiesGrid.superclass.initComponent.call(this);
- },
-
- /**
- * Method: addLayers
- *
- * Adds a layer to the <GeoExt.MapPanel> of this instance.
- */
- addLayers : function(){
-
- var sm = this.getSelectionModel();
-
- //for now just use the first selected record
- //TODO: force single selection (until we allow
- //adding group layers)
- var records = sm.getSelections();
-
- var record, layer;
- for(var i = 0; i < records.length; i++){
- record = records[i].copy(++Ext.data.Record.AUTO_ID);
- /*
- * TODO: deal with srs and maxExtent
- * At this point, we need to think about SRS if we want the layer to
- * have a maxExtent. For our app, we are dealing with EPSG:4326
- * only. This will have to be made more generic for apps that use
- * other srs.
- */
- layer = record.get("layer");
- layer.restrictedExtent = OpenLayers.Bounds.fromArray(record.get("llbbox"));
-
- if (this.alignToGrid) {
- layer.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
- } else {
- layer.maxExtent = layer.restrictedExtent;
- }
- this.mapPanel.layers.add(record);
- }
-
- }
-});
Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/CapabilitiesGrid.js (from rev 621, apps/opengeo/geoexplorer/trunk/lib/CapabilitiesGrid.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/CapabilitiesGrid.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/CapabilitiesGrid.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -0,0 +1,120 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ *
+ * Requires RowExpander.js from Ext examples
+ */
+
+/**
+ * Class: CapabilitiesGrid
+ * Create a new grid displaying the WMS cabilities of a URL,
+ * or the contents of a <GeoExt.data.WMSCapabilitiesStore>. The user can
+ * add layers to a passed in <GeoExt.MapPanel> from the grid.
+ *
+ * Extends:
+ * - <Ext.grid.GridPanel>
+ */
+
+/**
+ * Constructor: CapabilitiesGrid
+ * Creates a panel with a map inside it.
+ *
+ * Parameters:
+ * config - {Object} A config object. In addition to the config options
+ * of its parent class, this object can receive specific options,
+ * see the API properties to know about these specific options.
+ */
+
+var CapabilitiesGrid = Ext.extend(Ext.grid.GridPanel, {
+
+ store: null,
+
+ cm: null,
+
+ /**
+ * APIProperty: mapPanel
+ * {<GeoExt.MapPanel>} A MapPanel to which layers can be added
+ * via this grid.
+ */
+ mapPanel : null,
+
+ /**
+ * APIProperty: url
+ * {String} An OWS url to which the GetCapabilities request is sent.
+ * Necessary if a store is not passed in as a configuration option.
+ */
+ url: null,
+
+ autoExpandColumn: "title",
+
+ /**
+ * Method: initComponent
+ *
+ * Initializes the CapabilitiesGrid. Creates and loads a WMS
+ * Capabilities store from the url property if one is not passed as a
+ * configuration option.
+ */
+ initComponent: function(){
+
+ if(!this.store){
+ this.store = new GeoExt.data.WMSCapabilitiesStore({
+ url: this.url + "?service=wms&request=GetCapabilities"
+ });
+
+ this.store.load();
+ }
+
+ var expander = new Ext.grid.RowExpander({
+ tpl : new Ext.Template(
+ '<p><b>Abstract:</b> {abstract}</p>'
+ )
+ });
+
+ this.plugins = expander;
+
+ this.cm = new Ext.grid.ColumnModel([
+ expander,
+ {header: "Name", dataIndex: "name", width: 180, sortable: true},
+ {id: "title", header: "Title", dataIndex: "title", sortable: true},
+ {header: "Queryable", dataIndex: "queryable"}
+ ]);
+
+ CapabilitiesGrid.superclass.initComponent.call(this);
+ },
+
+ /**
+ * Method: addLayers
+ *
+ * Adds a layer to the <GeoExt.MapPanel> of this instance.
+ */
+ addLayers : function(){
+
+ var sm = this.getSelectionModel();
+
+ //for now just use the first selected record
+ //TODO: force single selection (until we allow
+ //adding group layers)
+ var records = sm.getSelections();
+
+ var record, layer;
+ for(var i = 0; i < records.length; i++){
+ record = records[i].copy(++Ext.data.Record.AUTO_ID);
+ /*
+ * TODO: deal with srs and maxExtent
+ * At this point, we need to think about SRS if we want the layer to
+ * have a maxExtent. For our app, we are dealing with EPSG:4326
+ * only. This will have to be made more generic for apps that use
+ * other srs.
+ */
+ layer = record.get("layer");
+ layer.restrictedExtent = OpenLayers.Bounds.fromArray(record.get("llbbox"));
+
+ if (this.alignToGrid) {
+ layer.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
+ } else {
+ layer.maxExtent = layer.restrictedExtent;
+ }
+ this.mapPanel.layers.add(record);
+ }
+
+ }
+});
Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolMenu.js (from rev 621, apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolMenu.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolMenu.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * About: Examples
+ *
+ * This example uses default names and icons for the menu entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * > var menu = new MapToolMenu({tools: [measure, select, zoomBox, draw]});
+ *
+ * This one provides a custom name and icon for one of the entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * > var menu = new MapToolMenu({tools: [{
+ * > text: 'Find a distance',
+ * > tool: measure,
+ * > iconCls: 'x-icon-distance-finder'
+ * > },
+ * > select,
+ * > zoomBox,
+ * > draw
+ * > ]});
+ */
+
+/*
+ * Constructor: MapToolMenu
+ * Simply create a menu that manipulates OpenLayers map controls
+ *
+ * Parameters:
+ * config - {Object} Various options, see {Ext.menu.Menu}
+ *
+ * In addition to the normal [items] array, MapToolMenu recognizes a [tools] array.
+ * This can be an array of OpenLayers Control objects, or of simple configuration
+ * objects analogous to Ext Map entries.
+ */
+var MapToolMenu = function(options) {
+ options.items = options.items || [];
+
+ var disableTools = function() {
+ for (var i = 0, len = options.tools.length; i < len; i++) {
+ var t = options.tools[i].tool || options.tools[i];
+ t.deactivate();
+ }
+ };
+
+ for (var i = 0, len = options.tools.length; i < len; i++) {
+ var conf = options.tools[i];
+ var t = conf.tool || conf;
+ options.items.push(Ext.applyIf(conf, {
+ text: t.CLASS_NAME,
+ iconCls: t.CLASS_NAME,
+ handler: (function(tool){
+ return function() {
+ disableTools();
+ tool.activate();
+ };
+ })(t),
+ scope: this
+ }));
+ }
+ MapToolMenu.superclass.constructor.call(this, options);
+};
+
+Ext.extend(MapToolMenu, Ext.menu.Menu);
Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolSplitToggle.js (from rev 621, apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolSplitToggle.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolSplitToggle.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -0,0 +1,153 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ *
+ * @requires MapToolMenu.js
+ */
+
+/**
+ * About: Examples
+ *
+ * This example uses default names and icons for the button and menu entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * : var menu = new MapToolSplitToggle({defaultTool: select, tools: [measure, select, zoomBox, draw]});
+ *
+ * This one provides a custom name and icon for one of the entries.
+ * : var measure, select, zoomBox, draw; // OpenLayers Controls
+ * : var menu = new MapToolSplitToggle({
+ * > defaultTool: zoomBox,
+ * > tools: [{
+ * > text: 'Find a distance',
+ * > tool: measure,
+ * > iconCls: 'x-icon-distance-finder'
+ * > },
+ * > select,
+ * > zoomBox,
+ * > draw
+ * > ]});
+ */
+
+/**
+ * Constructor: MapToolSplitToggle
+ * Creates an Ext SplitButton suited to switching between multiple related OpenLayers Controls.
+ * The MapToolSplitToggle accepts an array of controls, which can be activated from the dropdown menu.
+ * The main button simply toggles the most recently used control.
+ *
+ * Parameters:
+ * config - {Object} the configuration options for this split toggle, see {Ext.SplitButton}.
+ *
+ * In addition to the options accepted by Ext.SplitButton, the MapToolSplitToggle accepts:
+ * defaultTool - {OpenLayers.Control} the control which is to be activated if the button is toggled
+ * before the user selects one from the drop-down menu.
+ * tools - {Array} the controls to display in the drop-down menu. These may be simple Control objects,
+ * or Ext menu specifications with a tool parameter containing the control. (see MapToolMenu)
+ */
+var MapToolSplitToggle = function(options) {
+ this.lastActiveTool = options.defaultTool || options.tools[0];
+ this.tools = options.tools;
+
+ Ext.applyIf(options, {
+ enableToggle: true,
+ iconCls: this.findIconCls(),
+ toggleHandler: this.handleEvent,
+ handler: this.handleEvent,
+ scope: this,
+ menu: new MapToolMenu({tools: options.tools})
+ });
+
+ options.menu.on("itemclick", this.handleMenu, this);
+
+ MapToolSplitToggle.superclass.constructor.call(this, options);
+
+ if (options.toggleGroup) {
+ this.on("render",
+ function() {Ext.ButtonToggleMgr.register(this);},
+ this
+ );
+ }
+
+};
+
+Ext.extend(MapToolSplitToggle, Ext.SplitButton, {
+ /**
+ * Property: lastActiveTool
+ * The most recently selected OpenLayers Control, to be toggled when the main button is.
+ */
+ lastActiveTool: null,
+
+ /**
+ * Property: tools
+ * {Array} the OpenLayers tools from this component's configuration.
+ */
+ tools: null,
+
+ onClick: function (e) {
+ e.preventDefault();
+ if (!this.disabled) {
+ if (e.getTarget(".x-btn-menu-arrow-wrap")) {
+ if (this.menu
+ && !this.menu.isVisible()
+ && !this.ignoreNextClick) {
+ this.showMenu();
+ }
+ this.fireEvent("arrowclick", this, e);
+ if (this.arrowHandler) {
+ this.arrowHandler.call(this.scope || this, this, e);
+ }
+ } else {
+ if (this.enableToggle
+ && (this.allowDepress !== false
+ || !this.pressed)) {
+ this.toggle();
+ }
+ this.fireEvent("click", this, e);
+ if (this.handler) {
+ this.handler.call(this.scope || this, this, e);
+ }
+ }
+ }
+ },
+
+ /**
+ * Method: handleEvent
+ * Called when the main button is toggled, handled the (de)activation of the last active tool.
+ *
+ * Parameters:
+ * item - the component that triggered the event (ie, this SplitButton)
+ */
+ handleEvent: function(item) {
+ if (item.pressed) {
+ this.lastActiveTool.activate();
+ } else {
+ this.lastActiveTool.deactivate();
+ }
+ },
+
+ /**
+ * Method: handleMenu
+ * Called when an item in the menu is selected. All this does is update lastActiveTool;
+ * the menu should be a {MapToolMenu} to handle the control (de)activation.
+ *
+ * Parameters:
+ * item - the component that triggered the event (ie, the Menu item)
+ * evt - the Ext selection event
+ */
+ handleMenu: function(item, evt) {
+ for (var i = 0, len = this.tools.length; i < len; i++) {
+ var t = this.tools[i].tool || this.tools[i];
+ if (t.active) {
+ this.lastActiveTool = t;
+ this.toggle(true);
+ }
+ }
+ },
+
+ /**
+ * Method: findIconCls
+ * Determine the icon class for this split button, based on the {OpenLayers.Control} the
+ * button has been configured with.
+ */
+ findIconCls: function() {
+ return this.lastActiveTool.CLASS_NAME;
+ }
+
+});
Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolToggle.js (from rev 621, apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolToggle.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/MapToolToggle.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * About: Examples
+ *
+ * This example uses default names and icons for the button.
+ * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
+ * : var btn = new MapToolToggle({tool: measure});
+ *
+ * This one provides a custom name and icon.
+ * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
+ * : var btn = new MapToolToggle({
+ * > text: 'Find a distance',
+ * > tool: measure,
+ * > iconCls: 'x-icon-distance-finder'
+ * > });
+ */
+
+/**
+ * Constructor: MapToolToggle
+ * Creates an Ext Button suited to activating and deactivating an {OpenLayers.Control}.
+ * The MapToolToggle accepts a control as part of its configuration.
+ *
+ * Parameters:
+ * config - {Object} the configuration options for this split toggle, see {Ext.Button}.
+ *
+ * In addition to the options accepted by Ext.Button, the MapToolToggle accepts:
+ * tool - {OpenLayers.Control} the control which is to be manipulated by the button
+ */
+var MapToolToggle = function(options) {
+ this.mapTool = options.tool;
+ Ext.applyIf(options, {
+ text: this.findLabel(),
+ enableToggle: true,
+ iconCls: this.findIconCls(),
+ handler: this.handleEvent,
+ scope: this
+ });
+ MapToolToggle.superclass.constructor.call(this, options);
+};
+
+Ext.extend(MapToolToggle, Ext.Button, {
+ /**
+ * Property: mapTool
+ * The OpenLayers Control that this Action toggles.
+ */
+ mapTool: null,
+
+ /**
+ * Method: handleEvent
+ * Called when the main button is toggled, handled the (de)activation of the last active tool.
+ *
+ * Parameters:
+ * item - the component that triggered the event (ie, this SplitButton)
+ */
+ handleEvent: function(item) {
+ if (item.pressed) {
+ this.mapTool.activate();
+ } else {
+ this.mapTool.deactivate();
+ }
+ },
+
+ /**
+ * Method: findIconCls
+ * Determine the icon class for this split button, based on the {OpenLayers.Control} the
+ * button has been configured with.
+ */
+ findIconCls: function() {
+ return this.mapTool.CLASS_NAME;
+ },
+
+ /**
+ * Method: findLabel
+ * Determine the text label for this split button, based on the {OpenLayers.Control} the
+ * button has been configured with.
+ */
+ findLabel: function() {
+ return this.mapTool.CLASS_NAME;
+ }
+});
Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/RowExpander.js (from rev 621, apps/opengeo/geoexplorer/trunk/lib/RowExpander.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/RowExpander.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/RowExpander.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -0,0 +1,136 @@
+/*
+ * Ext JS Library 2.2.1
+ * Copyright(c) 2006-2009, Ext JS, LLC.
+ * licensing at extjs.com
+ *
+ * http://extjs.com/license
+ */
+
+Ext.grid.RowExpander = function(config){
+ Ext.apply(this, config);
+
+ this.addEvents({
+ beforeexpand : true,
+ expand: true,
+ beforecollapse: true,
+ collapse: true
+ });
+
+ Ext.grid.RowExpander.superclass.constructor.call(this);
+
+ if(this.tpl){
+ if(typeof this.tpl == 'string'){
+ this.tpl = new Ext.Template(this.tpl);
+ }
+ this.tpl.compile();
+ }
+
+ this.state = {};
+ this.bodyContent = {};
+};
+
+Ext.extend(Ext.grid.RowExpander, Ext.util.Observable, {
+ header: "",
+ width: 20,
+ sortable: false,
+ fixed:true,
+ menuDisabled:true,
+ dataIndex: '',
+ id: 'expander',
+ lazyRender : true,
+ enableCaching: true,
+
+ getRowClass : function(record, rowIndex, p, ds){
+ p.cols = p.cols-1;
+ var content = this.bodyContent[record.id];
+ if(!content && !this.lazyRender){
+ content = this.getBodyContent(record, rowIndex);
+ }
+ if(content){
+ p.body = content;
+ }
+ return this.state[record.id] ? 'x-grid3-row-expanded' : 'x-grid3-row-collapsed';
+ },
+
+ init : function(grid){
+ this.grid = grid;
+
+ var view = grid.getView();
+ view.getRowClass = this.getRowClass.createDelegate(this);
+
+ view.enableRowBody = true;
+
+ grid.on('render', function(){
+ view.mainBody.on('mousedown', this.onMouseDown, this);
+ }, this);
+ },
+
+ getBodyContent : function(record, index){
+ if(!this.enableCaching){
+ return this.tpl.apply(record.data);
+ }
+ var content = this.bodyContent[record.id];
+ if(!content){
+ content = this.tpl.apply(record.data);
+ this.bodyContent[record.id] = content;
+ }
+ return content;
+ },
+
+ onMouseDown : function(e, t){
+ if(t.className == 'x-grid3-row-expander'){
+ e.stopEvent();
+ var row = e.getTarget('.x-grid3-row');
+ this.toggleRow(row);
+ }
+ },
+
+ renderer : function(v, p, record){
+ p.cellAttr = 'rowspan="2"';
+ return '<div class="x-grid3-row-expander"> </div>';
+ },
+
+ beforeExpand : function(record, body, rowIndex){
+ if(this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false){
+ if(this.tpl && this.lazyRender){
+ body.innerHTML = this.getBodyContent(record, rowIndex);
+ }
+ return true;
+ }else{
+ return false;
+ }
+ },
+
+ toggleRow : function(row){
+ if(typeof row == 'number'){
+ row = this.grid.view.getRow(row);
+ }
+ this[Ext.fly(row).hasClass('x-grid3-row-collapsed') ? 'expandRow' : 'collapseRow'](row);
+ },
+
+ expandRow : function(row){
+ if(typeof row == 'number'){
+ row = this.grid.view.getRow(row);
+ }
+ var record = this.grid.store.getAt(row.rowIndex);
+ var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
+ if(this.beforeExpand(record, body, row.rowIndex)){
+ this.state[record.id] = true;
+ Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
+ this.fireEvent('expand', this, record, body, row.rowIndex);
+ }
+ },
+
+ collapseRow : function(row){
+ if(typeof row == 'number'){
+ row = this.grid.view.getRow(row);
+ }
+ var record = this.grid.store.getAt(row.rowIndex);
+ var body = Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body', true);
+ if(this.fireEvent('beforecollapse', this, record, body, row.rowIndex) !== false){
+ this.state[record.id] = false;
+ Ext.fly(row).replaceClass('x-grid3-row-expanded', 'x-grid3-row-collapsed');
+ this.fireEvent('collapse', this, record, body, row.rowIndex);
+ }
+ }
+});
Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Viewer.js (from rev 621, apps/opengeo/geoexplorer/trunk/lib/Viewer.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Viewer.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/Viewer.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * Constructor: Viewer
+ * Create a new Viewer application.
+ *
+ * Parameters:
+ * config - {Object} Optional application configuration properties.
+ *
+ * Extends:
+ * - Ext.util.Observable
+ */
+var Viewer = Ext.extend(Ext.util.Observable, {
+
+ /**
+ * Constructor: Viewer
+ */
+ constructor: function(config) {
+
+ var query = Ext.urlDecode(document.location.search.substr(1));
+ var queryConfig = Ext.util.JSON.decode(query.q);
+
+ this.initialConfig = Ext.apply({}, queryConfig, config);
+ Ext.apply(this, config);
+
+ // add any custom application events
+ this.addEvents(
+ /**
+ * Event: ready
+ * Fires when application is ready for user interaction.
+ */
+ "ready"
+ );
+
+ // pass on any proxy config to OpenLayers
+ if(this.proxy) {
+ OpenLayers.ProxyHost = this.proxy;
+ }
+
+ this.load();
+
+ },
+
+ /**
+ * Method: load
+ * Called to load the application. Implemented by a subclass.
+ */
+ load: Ext.emptyFn,
+
+ /**
+ * Method: dispatch
+ * Allows multiple asynchronous sequences to be called in parallel. A final
+ * callback is called when all other sequences report that they are done.
+ *
+ * Parameters:
+ * functions - {Array(Function)} List of functions to be called. All
+ * functions will be called with two arguments - a callback to call when
+ * the sequence is done and a storage object
+ * complete - {Function} A function that will be called when all other
+ * functions report that they are done. The final callback will be
+ * called with the storage object passed to all other functions.
+ * scope - {Object} Optional object to be set as the scope of all functions
+ * called.
+ */
+ dispatch: function(functions, complete, scope) {
+ complete = complete || Ext.emptyFn;
+ scope = scope || this;
+ var requests = functions.length;
+ var responses = 0;
+ var storage = {};
+ function respond() {
+ ++responses;
+ if(responses === requests) {
+ complete.call(scope, storage);
+ }
+ }
+ function trigger(index) {
+ window.setTimeout(function() {
+ functions[index].apply(scope, [respond, storage]);
+ });
+ }
+ for(var i=0; i<requests; ++i) {
+ trigger(i);
+ }
+ }
+
+});
\ No newline at end of file
Deleted: apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/lib/MapToolMenu.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -1,64 +0,0 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
-
-/**
- * About: Examples
- *
- * This example uses default names and icons for the menu entries.
- * : var measure, select, zoomBox, draw; // OpenLayers Controls
- * > var menu = new MapToolMenu({tools: [measure, select, zoomBox, draw]});
- *
- * This one provides a custom name and icon for one of the entries.
- * : var measure, select, zoomBox, draw; // OpenLayers Controls
- * > var menu = new MapToolMenu({tools: [{
- * > text: 'Find a distance',
- * > tool: measure,
- * > iconCls: 'x-icon-distance-finder'
- * > },
- * > select,
- * > zoomBox,
- * > draw
- * > ]});
- */
-
-/*
- * Constructor: MapToolMenu
- * Simply create a menu that manipulates OpenLayers map controls
- *
- * Parameters:
- * config - {Object} Various options, see {Ext.menu.Menu}
- *
- * In addition to the normal [items] array, MapToolMenu recognizes a [tools] array.
- * This can be an array of OpenLayers Control objects, or of simple configuration
- * objects analogous to Ext Map entries.
- */
-var MapToolMenu = function(options) {
- options.items = options.items || [];
-
- var disableTools = function() {
- for (var i = 0, len = options.tools.length; i < len; i++) {
- var t = options.tools[i].tool || options.tools[i];
- t.deactivate();
- }
- };
-
- for (var i = 0, len = options.tools.length; i < len; i++) {
- var conf = options.tools[i];
- var t = conf.tool || conf;
- options.items.push(Ext.applyIf(conf, {
- text: t.CLASS_NAME,
- iconCls: t.CLASS_NAME,
- handler: (function(tool){
- return function() {
- disableTools();
- tool.activate();
- };
- })(t),
- scope: this
- }));
- }
- MapToolMenu.superclass.constructor.call(this, options);
-};
-
-Ext.extend(MapToolMenu, Ext.menu.Menu);
Deleted: apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/lib/MapToolSplitToggle.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -1,153 +0,0 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- *
- * @requires MapToolMenu.js
- */
-
-/**
- * About: Examples
- *
- * This example uses default names and icons for the button and menu entries.
- * : var measure, select, zoomBox, draw; // OpenLayers Controls
- * : var menu = new MapToolSplitToggle({defaultTool: select, tools: [measure, select, zoomBox, draw]});
- *
- * This one provides a custom name and icon for one of the entries.
- * : var measure, select, zoomBox, draw; // OpenLayers Controls
- * : var menu = new MapToolSplitToggle({
- * > defaultTool: zoomBox,
- * > tools: [{
- * > text: 'Find a distance',
- * > tool: measure,
- * > iconCls: 'x-icon-distance-finder'
- * > },
- * > select,
- * > zoomBox,
- * > draw
- * > ]});
- */
-
-/**
- * Constructor: MapToolSplitToggle
- * Creates an Ext SplitButton suited to switching between multiple related OpenLayers Controls.
- * The MapToolSplitToggle accepts an array of controls, which can be activated from the dropdown menu.
- * The main button simply toggles the most recently used control.
- *
- * Parameters:
- * config - {Object} the configuration options for this split toggle, see {Ext.SplitButton}.
- *
- * In addition to the options accepted by Ext.SplitButton, the MapToolSplitToggle accepts:
- * defaultTool - {OpenLayers.Control} the control which is to be activated if the button is toggled
- * before the user selects one from the drop-down menu.
- * tools - {Array} the controls to display in the drop-down menu. These may be simple Control objects,
- * or Ext menu specifications with a tool parameter containing the control. (see MapToolMenu)
- */
-var MapToolSplitToggle = function(options) {
- this.lastActiveTool = options.defaultTool || options.tools[0];
- this.tools = options.tools;
-
- Ext.applyIf(options, {
- enableToggle: true,
- iconCls: this.findIconCls(),
- toggleHandler: this.handleEvent,
- handler: this.handleEvent,
- scope: this,
- menu: new MapToolMenu({tools: options.tools})
- });
-
- options.menu.on("itemclick", this.handleMenu, this);
-
- MapToolSplitToggle.superclass.constructor.call(this, options);
-
- if (options.toggleGroup) {
- this.on("render",
- function() {Ext.ButtonToggleMgr.register(this);},
- this
- );
- }
-
-};
-
-Ext.extend(MapToolSplitToggle, Ext.SplitButton, {
- /**
- * Property: lastActiveTool
- * The most recently selected OpenLayers Control, to be toggled when the main button is.
- */
- lastActiveTool: null,
-
- /**
- * Property: tools
- * {Array} the OpenLayers tools from this component's configuration.
- */
- tools: null,
-
- onClick: function (e) {
- e.preventDefault();
- if (!this.disabled) {
- if (e.getTarget(".x-btn-menu-arrow-wrap")) {
- if (this.menu
- && !this.menu.isVisible()
- && !this.ignoreNextClick) {
- this.showMenu();
- }
- this.fireEvent("arrowclick", this, e);
- if (this.arrowHandler) {
- this.arrowHandler.call(this.scope || this, this, e);
- }
- } else {
- if (this.enableToggle
- && (this.allowDepress !== false
- || !this.pressed)) {
- this.toggle();
- }
- this.fireEvent("click", this, e);
- if (this.handler) {
- this.handler.call(this.scope || this, this, e);
- }
- }
- }
- },
-
- /**
- * Method: handleEvent
- * Called when the main button is toggled, handled the (de)activation of the last active tool.
- *
- * Parameters:
- * item - the component that triggered the event (ie, this SplitButton)
- */
- handleEvent: function(item) {
- if (item.pressed) {
- this.lastActiveTool.activate();
- } else {
- this.lastActiveTool.deactivate();
- }
- },
-
- /**
- * Method: handleMenu
- * Called when an item in the menu is selected. All this does is update lastActiveTool;
- * the menu should be a {MapToolMenu} to handle the control (de)activation.
- *
- * Parameters:
- * item - the component that triggered the event (ie, the Menu item)
- * evt - the Ext selection event
- */
- handleMenu: function(item, evt) {
- for (var i = 0, len = this.tools.length; i < len; i++) {
- var t = this.tools[i].tool || this.tools[i];
- if (t.active) {
- this.lastActiveTool = t;
- this.toggle(true);
- }
- }
- },
-
- /**
- * Method: findIconCls
- * Determine the icon class for this split button, based on the {OpenLayers.Control} the
- * button has been configured with.
- */
- findIconCls: function() {
- return this.lastActiveTool.CLASS_NAME;
- }
-
-});
Deleted: apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/lib/MapToolToggle.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -1,83 +0,0 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
-
-/**
- * About: Examples
- *
- * This example uses default names and icons for the button.
- * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
- * : var btn = new MapToolToggle({tool: measure});
- *
- * This one provides a custom name and icon.
- * : var measure = new OpenLayers.Control.Measure(OpenLayers.Handler.Path);
- * : var btn = new MapToolToggle({
- * > text: 'Find a distance',
- * > tool: measure,
- * > iconCls: 'x-icon-distance-finder'
- * > });
- */
-
-/**
- * Constructor: MapToolToggle
- * Creates an Ext Button suited to activating and deactivating an {OpenLayers.Control}.
- * The MapToolToggle accepts a control as part of its configuration.
- *
- * Parameters:
- * config - {Object} the configuration options for this split toggle, see {Ext.Button}.
- *
- * In addition to the options accepted by Ext.Button, the MapToolToggle accepts:
- * tool - {OpenLayers.Control} the control which is to be manipulated by the button
- */
-var MapToolToggle = function(options) {
- this.mapTool = options.tool;
- Ext.applyIf(options, {
- text: this.findLabel(),
- enableToggle: true,
- iconCls: this.findIconCls(),
- handler: this.handleEvent,
- scope: this
- });
- MapToolToggle.superclass.constructor.call(this, options);
-};
-
-Ext.extend(MapToolToggle, Ext.Button, {
- /**
- * Property: mapTool
- * The OpenLayers Control that this Action toggles.
- */
- mapTool: null,
-
- /**
- * Method: handleEvent
- * Called when the main button is toggled, handled the (de)activation of the last active tool.
- *
- * Parameters:
- * item - the component that triggered the event (ie, this SplitButton)
- */
- handleEvent: function(item) {
- if (item.pressed) {
- this.mapTool.activate();
- } else {
- this.mapTool.deactivate();
- }
- },
-
- /**
- * Method: findIconCls
- * Determine the icon class for this split button, based on the {OpenLayers.Control} the
- * button has been configured with.
- */
- findIconCls: function() {
- return this.mapTool.CLASS_NAME;
- },
-
- /**
- * Method: findLabel
- * Determine the text label for this split button, based on the {OpenLayers.Control} the
- * button has been configured with.
- */
- findLabel: function() {
- return this.mapTool.CLASS_NAME;
- }
-});
Deleted: apps/opengeo/geoexplorer/trunk/lib/RowExpander.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/RowExpander.js 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/lib/RowExpander.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -1,136 +0,0 @@
-/*
- * Ext JS Library 2.2.1
- * Copyright(c) 2006-2009, Ext JS, LLC.
- * licensing at extjs.com
- *
- * http://extjs.com/license
- */
-
-Ext.grid.RowExpander = function(config){
- Ext.apply(this, config);
-
- this.addEvents({
- beforeexpand : true,
- expand: true,
- beforecollapse: true,
- collapse: true
- });
-
- Ext.grid.RowExpander.superclass.constructor.call(this);
-
- if(this.tpl){
- if(typeof this.tpl == 'string'){
- this.tpl = new Ext.Template(this.tpl);
- }
- this.tpl.compile();
- }
-
- this.state = {};
- this.bodyContent = {};
-};
-
-Ext.extend(Ext.grid.RowExpander, Ext.util.Observable, {
- header: "",
- width: 20,
- sortable: false,
- fixed:true,
- menuDisabled:true,
- dataIndex: '',
- id: 'expander',
- lazyRender : true,
- enableCaching: true,
-
- getRowClass : function(record, rowIndex, p, ds){
- p.cols = p.cols-1;
- var content = this.bodyContent[record.id];
- if(!content && !this.lazyRender){
- content = this.getBodyContent(record, rowIndex);
- }
- if(content){
- p.body = content;
- }
- return this.state[record.id] ? 'x-grid3-row-expanded' : 'x-grid3-row-collapsed';
- },
-
- init : function(grid){
- this.grid = grid;
-
- var view = grid.getView();
- view.getRowClass = this.getRowClass.createDelegate(this);
-
- view.enableRowBody = true;
-
- grid.on('render', function(){
- view.mainBody.on('mousedown', this.onMouseDown, this);
- }, this);
- },
-
- getBodyContent : function(record, index){
- if(!this.enableCaching){
- return this.tpl.apply(record.data);
- }
- var content = this.bodyContent[record.id];
- if(!content){
- content = this.tpl.apply(record.data);
- this.bodyContent[record.id] = content;
- }
- return content;
- },
-
- onMouseDown : function(e, t){
- if(t.className == 'x-grid3-row-expander'){
- e.stopEvent();
- var row = e.getTarget('.x-grid3-row');
- this.toggleRow(row);
- }
- },
-
- renderer : function(v, p, record){
- p.cellAttr = 'rowspan="2"';
- return '<div class="x-grid3-row-expander"> </div>';
- },
-
- beforeExpand : function(record, body, rowIndex){
- if(this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false){
- if(this.tpl && this.lazyRender){
- body.innerHTML = this.getBodyContent(record, rowIndex);
- }
- return true;
- }else{
- return false;
- }
- },
-
- toggleRow : function(row){
- if(typeof row == 'number'){
- row = this.grid.view.getRow(row);
- }
- this[Ext.fly(row).hasClass('x-grid3-row-collapsed') ? 'expandRow' : 'collapseRow'](row);
- },
-
- expandRow : function(row){
- if(typeof row == 'number'){
- row = this.grid.view.getRow(row);
- }
- var record = this.grid.store.getAt(row.rowIndex);
- var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
- if(this.beforeExpand(record, body, row.rowIndex)){
- this.state[record.id] = true;
- Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
- this.fireEvent('expand', this, record, body, row.rowIndex);
- }
- },
-
- collapseRow : function(row){
- if(typeof row == 'number'){
- row = this.grid.view.getRow(row);
- }
- var record = this.grid.store.getAt(row.rowIndex);
- var body = Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body', true);
- if(this.fireEvent('beforecollapse', this, record, body, row.rowIndex) !== false){
- this.state[record.id] = false;
- Ext.fly(row).replaceClass('x-grid3-row-expanded', 'x-grid3-row-collapsed');
- this.fireEvent('collapse', this, record, body, row.rowIndex);
- }
- }
-});
Deleted: apps/opengeo/geoexplorer/trunk/lib/Viewer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/Viewer.js 2009-05-21 18:27:36 UTC (rev 838)
+++ apps/opengeo/geoexplorer/trunk/lib/Viewer.js 2009-05-21 19:57:30 UTC (rev 839)
@@ -1,89 +0,0 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
-
-/**
- * Constructor: Viewer
- * Create a new Viewer application.
- *
- * Parameters:
- * config - {Object} Optional application configuration properties.
- *
- * Extends:
- * - Ext.util.Observable
- */
-var Viewer = Ext.extend(Ext.util.Observable, {
-
- /**
- * Constructor: Viewer
- */
- constructor: function(config) {
-
- var query = Ext.urlDecode(document.location.search.substr(1));
- var queryConfig = Ext.util.JSON.decode(query.q);
-
- this.initialConfig = Ext.apply({}, queryConfig, config);
- Ext.apply(this, config);
-
- // add any custom application events
- this.addEvents(
- /**
- * Event: ready
- * Fires when application is ready for user interaction.
- */
- "ready"
- );
-
- // pass on any proxy config to OpenLayers
- if(this.proxy) {
- OpenLayers.ProxyHost = this.proxy;
- }
-
- this.load();
-
- },
-
- /**
- * Method: load
- * Called to load the application. Implemented by a subclass.
- */
- load: Ext.emptyFn,
-
- /**
- * Method: dispatch
- * Allows multiple asynchronous sequences to be called in parallel. A final
- * callback is called when all other sequences report that they are done.
- *
- * Parameters:
- * functions - {Array(Function)} List of functions to be called. All
- * functions will be called with two arguments - a callback to call when
- * the sequence is done and a storage object
- * complete - {Function} A function that will be called when all other
- * functions report that they are done. The final callback will be
- * called with the storage object passed to all other functions.
- * scope - {Object} Optional object to be set as the scope of all functions
- * called.
- */
- dispatch: function(functions, complete, scope) {
- complete = complete || Ext.emptyFn;
- scope = scope || this;
- var requests = functions.length;
- var responses = 0;
- var storage = {};
- function respond() {
- ++responses;
- if(responses === requests) {
- complete.call(scope, storage);
- }
- }
- function trigger(index) {
- window.setTimeout(function() {
- functions[index].apply(scope, [respond, storage]);
- });
- }
- for(var i=0; i<requests; ++i) {
- trigger(i);
- }
- }
-
-});
\ No newline at end of file
More information about the Commits
mailing list