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 mt...@apache.org on 2007/04/26 18:43:49 UTC
svn commit: r532835 - in /incubator/xap/trunk:
codebase/src/xap/bridges/dojo/ColumnBridge.js
codebase/src/xap/bridges/dojo/RowBridge.js
codebase/src/xap/widgets/dojo/TreeTable.js
samples/WebContent/examples/widgets/table.xal
Author: mturyn
Date: Thu Apr 26 11:43:47 2007
New Revision: 532835
URL: http://svn.apache.org/viewvc?view=rev&rev=532835
Log:
Added code to allow setting horizontalAlignment of cells in columns:
1.) Defaults to "left".
2.) If an individual <cell/> has an explicit h-alignment, that trumps the column's.
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/widgets/dojo/TreeTable.js
incubator/xap/trunk/samples/WebContent/examples/widgets/table.xal
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=532835&r1=532834&r2=532835
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js Thu Apr 26 11:43:47 2007
@@ -54,13 +54,19 @@
xap.bridges.dojo.ColumnBridge.prototype.getNewAllowedAttributes = function(){
- return ['dataType'];
+ return ['dataType','horizontalAlignment'];
}
xap.bridges.dojo.ColumnBridge.prototype.setDataTypeAttribute = function( value ){
this.getPeer()._dataType = value;
}
+
+xap.bridges.dojo.ColumnBridge.prototype.setHorizontalAlignmentAttribute = function( value ){
+ this.getPeer()._horizontalAlignment = value;
+}
+
+
xap.bridges.dojo.ColumnBridge.prototype.addChild = function(childHandler, index){
this.getPeer().setHeader(childHandler.getPeer());
}
@@ -74,6 +80,7 @@
var peer = this.getPeer() ;
if( peer ){
peer._explicitColumnWidth = this.getElement().getAttribute("width") ;
+ peer._horizontalAlignment = this.getElement().getAttribute("horizontalAlignment") ;
}
}
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=532835&r1=532834&r2=532835
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/RowBridge.js Thu Apr 26 11:43:47 2007
@@ -96,8 +96,8 @@
cellInfo._text = xap.bridges.dojo.RowBridge.ts_getInnerText(childHandler.getRootDomNode());
}
}
-
- this.getPeer().addCell(childHandler.getRootDomNode(),cellInfo);
+ var idx = this.getRootDomNode().childNodes.length ;
+ this.getPeer().addCell(childHandler.getRootDomNode(),cellInfo,idx);
}
}
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=532835&r1=532834&r2=532835
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Thu Apr 26 11:43:47 2007
@@ -1161,6 +1161,7 @@
templateCssPath: null ,
widgetType: "TableColumn",
isContainer: true,
+ _horizontalAlignment: "left",
//we need this because setting the template string to
@@ -1269,22 +1270,36 @@
//thing, it should probably have something like:
//getText() function, domNode, getSortValue() function, etc,
//right now we don't have a good way of knowing what the text is
- addCell : function( cell , cellInfo){
+ addCell : function( cell , cellInfo, columnIndex){
this._cellInfo.push(cellInfo);
var td = document.createElement("td");
this.domNode.appendChild(td);
td.style.whiteSpace = "nowrap";
- td.style.overflow = "hidden";
- td.align="left";
+ td.style.overflow = "hidden";
+
+ var hAlignment ="left";
+ if ( cell.style.textAlign ) {
+ hAlignment = cell.style.textAlign;
+ //td.appendChild(document.createTextNode(hAlignment.toUpperCase().substring(0,1))) ;
+ } else {
+ var col = this._table._columns[columnIndex] ;
+ if(col){
+ hAlignment = col._horizontalAlignment ;
+ //td.appendChild(document.createTextNode(hAlignment.toUpperCase().substring(0,1))) ;
+ }
+ }
+ td.align = hAlignment ;
+
+// td.appendChild(document.createTextNode("1:"+hAlignment.substring(0,1))) ;
+
+
td.valign = "top";
// read cell attributes and apply to the td
if ( cell.style.backgroundColor ){
td.style.backgroundColor = cell.style.backgroundColor;
}
- if ( cell.style.textAlign ) {
- td.align = cell.style.textAlign;
- }
+
if (this._table && this._table._tableCellClass){
dojo.html.addClass(td,this._table._tableCellClass);
Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/table.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/table.xal?view=diff&rev=532835&r1=532834&r2=532835
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/table.xal (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/table.xal Thu Apr 26 11:43:47 2007
@@ -209,10 +209,10 @@
<freePane width="500px" height="300px" backgroundColor="#EEEEFF"
id="testComponentFreePane">
<table id="testComponent">
- <column id="column1" width="160px" onCreate="mco:attributeSetter.registerElement(this)">
+ <column horizontalAlignment="center" id="column1" width="160px" onCreate="mco:attributeSetter.registerElement(this)">
<header text="Column 1" />
</column>
- <column width="80px">
+ <column horizontalAlignment="right" width="80px">
<header text="Column 2" />
</column>
<column id="column3"
@@ -221,20 +221,20 @@
>
<header text="Column 3"/>
</column>
- <column width="20px" id="columnA" onCreate="mco:attributeSetter.registerElement(this)">
+ <column horizontalAlignment="left" width="20px" id="columnA" onCreate="mco:attributeSetter.registerElement(this)">
<header text="Column A"/>
</column>
<row id="row1" onCreate="mco:attributeSetter.registerElement(this)">
- <cell text="a"/>
+ <cell text="l:a" horizontalAlignment="left"/>
<cell text="b"/>
<cell text="c"/>
<cell text="d"/>
<row id="myBranch" onCreate="mco:attributeSetter.registerElement(this)">
- <cell text="depth 2 a"/>
+ <cell horizontalAlignment="right" text="r:depth 2 a"/>
<cell text="depth 2 b"/>
<cell text="depth 2 c"/>
<row>
- <cell text="depth 3 a"/>
+ <cell horizontalAlignment="left" text="l:depth 3 a"/>
<cell text="depth 3 b"/>
<cell text="depth 3 c"/>
</row>
@@ -247,7 +247,7 @@
</row>
<row id="row3" onCreate="mco:attributeSetter.registerElement(this)">
<cell text="aaaaaaaaaaaaaaaaaa"/>
- <cell text="bbbbbb"/>
+ <cell text="c:bbbbbb" horizontalAlignment="center" />
<cell text="ccccc"/>
</row>
</table>