You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/06/22 01:27:41 UTC
svn commit: r549662 - in /incubator/xap/trunk/codebase/src/xap:
bridges/dojo/ColumnBridge.js bridges/dojo/RowBridge.js
bridges/dojo/TableBridge.js widgets/dojo/TreeTable.js
Author: jmargaris
Date: Thu Jun 21 18:27:41 2007
New Revision: 549662
URL: http://svn.apache.org/viewvc?view=rev&rev=549662
Log:
Roll back changes to resize table logic, including column width set logic. Fixed problem with unset table width (could make table too wide), and a timing in resizeTable which could be called with header information that was inconsistent with the column list.
Modified:
incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js
incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js?view=diff&rev=549662&r1=549661&r2=549662
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js Thu Jun 21 18:27:41 2007
@@ -54,79 +54,15 @@
xap.bridges.dojo.ColumnBridge.prototype.getNewAllowedAttributes = function(){
- return ['dataType','horizontalAlignment'];
+ return ['dataType'];
}
xap.bridges.dojo.ColumnBridge.prototype.setDataTypeAttribute = function( value ){
this.getPeer()._dataType = value;
}
-//TODO: Find out why this doesn't seem to get called.
-xap.bridges.dojo.ColumnBridge.prototype.setHorizontalAlignmentAttribute = function( value ){
- this.getPeer()._horizontalAlignment = value;
-}
-
-
xap.bridges.dojo.ColumnBridge.prototype.addChild = function(childHandler, index){
- var peer = childHandler.getPeer() ;
- peer._horizontalAlignment = childHandler.getElement().getAttribute("horizontalAlignment") ;
- peer._horizontalTextToImagePlacement = childHandler.getElement().getAttribute("horizontalTextToImagePlacement") ;
- this.getPeer().setHeader(peer);
-}
-
-/**
- * This seems the best place at which to cache the
- * XAL-derived width, if any:
-**/
-//Old way of doing it, superseded by the set[Width|HorizontalAlignment]Attribute
-// methods below; keep it around commented-out until we're sure that the newer
-// way will work, e.g. that we're not missing a peer.header when we first parse
-// this tag.
-//
-xap.bridges.dojo.ColumnBridge.prototype.init = function(){
- xap.bridges.dojo.ColumnBridge.superclass.init.call(this) ;
- var peer = this.getPeer() ;
- if( peer ){
- peer.setStatedWidth(this.getElement().getAttribute("width")) ;
- peer._horizontalAlignment = this.getElement().getAttribute("horizontalAlignment") ;
- if(peer.header && peer._horizontalAlignment){
- peer.header.setHorizontalAlignment(peer._horizontalAlignment) ;
- }
- }
+ this.getPeer().setHeader(childHandler.getPeer());
}
-/**
- * Set explicit column width and resize a table
- */
-xap.bridges.dojo.ColumnBridge.prototype.setWidthAttribute = function( value ){
- var peer = this.getPeer();
- if(peer) {
- peer.setStatedWidth(value);
- }
- // Need this here if we resize a column after the
- // table is built---use resizeTable<b>Later</b>
- // because 1.) IE probably needs the delay, and
- // 2.) the peer code keeps this from being run multiple
- // times in succession---if there's already a resizeTableTask
- // job in play, this won't add another one:
- if(peer._table) {
- peer._table._resizeTableLater();
- }
-};
-
-
-/**
- * Set column halignment---note that this is not sufficient to
- * reset the alignment all over the table, that will come later.
- */
-xap.bridges.dojo.ColumnBridge.prototype.setHorizontalAlignmentAttribute = function( value ){
- var peer = this.getPeer();
- if(peer.header && peer._horizontalAlignment){
- peer.header.setHorizontalAlignment(value) ;
- // Code in table widget will look at this
- // member to determing the alignment of
- // newly-added cells:
- peer._horizontalAlignment=value ;
- }
-}
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js?view=diff&rev=549662&r1=549661&r2=549662
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js Thu Jun 21 18:27:41 2007
@@ -96,8 +96,8 @@
cellInfo._text = xap.bridges.dojo.RowBridge.ts_getInnerText(childHandler.getRootDomNode());
}
}
- var idx = this.getRootDomNode().childNodes.length ;
- this.getPeer().addCell(childHandler.getRootDomNode(),cellInfo,idx);
+
+ this.getPeer().addCell(childHandler.getRootDomNode(),cellInfo);
}
}
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js?view=diff&rev=549662&r1=549661&r2=549662
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js Thu Jun 21 18:27:41 2007
@@ -134,10 +134,6 @@
this.getPeer().setHeight(value);
};
-xap.bridges.dojo.TableBridge.prototype.setWidthAttribute = function(value){
- this.getPeer().setWidth(value) ;
-};
-
xap.bridges.dojo.TableBridge.prototype.addChild = function(childHandler, index){
var childPeer = childHandler.getPeer();
Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js?view=diff&rev=549662&r1=549661&r2=549662
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Thu Jun 21 18:27:41 2007
@@ -32,7 +32,6 @@
Xap.require("dojo.event");
Xap.require("xap.util.ArrayHelper");
-//IMPORTANT move this to some shared area
dojo.widget.tags.addParseTreeHandler("dojo:TreeTable");
dojo.widget.tags.addParseTreeHandler("dojo:TableColumn");
dojo.widget.tags.addParseTreeHandler("dojo:TableRow");
@@ -68,7 +67,7 @@
templateString: '<div style="padding:0px 0px 0px 0px; overflow:hidden;position:relative;text-align:left">' +
'<div dojoAttachPoint="headerDiv"><table dojoAttachPoint="headerTable" style="position:relative;width:100%;table-layout:fixed;">' +
'<tbody dojoAttachPoint="headerTbody"><tr dojoAttachPoint="headerRow"></tr></tbody></table></div>'+
- '<div dojoAttachPoint="scrollDiv" style="overflow:auto;height:100%;">' +
+ '<div dojoAttachPoint="scrollDiv" style="overflow:auto;width:100%;height:100%;">' +
'<table dojoAttachPoint="table" style="height:100%;"><tbody></tbody></table></div></div>',
templateCssPath: null ,
widgetType: "TreeTable",
@@ -137,88 +136,103 @@
* After a table has been built to the screen go through and make sure
* the widths of columns and headers match up.
*/
- _resizeTable: function() {
-
+ _resizeTable: function(){
+ // In some multi-threaded scenarios, _resizeTable can fire when the peer columns/headers
+ // are out of synch with the available Xap columns, in this instance, we should call
+ // rebuild to synchronize the columns in this condition
+ if (this._columns.length > this.headerTable.childNodes.length) {
+ this._rebuildTable();
+ return;
+ }
+
//don't user tbody.childNodes[0] here because in the case
//where we need to fix up IE we want to fixup and THEN remove
//and re-add rows in the new order.
var firstRow = this._rows.length>0?this._rows[0].domNode:null;
- for (var i=0; i<this._columns.length; i++) {
+ var tableWidth = 0;
+
+ for (var i=0; i<this._columns.length;i++){
- var headerWidth = this._getSizeFromString (this._columns[i].getBestWidth());
-
+ var headerWidth = 0;
+ var columnWidth = 0;
+ var setWidth = 0;
+
//In IE get/set of column width dynamically doesn't seem to work
//too well so use first row instead
-
if (dojo.render.html.ie){
- if(headerWidth) {
- dojo.html.setMarginBox( this.headerRow.childNodes[i], {width: headerWidth} ) ;
- //this.headerRow.childNodes[i].style.width = headerWidth + 'px';
- } else {
- headerWidth = this.headerRow.childNodes[i].offsetWidth;
- }
+ var headerWidth = this.headerRow.childNodes[i].offsetWidth;
if (firstRow && firstRow.childNodes[i]){
- dojo.html.setMarginBox( firstRow.childNodes[i], {width: headerWidth} ) ;
- //firstRow.childNodes[i].style.width = headerWidth + 'px';
- }
- } else {
- if(headerWidth) {
- this.headerTable.childNodes[i].style.width = headerWidth + 'px';
- } else {
- headerWidth = this.headerTable.childNodes[i].offsetWidth;
+ columnWidth = firstRow.childNodes[i].offsetWidth;
}
- this.table.childNodes[i].style.width = headerWidth + 'px';
+ }
+ else{
+ headerWidth = this.headerTable.childNodes[i].offsetWidth;
+ columnWidth = this.table.childNodes[i].offsetWidth;
+ }
+
+ /* if the user explicitly set, we use those */
+ if ( this._columns[i]._headerWidth ) {
+ var val = this._getSizeFromString (this._columns[i]._headerWidth);
+ if ( val ) setWidth = val;
}
// we want the greater of explicity set, calculated column or calculated cell; note that we need to look up
// the explicity set ones in case the table is hidden when created
- this._columns[i]._calculatedWidth = headerWidth;
+ var finalWidth = headerWidth>columnWidth ? headerWidth:columnWidth;
+ finalWidth = setWidth>finalWidth?setWidth:finalWidth;
+ this._columns[i]._calculatedWidth = finalWidth + "px";
+ tableWidth += finalWidth;
}
- dojo.lang.setTimeout(this, this._fixColumnWidths, 0);
+ //if we don't fix the width here then when we want the table
+ //to scroll horizontally it doesn't work very well, sizes
+ //too small
+ this.table.style.width = tableWidth + "px";
+
+ //if no dom node width is set (by user or layout manager),
+ //fix it at the same width we calculated for the inner content,
+ //this fixes some problems where the 100% width on the child divs
+ //would force the table to be wide in some layouts.
+ //We may want to extend this so that when we recalculate
+ //the table size we also reset this, but that is a lot trickier
+ //as the test becomes more complicated than if width is set
+ if (!this.domNode.style.width){
+ this.domNode.style.width = tableWidth + "px";
+ }
+
+ this.headerTable.style.width = tableWidth + "px";
+
+ this.headerTable.style.tableLayout = "fixed";
+ this.table.style.tableLayout = "fixed";
+
+ this._fixColumnWidths();
window.clearTimeout(this._resizeTableTask);
this._resizeTableTask = null;
},
_fixColumnWidths : function(){
-
- var tableWidth = 0;
var firstRow = this._rows.length>0?this._rows[0].domNode:null;
-
- for (var i = 0; i < this._columns.length; i++) {
-
- var width = this._columns[i]._calculatedWidth;
- var columnWidth = 0;
- if (dojo.render.html.ie) {
+ for (var i=0; i<this._columns.length;i++){
+ var width = this._columns[i]._calculatedWidth; // Note: ends with "px"
+
+ if (dojo.render.html.ie){
+ dojo.html.setMarginBox( this.headerRow.childNodes[i],
+ {width: parseInt(width)} ) ;
+
if (firstRow && firstRow.childNodes[i]){
- columnWidth = firstRow.childNodes[i].offsetWidth;
- width = width > columnWidth ? width : columnWidth;
- dojo.html.setMarginBox( this.headerRow.childNodes[i], {width: width} ) ;
- //this.headerRow.childNodes[i].style.width = width + 'px';
+ dojo.html.setMarginBox( firstRow.childNodes[i],
+ {width: parseInt(width)} ) ;
}
- } else {
- columnWidth = this.table.childNodes[i].offsetWidth;
- width = width > columnWidth ? width : columnWidth;
- this.headerTable.childNodes[i].style.width = width + 'px';
}
-
- tableWidth += width;
-
- if (this.headerRow.childNodes[i].childNodes[0]) {
- this.headerRow.childNodes[i].childNodes[0].style.width = "100%";
+ else{
+ this.headerTable.childNodes[i].style.width = width;
+ this.table.childNodes[i].style.width = width;
}
+ if (this.headerRow.childNodes[i].childNodes[0])
+ this.headerRow.childNodes[i].childNodes[0].style.width = "100%";
}
-
- //if we don't fix the width here then when we want the table
- //to scroll horizontally it doesn't work very well, sizes
- //too small
- this.table.style.width = tableWidth + "px";
- this.headerTable.style.width = tableWidth + "px";
-
- this.headerTable.style.tableLayout = "fixed";
- this.table.style.tableLayout = "fixed";
},
/**
@@ -235,11 +249,12 @@
var ht = this.domNode.clientHeight - this.headerDiv.clientHeight;
//in IE the calculated height can be negative because
- //clientHeight can be zero
+ //clientHeight can be zero
if ( ht > 0 ) contentHt = ht + "px";
+
dojo.lang.mixin(this.scrollDiv.style,{
position:"relative",
- //width:"100%",
+ width:"100%",
height: contentHt,
overflow:"auto"});
@@ -411,13 +426,7 @@
this.onResized();
},
- setWidth:function(value){
- if (this.domNode){
- this.domNode.style.width = value;
- this._resetWidth = value ;
- }
- },
-
+
_isResized: function(w, h){
// summary
// Test if my size has changed.
@@ -660,9 +669,9 @@
// before we do anything set the widths of what will become the new first row of cells
// so IE won't freak out (fixed layout without fixed sizes in the first inserted row)
- //if (dojo.render.html.ie){
- // this._fixColumnWidths();
- //}
+ if (dojo.render.html.ie){
+ this._fixColumnWidths();
+ }
this._lastSortedColumn = column;
this._rebuildRowsLater();
@@ -732,32 +741,6 @@
if (this._table){
this._table.sortColumn(this);
}
- },
-
-
- getStatedWidth: function(){
- return this._sStatedWidth ;
- },
-
- setStatedWidth: function(val){
- var res = val ;
- // We want a string value that
- // can be used to directly set
- // a style object member:
- if(!isNaN(val)){
- res += "px" ;
- }
- this._sStatedWidth = res ;
- },
-
- getBestWidth: function(){
- // Use column width; if not set,
- // use header width:
- var res = this.getStatedWidth();
- if( !res ){
- res = this._headerWidth;
- }
- return res;
}
});