Author: konstantin.mishin
Date: 2008-01-11 13:10:58 -0500 (Fri, 11 Jan 2008)
New Revision: 5314
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/Grid.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridFooter.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridHeader.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/GridLayoutManager.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/LayoutManager.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/VLayoutManager.js
Log:
merged scrollable-data-table with 3/1/x branch
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2008-01-11
18:10:58 UTC (rev 5314)
@@ -93,12 +93,13 @@
int curentRow = getFirst();
+ int rows;
if(reqRowsCount == -1 ){
- reqRowsCount = getRows();
+ rows = getRows();
+ } else {
+ rows = reqRowsCount;
}
-
- int rows = reqRowsCount;
-
+
int rowsCount = getExtendedDataModel().getRowCount();
if(rows > 0){
Modified: trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/common/utils/Utils.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -60,15 +60,15 @@
target.parentNode.replaceChild(imported, target);;
return imported;
- } else if (ClientUILib.isGecko){
- //Mozill family
- var theDoc = document;
-
- Utils.DOM._clearAttributes(target);
- Utils.DOM.copyAttributes(target, src);
-
- target.innerHTML = src.innerHTML;//nnerHTML.join("");
- return target;
+// } else if (ClientUILib.isGecko){
+// //Mozill family
+// var theDoc = document;
+//
+// Utils.DOM._clearAttributes(target);
+// Utils.DOM.copyAttributes(target, src);
+//
+// target.innerHTML = src.innerHTML;//nnerHTML.join("");
+// return target;
} else {
//Fall back to DOM, and cross the fingers
src = document.importNode(src, true);
@@ -299,6 +299,12 @@
}
};
+Utils.trace = function(s) {
+ LOG.info(s + ": " + (new Date().getTime()- this._d) + " ");
+ //window.status = s + ": " + (new Date().getTime()- this._d) + "
" + window.status;
+ this._d = new Date().getTime();
+};
+
Array.prototype.unbreakableEach = function(f) {
for (var i = 0; i < this.length; i++) {
f(this[i], i);
Modified: trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/Grid.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/Grid.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/Grid.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -71,31 +71,19 @@
var grid = this;
Utils.execOnLoad(
function(){
+ grid.getHeader().updateSize();
+ grid.getBody().updateSize();
+ if(grid.getFooter()) {grid.getFooter().updateSize();}
grid.updateLayout();
},
Utils.Condition.ElementPresent(grid.client_id), 100);
},
updateLayout: function($super) {
- if(!this.controlCreated || this.getHeight()==0) {
- return;
- }
$super();
-
- var header = this.getHeader();
- if(header.getHeight() == 0) {
- header.updateSize();
- this.getBody().updateSize();
- if(this.getFooter()) {this.getFooter().updateSize();}
- }
-
if(this.layout) {
this.layout.updateLayout();
}
- header.updateLayout();
- header.setFakeColumnWidth();
- this.getBody().setFakeColumnWidth();
- if(this.getFooter()) {this.getFooter().setFakeColumnWidth();}
},
getHeader: function() {
return this.layout.getPane(GridLayout_Enum.HEADER);
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -51,8 +51,8 @@
window.loadingInvalidateTime = (new Date()).getTime();
},
_onContentVScroll: function(event) {
- this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.helpObject1.moveToY(this.sizeBox.element.offsetHeight+ this.defaultRowHeight +
5);
+ this.helpObject2.moveToY(this.sizeBox.element.offsetHeight+ this.defaultRowHeight +
5);
this.setScrollPos(event.memo.pos);
this.adjustDataPosition(event.memo.pos);
},
@@ -174,15 +174,14 @@
},
updateSize: function() {
- var defHeight = this._calcDefaultRowHeight();
-
- if (isFinite(defHeight)) {
- this.defaultRowHeight = defHeight;
- }
-
var row = this.templNormal.getElement().rows[0];
if(row) {
this.defaultRowHeight = row.cells[0].offsetHeight;
+ } else {
+ var defHeight = this._calcDefaultRowHeight();
+ if (isFinite(defHeight)) {
+ this.defaultRowHeight = defHeight;
+ }
}
//if(ClientUILib.isGecko) {
// this.defaultRowHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
@@ -206,7 +205,7 @@
this.scrollBox.setHeight(height);
var scrollLeft = this.grid.getScrollOffset();
- var fixH = this.grid.getFooter() ? this.grid.getFooter().getHeight() : 0;
+ var fixH = this.grid.getFooter() ? this.grid.getFooter().element.offsetHeight : 0;
if(fixH > height) fixH = 0;
var frozenContentWidth = this.grid.getColumnsFrozenWidth();
@@ -229,10 +228,10 @@
this.defaultRowHeight = this._calcDefaultRowHeight();
this.scrollBox.hide();
this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
- this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.helpObject1.moveToY(this.sizeBox.element.offsetHeight+ this.defaultRowHeight +
5);
+ this.helpObject2.moveToY(this.sizeBox.element.offsetHeight+ this.defaultRowHeight +
5);
- this.dataVisible = parseInt(this.contentBox.getHeight() / this.defaultRowHeight, 10) +
1;
+ this.dataVisible = parseInt(this.contentBox.element.offsetHeight /
this.defaultRowHeight, 10) + 1;
this.dataVisible = Math.min(this.dataVisible, this.rowsCount);
if(height > 0) {
this.adjustDataPosition(this.currentPos);
@@ -249,6 +248,7 @@
}
var scrollPos = Math.min(totalWidth - viewWidth, scrollLeft);
this.grid.adjustScrollPosition(scrollPos);
+ this.setFakeColumnWidth();
},
adjustScrollPosition: function(pos) {
this.templNormal.moveToX(-pos);
@@ -370,21 +370,20 @@
}
if(switchType === 0) {
- startRowIndx = this._getRowIndex(this.templFrozen.getElement().rows[0].id);
+ startRowIndx = this._getRowIndex(this.templNormal.getElement().rows[0].id);
startIndex = range.start;
countToLoad = range.end - range.start;
}
else {
var i, row, rownew, cloned;
countToLoad = 0;
- var frozenTbl = this.templFrozen.getElement();
var normalTbl = this.templNormal.getElement();
if(range.start > this.currRange.start
&& range.start < this.currRange.end) {
switchType = 1;
countToLoad = range.start - this.currRange.start;
if(countToLoad > 0) {
- startRowIndx = this._getRowIndex(frozenTbl.rows[0].id);
+ startRowIndx = this._getRowIndex(normalTbl.rows[0].id);
startIndex = this.currRange.end;
}
}
@@ -394,7 +393,7 @@
if(countToLoad > 0) {
startIndex = this.currRange.end;
var restCount = this.rowsCount - countToLoad;
- startRowIndx = this._getRowIndex(frozenTbl.rows[restCount].id);
+ startRowIndx = this._getRowIndex(normalTbl.rows[restCount].id);
}
}
else {
@@ -403,7 +402,7 @@
if(countToLoad > 0) {
startIndex = range.start;
var restCount = this.rowsCount - countToLoad;
- startRowIndx = this._getRowIndex(frozenTbl.rows[restCount].id);
+ startRowIndx = this._getRowIndex(normalTbl.rows[restCount].id);
}
}
}
@@ -709,7 +708,7 @@
ensureVisible: function (index) {
if(index>=0 && index<this.grid.dataModel.getCount()) {
- var visibleRows = parseInt(this.contentBox.getHeight() / this.defaultRowHeight, 10) +
1;
+ var visibleRows = parseInt(this.contentBox.element.offsetHeight /
this.defaultRowHeight, 10) + 1;
if(this.grid.dataModel.getCount() > visibleRows) {
var y = index*this.defaultRowHeight;
this.scrollBox.getElement().scrollTop = y;
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridFooter.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridFooter.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridFooter.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -102,12 +102,11 @@
this.helpObj = new ClientUI.common.box.Box(this.frozenContentBox.getElement(), null,
true);
this.defaultWidth = this.grid.getHeader().defaultWidth;
+ this.defaultHeight = this.headerRow.getElement().rows[0].cells[0].offsetHeight;
if(ClientUILib.isGecko) {
this.defaultHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
//this.defaultWidth -= this.getBorderWidth("lr") +
this.getPadding("lr");
- } else {
- this.defaultHeight = this.headerRow.getElement().rows[0].cells[0].offsetHeight;
- }
+ }
this.frozenSubstrate = new ClientUI.common.box.Box(this.grid.getElement().id +
":fs", this.getElement());
this.frozenSubstrate.getElement().name = this.getElement().id + "FRFrm";
@@ -116,11 +115,10 @@
},
updateSize: function() {
this.defaultWidth = this.grid.getHeader().defaultWidth;
+ this.defaultHeight = this.headerRow.getElement().rows[0].cells[0].offsetHeight;
if(ClientUILib.isGecko) {
this.defaultHeight -= this.getBorderWidth("tb") +
this.getPadding("tb");
//this.defaultWidth -= this.getBorderWidth("lr") +
this.getPadding("lr");
- } else {
- this.defaultHeight = this.headerRow.getElement().rows[0].cells[0].offsetHeight;
}
this.setHeight(this.defaultHeight);
this.setWidth(this.defaultWidth);
@@ -131,7 +129,7 @@
}
$super();
- var height = this.getHeight();
+ var height = this.element.offsetHeight;
var totalWidth = this.grid.getColumnsTotalWidth();
var frozenContentWidth = this.grid.getColumnsFrozenWidth();
@@ -147,6 +145,7 @@
this.container.setWidth(viewWidth);
this.setWidth(viewWidth);
this.frozenSubstrate.setWidth(frozenContentWidth);
+ this.setFakeColumnWidth();
},
adjustScrollPosition: function(pos) {
this.contentBox.moveToX(this.grid.getColumnsFrozenWidth()-pos);
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridHeader.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -56,7 +56,6 @@
if(!template) {
return false;
}
-
var childs = template.childNodes;
for(var i=0; i<childs.length; i++) {
if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
@@ -121,6 +120,7 @@
var ids = this.grid.options.ids;
var count = this.frozenCells.length;
for(i=0; i<count; i++) {
+ Utils.trace(i);
cell = this.frozenCells[i];
columns[j] = {
columnId: ids[i],
@@ -137,14 +137,18 @@
sortable: Validators.getBoolean(cell.getAttribute("sortable"), false),
sorted: Validators.getBoolean(cell.getAttribute("sorted"),
"desc")
};
+ Utils.trace(i+"a");
if(columns[j].sortable)
Event.observe(cell, 'click', eventCellMouseDown);
- h = cell.offsetHeigh;
+ Utils.trace(i+"a1");
+ h = cell.offsetHeight;
+ Utils.trace(i+"a2");
if(h > defaultHeight) defaultHeight = h;
defaultWidth += columns[j].width;
columns[j].object = new ClientUI.common.box.InlineBox(cell, null, true);
+ Utils.trace(i+"b");
var details = this._getCellElements(j);
// separator
columns[j].sep = new ClientUI.common.box.InlineBox(details[0], null, true);
@@ -161,6 +165,7 @@
//columns[j].sortDesc = new ClientUI.common.box.Box(details[1], null, true);
//columns[j].sortAsc = new ClientUI.common.box.Box(details[2], null, true);
j++;
+ Utils.trace(i+"c");
}
cols = this.headerRow.getElement().getElementsByTagName("col");
@@ -222,8 +227,8 @@
this.frozenSubstrate = new ClientUI.common.box.Box(this.gridId + ":hs",
this.getElement());
this.frozenSubstrate.getElement().name = this.getElement().id + "HRFrm";
- this.frozenSubstrate.setHeight(this.headerRow.getHeight());
-
+ this.frozenSubstrate.setHeight(this.headerRow.element.offsetHeight);
+
return true;
},
_getCellElements: function(column) {
@@ -252,33 +257,33 @@
},
updateSize: function() {
var defaultWidth = 0, defaultHeight = 0;
- var i = 0, h, j=0;
+ var i = 0, h;
var columns = this._columns;
var cols =
$A(this.headerFrozenRow.getElement().getElementsByTagName("col"));
- var cells = $A(this.headerFrozenRow.getElement().rows[0].cells);
- cells.each(function(cell) {
+ var count = this.frozenCells.length;
+ for(j=0; j<count; j++) {
+ cell = this.frozenCells[j];
if(i<columns.length) {
columns[i].width = parseInt(cols[j].width);
- h = cell.offsetHeigh;
+ h = cell.offsetHeight;
if(h > defaultHeight) defaultHeight = h;
defaultWidth += columns[i].width;
}
- i++;j++;
- });
-
- j=0;
+ i++;
+ }
cols = $A(this.headerRow.getElement().getElementsByTagName("col"));
- cells = $A(this.headerRow.getElement().rows[0].cells);
- cells.each(function(cell) {
+ count = this.cells.length;
+ for(j=0; j<count; j++) {
+ cell = this.cells[j];
if(i<columns.length) {
columns[i].width = parseInt(cols[j].width);
- h = cell.offsetHeigh;
+ h = cell.offsetHeight;
if(h > defaultHeight) defaultHeight = h;
defaultWidth += columns[i].width;
}
- i++;j++;
- });
+ i++;
+ }
this.defaultHeight = defaultHeight;
this.defaultWidth = defaultWidth;
@@ -293,7 +298,7 @@
return;
}
$super();
- var height = this.getHeight();
+ var height = this.element.offsetHeight;
var totalWidth = this.grid.getColumnsTotalWidth();
var frozenContentWidth = this.grid.getColumnsFrozenWidth();
@@ -307,6 +312,7 @@
this.headerFrozenRow.setHeight(height);
this.frozenSubstrate.setWidth(frozenContentWidth);
this.updateHeaders();
+ this.setFakeColumnWidth();
},
getColumns: function() {
return this._columns;
@@ -372,7 +378,7 @@
}
this.dragColumnInfo.originalX = pos;
this.columnSplitter.show();
- this.columnSplitter.setHeight(this.defaultHeight +
this.grid.getBody().contentBox.getHeight());
+ this.columnSplitter.setHeight(this.defaultHeight +
this.grid.getBody().contentBox.element.offsetHeight);
this.columnSplitter.moveTo(pos, 0);
},
_hideSplitter: function() {
@@ -437,7 +443,7 @@
if (icon) {
var newPosX = div.clientWidth - icon.getWidth();
- var newPosY = (div.clientHeight - icon.getHeight())/2;
+ var newPosY = (div.clientHeight - icon.offsetHeight)/2;
newPosX = Math.floor(newPosX);
newPosY = Math.floor(newPosY);
@@ -485,4 +491,4 @@
sepStyleClass: "dr-sdt-hsep",
// internal variables
_columns: []
-});
\ No newline at end of file
+});
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/GridLayoutManager.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/GridLayoutManager.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/GridLayoutManager.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -30,7 +30,7 @@
var parentBox = this.getContainer();
if(parentBox==null) parentBox = this;
- var height = parentBox.getHeight();
+ var height = parentBox.element.offsetHeight;
var width = parentBox.getViewportWidth();
// NOTE: not implemented in this class
@@ -41,7 +41,7 @@
// first get size of header
if(this.panels[GridLayout_Enum.HEADER]) {
- headerHeight = this.panels[GridLayout_Enum.HEADER].getHeight();
+ headerHeight = this.panels[GridLayout_Enum.HEADER].element.offsetHeight;
this.panels[GridLayout_Enum.HEADER].moveTo(0, 0);
this.panels[GridLayout_Enum.HEADER].setWidth(width);
this.panels[GridLayout_Enum.HEADER].updateLayout();
@@ -58,7 +58,7 @@
}
if(this.panels[GridLayout_Enum.FOOTER]) {
- footerHeight = this.panels[GridLayout_Enum.FOOTER].getHeight();
+ footerHeight = this.panels[GridLayout_Enum.FOOTER].element.offsetHeight;
this.panels[GridLayout_Enum.FOOTER].moveTo(0, bodyBottom - footerHeight);
this.panels[GridLayout_Enum.FOOTER].setWidth(width);
this.panels[GridLayout_Enum.FOOTER].updateLayout();
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/LayoutManager.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/LayoutManager.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/LayoutManager.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -37,7 +37,7 @@
updateLayout: function($super) {
if(this.container) {
var w = this.container.getWidth();
- var h = this.container.getHeight();
+ var h = this.container.element.offsetHeight;
if(ClientUILib.isGecko) {
w -= this.container.getBorderWidth("lr") +
this.container.getPadding("lr");
h -= this.container.getBorderWidth("tb") +
this.container.getPadding("tb");
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/VLayoutManager.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/VLayoutManager.js 2008-01-11
17:37:38 UTC (rev 5313)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/layouts/VLayoutManager.js 2008-01-11
18:10:58 UTC (rev 5314)
@@ -50,7 +50,7 @@
var parentBox = this.getContainer();
if(!parentBox) parentBox = this;
- var height = parentBox.getHeight();
+ var height = parentBox.element.offsetHeight;
var width = parentBox.getViewportWidth();
if(ClientUILib.isGecko) {
width -= parentBox.getBorderWidth("lr") +
parentBox.getPadding("lr");
@@ -64,13 +64,13 @@
// first get size of header
if(this.panels[GridLayout_Enum.HEADER]) {
- headerHeight = this.panels[GridLayout_Enum.HEADER].getHeight();
+ headerHeight = this.panels[GridLayout_Enum.HEADER].element.offsetHeight;
this.panels[GridLayout_Enum.HEADER].moveTo(0, 0);
this.panels[GridLayout_Enum.HEADER].setWidth(width);
this.panels[GridLayout_Enum.HEADER].updateLayout();
}
if(this.panels[GridLayout_Enum.FOOTER]) {
- footerHeight = this.panels[GridLayout_Enum.FOOTER].getHeight();
+ footerHeight = this.panels[GridLayout_Enum.FOOTER].element.offsetHeight;
this.panels[GridLayout_Enum.FOOTER].moveTo(0, height - footerHeight);
this.panels[GridLayout_Enum.FOOTER].setWidth(width);
this.panels[GridLayout_Enum.FOOTER].updateLayout();