[fusion-commits] r2235 - in sandbox/jxlib-3.0: layers
layers/MapGuide layers/MapServer lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Sep 27 15:34:46 EDT 2010
Author: pagameba
Date: 2010-09-27 19:34:46 +0000 (Mon, 27 Sep 2010)
New Revision: 2235
Modified:
sandbox/jxlib-3.0/layers/Layers.js
sandbox/jxlib-3.0/layers/MapGuide/MapGuide.js
sandbox/jxlib-3.0/layers/MapServer/MapServer.js
sandbox/jxlib-3.0/lib/Map.js
sandbox/jxlib-3.0/lib/jxlib.uncompressed.js
Log:
adding indicator for whether layers support querying, updating jxlib
Modified: sandbox/jxlib-3.0/layers/Layers.js
===================================================================
--- sandbox/jxlib-3.0/layers/Layers.js 2010-09-24 18:32:16 UTC (rev 2234)
+++ sandbox/jxlib-3.0/layers/Layers.js 2010-09-27 19:34:46 UTC (rev 2235)
@@ -48,6 +48,9 @@
noCache: false,
_sMapTitle: null,
_sMapname: null,
+ supports: {
+ query: false
+ },
initialize: function(map, mapTag, isMapWidgetLayer) {
// console.log('Fusion.Layers.initialize');
Modified: sandbox/jxlib-3.0/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/jxlib-3.0/layers/MapGuide/MapGuide.js 2010-09-24 18:32:16 UTC (rev 2234)
+++ sandbox/jxlib-3.0/layers/MapGuide/MapGuide.js 2010-09-27 19:34:46 UTC (rev 2235)
@@ -44,6 +44,9 @@
selectionAsOverlay: true,
useAsyncOverlay: false,
defaultFormat: 'PNG',
+ supports: {
+ query: true
+ },
initialize: function(map, mapTag, isMapWidgetLayer) {
// console.log('MapGuide.initialize');
Modified: sandbox/jxlib-3.0/layers/MapServer/MapServer.js
===================================================================
--- sandbox/jxlib-3.0/layers/MapServer/MapServer.js 2010-09-24 18:32:16 UTC (rev 2234)
+++ sandbox/jxlib-3.0/layers/MapServer/MapServer.js 2010-09-27 19:34:46 UTC (rev 2235)
@@ -47,6 +47,9 @@
//the map file
sMapFile: null,
+ supports: {
+ query: true
+ },
initialize: function(map, mapTag, isMapWidgetLayer) {
//console.log('Fusion.Layers.MapServer.initialize');
Modified: sandbox/jxlib-3.0/lib/Map.js
===================================================================
--- sandbox/jxlib-3.0/lib/Map.js 2010-09-24 18:32:16 UTC (rev 2234)
+++ sandbox/jxlib-3.0/lib/Map.js 2010-09-27 19:34:46 UTC (rev 2235)
@@ -688,7 +688,8 @@
this.oSelection = {};
this.nSelectionMaps = 0;
for (var i=0; i<this.aMaps.length; i++ ) {
- if(this.aMaps[i].layerType == "Google" || this.aMaps[i].layerType == "Yahoo" ||this.aMaps[i].layerType == "VirtualEarth" )
+ if (this.aMaps[i].supports.query)
+ // if(this.aMaps[i].layerType == "Google" || this.aMaps[i].layerType == "Yahoo" ||this.aMaps[i].layerType == "VirtualEarth" )
continue;
this.nSelectionMaps++;
this.aMaps[i].getSelection(
Modified: sandbox/jxlib-3.0/lib/jxlib.uncompressed.js
===================================================================
--- sandbox/jxlib-3.0/lib/jxlib.uncompressed.js 2010-09-24 18:32:16 UTC (rev 2234)
+++ sandbox/jxlib-3.0/lib/jxlib.uncompressed.js 2010-09-27 19:34:46 UTC (rev 2235)
@@ -31989,7 +31989,7 @@
...
*/
-// $Id: row.js 981 2010-09-13 12:18:35Z pagameba $
+// $Id: row.js 986 2010-09-15 19:01:47Z pagameba $
/**
* Class: Jx.Row
*
@@ -32125,7 +32125,8 @@
* determines and returns the height of a row
*/
getHeight : function (row) {
- var h = this.options.rowHeight;
+ var h = this.options.rowHeight,
+ rowEl;
//this should eventually compute a height, however, we would need
//a fixed width to do so reliably. For right now, we use a fixed height
//for all rows.
@@ -32135,6 +32136,10 @@
if (this.options.rowHeight == 'auto') {
// this.calculateHeight(row);
h = 20; // TODO calculate?
+ rowEl = this.grid.gridTableBody.rows[row]
+ if (rowEl) {
+ h = rowEl.getContentBoxSize().height;
+ }
} else if (Jx.type(this.options.rowHeight) !== 'number') {
h = 20; // TODO calculate?
}
@@ -32337,7 +32342,7 @@
...
*/
-// $Id: grid.js 982 2010-09-15 13:49:13Z pagameba $
+// $Id: grid.js 989 2010-09-15 20:27:48Z pagameba $
/**
* Class: Jx.Grid
*
@@ -32387,7 +32392,7 @@
Jx.Grid = new Class({
Family : 'Jx.Grid',
Extends: Jx.Widget,
- Binds: ['storeLoaded', 'clickColumnHeader', 'moveColumnHeader', 'clickRowHeader', 'moveRowHeader', 'clickCell', 'moveCell', 'leaveGrid', 'resize', 'drawStore', 'scroll', 'addRow', 'removeRow', 'removeRows', 'updateRow'],
+ Binds: ['storeLoaded', 'clickColumnHeader', 'moveColumnHeader', 'clickRowHeader', 'moveRowHeader', 'clickCell', 'dblclickCell', 'moveCell', 'leaveGrid', 'resize', 'drawStore', 'scroll', 'addRow', 'removeRow', 'removeRows', 'updateRow'],
/**
* Property: pluginNamespace
@@ -32522,15 +32527,12 @@
'gridRowLeave': false,
'gridRowClick': false,
'gridCellClick': false,
+ 'gridCellDblClick': false,
'gridCellEnter': false,
'gridCellLeave': false,
'gridMouseLeave': false
});
- if (options.parent) {
- this.addTo(options.parent);
- }
-
this.parent();
},
@@ -32578,6 +32580,10 @@
this.gridObj.addEvent('click', this.clickCell);
this.hooks.set('gridCellClick', true);
break;
+ case 'gridCellDblClick':
+ this.gridObj.addEvent('dblclick', this.dblclickCell);
+ this.hooks.set('gridCellDblClick', true);
+ break;
case 'gridMouseLeave':
this.rowObj.addEvent('mouseleave', this.leaveGrid);
this.colObj.addEvent('mouseleave', this.leaveGrid);
@@ -32606,6 +32612,10 @@
* Create the grid for the current model
*/
render: function() {
+ if (this.domObj) {
+ this.redraw();
+ return;
+ }
this.parent();
var store = this.store;
@@ -32649,6 +32659,7 @@
if (document.id(this.options.parent)) {
this.addTo(this.options.parent);
+ this.resize();
}
},
@@ -32730,7 +32741,12 @@
},
storeLoaded: function(store) {
- var template = '',
+ this.redraw();
+ },
+
+ redraw: function() {
+ var store = this.store,
+ template = '',
tr,
columns = [],
useRowHeaders = this.row.useHeaders();
@@ -32787,6 +32803,13 @@
if (this.columns.useHeaders()) {
tr = new Element('tr');
this.columns.getHeaders(tr);
+ tr.adopt(new Element('th', {
+ 'class': 'jxGridColHead',
+ 'html': ' ',
+ styles: {
+ width: 1000
+ }
+ }))
this.colObj.getElement('thead').empty().adopt(tr);
}
this.columns.calculateWidths();
@@ -32876,15 +32899,27 @@
* that is handled by the render() method
*/
drawStore: function() {
+ var useHeaders = this.row.useHeaders(),
+ blank;
this.domObj.resize();
this.gridTableBody.empty();
- if (this.row.useHeaders()) {
+ if (useHeaders) {
this.rowTableBody.empty();
}
this.store.each(function(record,index) {
this.store.index = index;
this.drawRow(record, index);
}, this);
+ if (useHeaders) {
+ blank = new Element('tr', {
+ styles: { height: 1000 }
+ });
+ blank.adopt(new Element('th', {
+ 'class':'jxGridRowHead',
+ html: ' '
+ }));
+ this.rowTableBody.adopt(blank);
+ }
},
/**
@@ -32953,9 +32988,6 @@
if (row.options.headerColumn && renderer.domInsert) {
th.adopt(rowHeaderColumn.getHTML());
}
- if (autoRowHeight) {
- th.setStyle('height', tr.childNodes[0].getContentBoxSize().height);
- }
rh = new Element('tr').adopt(th);
if (position == 'replace' && index < rowBody.childNodes.length) {
rh.inject(rowBody.childNodes[index], 'after');
@@ -32963,6 +32995,10 @@
} else {
rh.inject(rowBody, position);
}
+ if (autoRowHeight) {
+ // th.setBorderBoxSize({height: tr.childNodes[0].getBorderBoxSize().height});
+ rh.setBorderBoxSize({height: tr.getBorderBoxSize().height});
+ }
}
},
@@ -33047,6 +33083,18 @@
},
/**
+ * Method: dblclickCell
+ * handle doubleclicks on cells in the grid
+ */
+ clickCell: function(e) {
+ var target = e.target;
+ if (target.getParent('tbody')) {
+ target = target.tagName == 'TD' ? target : target.getParent('td');
+ this.fireEvent('gridCellDblClick', target);
+ }
+ },
+
+ /**
* Method: moveCell
* handle the mouse moving over cells in the grid
*/
@@ -33507,7 +33555,7 @@
...
*/
-// $Id: grid.selector.js 982 2010-09-15 13:49:13Z pagameba $
+// $Id: grid.selector.js 987 2010-09-15 19:18:57Z pagameba $
/**
* Class: Jx.Plugin.Grid.Selector
*
@@ -33530,7 +33578,7 @@
name: 'Selector',
- Binds: ['select','checkSelection','checkAll','afterGridRender','onCellClick'],
+ Binds: ['select','checkSelection','checkAll','afterGridRender','onCellClick', 'sort'],
options : {
/**
@@ -33628,7 +33676,8 @@
width: 20,
renderer: null,
name: 'selection',
- isSortable: this.options.sortableColumn || false
+ isSortable: options.sortableColumn || false,
+ sort: options.sortableColumn ? this.sort : null
}, grid);
this.checkColumn.options.renderer = this;
grid.columns.columns.reverse();
@@ -33731,7 +33780,7 @@
* opt - the option to turn off. One of 'cell', 'column', or 'row'
*/
deactivate: function (opt) {
- var gridTableRows = this.grid.gridTable.rows,
+ var gridTableRows = this.grid.gridTableBody.rows,
selected = this.selected,
i;
this.options[opt] = false;
@@ -33945,7 +33994,7 @@
* col - {Integer} the column to select
*/
selectColumn: function (col) {
- var gridTable = this.grid.gridTable,
+ var gridTable = this.grid.gridTableBody,
cols = this.selected.get('columns'),
m = '',
i;
@@ -34067,6 +34116,63 @@
}
}
}, this);
+ },
+
+ sort: function(dir) {
+ var grid = this.grid,
+ store = grid.store,
+ data = store.data,
+ gridTableBody= grid.gridTableBody,
+ gridParent = gridTableBody.getParent(),
+ useHeaders = grid.row.useHeaders(),
+ rowTableBody = grid.rowTableBody,
+ rowParent = rowTableBody.getParent(),
+ selected = this.selected.rows;
+
+ // sorting only works for rows and when more than zero are selected
+ // in fact it is probably only useful if multiple selections are also enabled
+ // but that is not a hard rule for this method
+ if (!this.options.row || selected.length == 0) {
+ console.log('not sorting by selection, nothing to sort');
+ return;
+ }
+
+ store.each(function(record, index) {
+ record.dom = {
+ cell: gridTableBody.childNodes[index],
+ row: useHeaders ? rowTableBody.childNodes[index] : null
+ };
+ });
+
+ gridTableBody.dispose();
+ if (useHeaders) {
+ rowTableBody.dispose();
+ }
+ selected.sort(function(a,b) {
+ return a.retrieve('jxRowData').row - b.retrieve('jxRowData').row;
+ }).each(function(row) {
+ console.log('moving row ' + row.retrieve('jxRowData').row + ' to beginning of array');
+ data.unshift(data.splice(row.retrieve('jxRowData').row,1)[0]);
+ });
+
+ if (dir == 'desc') {
+ data.reverse();
+ }
+
+ store.each(function(record, index) {
+ record.dom.cell.inject(gridTableBody);
+ record.dom.cell.store('jxRowData', {row: index});
+ if (useHeaders) {
+ record.dom.row.inject(rowTableBody);
+ }
+ });
+
+ if (gridParent) {
+ gridParent.adopt(gridTableBody);
+ }
+ if (useHeaders && rowParent) {
+ rowParent.adopt(rowTableBody);
+ }
}
});
/*
@@ -34500,8 +34606,8 @@
data = el.retrieve('jxCellData'),
dir = 'asc',
opt = this.options;
-
- if (sorter && $defined(data.column) && data.column.isSortable()) {
+
+ if ($defined(data.column) && data.column.isSortable()){
if (el.hasClass(opt.ascendingClass)) {
el.removeClass(opt.ascendingClass).addClass(opt.descendingClass);
dir = 'desc';
@@ -34514,34 +34620,40 @@
current.removeClass(opt.ascendingClass).removeClass(opt.descendingClass);
}
this.current = el;
- gridTableBody.dispose();
- if (useHeaders) {
- rowTableBody.dispose();
- }
- store.each(function(record, index) {
- record.dom = {
- cell: gridTableBody.childNodes[index],
- row: useHeaders ? rowTableBody.childNodes[index] : null
- };
- });
-
- // store.removeEvent('storeSortFinished', grid.drawStore);
- sorter.sort(data.column.name, null, dir);
- // store.addEvent('storeSortFinished', grid.drawStore);
-
- store.each(function(record, index) {
- record.dom.cell.inject(gridTableBody);
- if (useHeaders) {
- record.dom.row.inject(rowTableBody);
+ if ($defined(data.column.options.sort) && Jx.type(data.column.options.sort) == 'function') {
+ data.column.options.sort(dir);
+ } else {
+ if (sorter) {
+ gridTableBody.dispose();
+ if (useHeaders) {
+ rowTableBody.dispose();
+ }
+ store.each(function(record, index) {
+ record.dom = {
+ cell: gridTableBody.childNodes[index],
+ row: useHeaders ? rowTableBody.childNodes[index] : null
+ };
+ });
+
+ // store.removeEvent('storeSortFinished', grid.drawStore);
+ sorter.sort(data.column.name, null, dir);
+ // store.addEvent('storeSortFinished', grid.drawStore);
+
+ store.each(function(record, index) {
+ record.dom.cell.inject(gridTableBody);
+ if (useHeaders) {
+ record.dom.row.inject(rowTableBody);
+ }
+ });
+
+ if (gridParent) {
+ gridParent.adopt(gridTableBody);
+ }
+ if (useHeaders && rowParent) {
+ rowParent.adopt(rowTableBody);
+ }
}
- });
-
- if (gridParent) {
- gridParent.adopt(gridTableBody);
}
- if (useHeaders && rowParent) {
- rowParent.adopt(rowTableBody);
- }
}
}
});/*
More information about the fusion-commits
mailing list