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/03 06:31:22 UTC
svn commit: r525052 - in /incubator/xap/trunk:
codebase/src/xap/bridges/dojo/DojoWidgetBridge.js
codebase/src/xap/widgets/dojo/TreeTable.js
samples/WebContent/examples/widgets/treeTable.xal
Author: mturyn
Date: Mon Apr 2 23:31:21 2007
New Revision: 525052
URL: http://svn.apache.org/viewvc?view=rev&rev=525052
Log:
(For D. Gennaco.)
Fixes table display issues as discussed in useful depth in XAP-354, which in turn references XAP-72 and XAP-43, most significantly unexpanded rows' not taking up space.
http://issues.apache.org/jira/browse/XAP-354
http://issues.apache.org/jira/browse/XAP-72
http://issues.apache.org/jira/browse/XAP-43
Modified:
incubator/xap/trunk/codebase/src/xap/bridges/dojo/DojoWidgetBridge.js
incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
incubator/xap/trunk/samples/WebContent/examples/widgets/treeTable.xal
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/DojoWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/DojoWidgetBridge.js?view=diff&rev=525052&r1=525051&r2=525052
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/DojoWidgetBridge.js Mon Apr 2 23:31:21 2007
@@ -299,10 +299,6 @@
}
xap.bridges.basic.AbstractWidgetBridge.prototype.init.call(this);
-
- if( this.getPeer().show){
- this.getPeer().show();
- }
}
@@ -312,6 +308,16 @@
xap.bridges.dojo.DojoWidgetBridge.prototype.getNewAllowedAttributes = function(){
return [];
}
+
+/** XML attribute set method for "visible" - override of AbstractWidgetBridge */
+xap.bridges.dojo.DojoWidgetBridge.prototype.setVisibleAttribute = function(value){
+ if ((value == "true") && this.getPeer().show){
+ this.getPeer().show();
+ }
+ if ((value == "false") && this.getPeer().hide){
+ this.getPeer().hide();
+ }
+}
/** XML attribute set method for "width" */
xap.bridges.dojo.DojoWidgetBridge.prototype.setWidthAttribute = function(value){
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=525052&r1=525051&r2=525052
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Mon Apr 2 23:31:21 2007
@@ -56,6 +56,7 @@
this._alternateRowClass = "alternateRow";
this._tableCellClass = "tableCell";
this._headerVisibility = "visible";
+ this._initialResizePending = true;
}
dojo.inherits(xap.widgets.dojo.TreeTable,dojo.widget.HtmlWidget);
@@ -72,6 +73,7 @@
templateCssPath: null ,
widgetType: "TreeTable",
isContainer: false,
+ defaultCellInfo: {_text:""},
/**
*
@@ -195,19 +197,15 @@
_fixColumnWidths : function(){
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 width = this._columns[i]._calculatedWidth; // Note: ends with "px"
- // TODO: if the user wants a column to fill the remaining width they should set that column to 100%
if (dojo.render.html.ie){
- dojo.html.setMarginBox(
- this.headerRow.childNodes[i].style.width,
- {width: width}
- ) ;
+ dojo.html.setMarginBox( this.headerRow.childNodes[i],
+ {width: parseInt(width)} ) ;
+
if (firstRow && firstRow.childNodes[i]){
- dojo.html.setMarginBox(
- firstRow.childNodes[i].style.width,
- {width: width}
- ) ;
+ dojo.html.setMarginBox( firstRow.childNodes[i],
+ {width: parseInt(width)} ) ;
}
}
else{
@@ -245,6 +243,7 @@
dojo.event.connect(this.scrollDiv, "onscroll", this, "onScrollCallback");
this.table = document.createElement("table");
+ delete this.tbody;
this.scrollDiv.appendChild(this.table);
this.table.cellPadding = "0px";
this.table.cellSpacing= "0px";
@@ -341,6 +340,16 @@
* Rebuilds the entire table from scratch
*/
_rebuildTable: function(){
+ var wh = dojo.html.getMarginBox(this.domNode);
+
+ //if we have no width wait for onResized()
+ if (!wh.width){
+ window.clearTimeout(this._rebuildTableTask);
+ this._rebuildTableTask = null;
+ return;
+ }
+ this._initialResizePending = false;
+
this._rebuildHead();
this._rebuildBody();
window.clearTimeout(this._rebuildTableTask);
@@ -393,8 +402,35 @@
if (this.domNode) this.domNode.style.height = value;
this.onResized();
},
+
+
+ _isResized: function(w, h){
+ // summary
+ // Test if my size has changed.
+ // If width & height are specified then that's my new size; otherwise,
+ // query outerWidth/outerHeight of my domNode
+
+ // If I'm not being displayed then disregard (show() must
+ // check if the size has changed)
+ if(!this.isShowing()){ return false; }
+
+ // If my parent has been resized and I have style="height: 100%"
+ // or something similar then my size has changed too.
+ var wh = dojo.html.getMarginBox(this.domNode);
+ var width=w||wh.width;
+ var height=h||wh.height;
+ if(this.width == width && this.height == height){ return false; }
+
+ this.width=width;
+ this.height=height;
+ return true;
+ },
+
onResized:function(){
if ( this.scrollDiv && this.headerDiv){
+ if (this._initialResizePending && this.width) {
+ this._rebuildTableLater();
+ }
/* recalculate the content scrollDiv */
var contentHt = "100%";
var ht = this.domNode.clientHeight - this.headerDiv.clientHeight;
@@ -457,7 +493,7 @@
//recurse through all children
for (var i = 0; i<row._rows.length;i++){
- this._rowAdded(row._rows[i]);
+ this._rowAdded(row._rows[i]);
}
//TODO we should be able to insert the row into the table
@@ -572,7 +608,7 @@
//build an array of rows that will be sorted by that index
for (var i = 0; i<this._rows.length; i++){
var row = this._rows[i];
- var cellInfo = row._cellInfo[index];
+ var cellInfo = row._cellInfo[index] || this.defaultCellInfo;
var sortValue = cellInfo._sortValue || cellInfo._text;
if (dataType=='number'){
@@ -608,8 +644,8 @@
this._rows.reverse();
}
- //before we do anything set the widths of first row of cells
- //so IE won't freak out
+ // 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();
}
@@ -698,8 +734,8 @@
xap.widgets.dojo.TableRow = function(){
dojo.widget.HtmlWidget.call(this);
this._rows = [];
- //TODO start closed and fire a first expand event
- this._expanded = true;
+ //TODO fire a first expand event when first expanding a row.
+ this._expanded = false;
this._cellInfo = [];
}
@@ -843,6 +879,9 @@
},
insertRow: function(row, index){
+ // Don't show the kid if we are not expanded!
+ row.setVisible(this._expanded);
+
if (index && index>=0){
xap.util.ArrayHelper.insertElementAt(this._rows,row,index);
}
Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/treeTable.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/treeTable.xal?view=diff&rev=525052&r1=525051&r2=525052
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/treeTable.xal (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/treeTable.xal Mon Apr 2 23:31:21 2007
@@ -1,243 +1,142 @@
-<!--
- - Licensed to the Apache Software Foundation (ASF) under one
- - or more contributor license agreements. See the NOTICE file
- - distributed with this work for additional information
- - regarding copyright ownership. The ASF licenses this file
- - to you under the Apache License, Version 2.0 (the
- - "License"); you may not use this file except in compliance
- - with the License. You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing, software
- - distributed under the License is distributed on an "AS IS" BASIS,
- - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- - See the License for the specific language governing permissions and
- - limitations under the License.
- -
--->
+<xal xmlns="http://openxal.org/ui/html">
-<xal xmlns="http://openxal.org/ui" xmlns:xal="http://openxal.org/ui">
-
-
- <mco xmlns="http://openxal.org/core/mco" id="attributeSetter" class="AttributeTester"
- src="src-js/AttributeTester.js"/>
-
- <mco xmlns="http://openxal.org/core/mco" id="SmokeTests" class="SmokeTests"
- src="src-js/SmokeTests.js"/>
-
- <mco:mco xmlns:mco="http://openxal.org/core/mco" id="tableMco" class="TableMco"
- src="src-js/TableMco.js"/>
- <macro:macro id="addRow" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:append select="id('testComponent')">
- <row>
- <cell text="New Cell 1"/>
- <cell text="New Cell 2"/>
- <cell text="New Cell 3"/>
- </row>
- </xm:append>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="addMultiRow" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:append select="id('testComponent')">
- <row>
- <cell text="New Cell 1"/>
- <cell text="New Cell 2"/>
- <cell text="New Cell 3"/>
- </row>
- <row>
- <cell text="New Cell 4"/>
- <cell text="New Cell 5"/>
- <cell text="New Cell 6"/>
- </row>
- </xm:append>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="addColumn" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:insert-after select="id('column3')">
- <column>
- <header text="Column 4"/>
- </column>
- </xm:insert-after>
- <xm:append select="id('row1')">
- <cell text="New Cell"/>
- </xm:append>
- <xm:append select="id('myRow')">
- <cell text="New Cell"/>
- </xm:append>
- <xm:append select="id('row3')">
- <cell text="New Cell"/>
- </xm:append>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="intoBranch" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:append select="id('myBranch')">
- <row>
- <cell text="New Cell 1"/>
- <cell text="New Cell 2"/>
- <cell text="New Cell 3"/>
- </row>
- </xm:append>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="removeRow" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:remove-element select="id('myRow')"/>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="removeAllRows" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:remove-element select="id('testComponent')/row"/>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="removeBranch" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:remove-element select="id('myBranch')"/>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="removeAllBranches" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:remove-element select="//row/row"/>
- </xm:modifications>
- </macro:macro>
-
- <macro:macro id="branch" xmlns:macro="http://openxal.org/core/macro">
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:append select="id('testComponent')">
- <row>
- <cell text="New Cell 1"/>
- <cell text="New Cell 2"/>
- <cell text="New Cell 3"/>
- <row>
- <cell text="depth 3 a"/>
- <cell text="depth 3 b"/>
- <cell text="depth 3 c"/>
- </row>
- <row>
- <cell text="depth 3 a"/>
- <cell text="depth 3 b"/>
- <cell text="depth 3 c"/>
- <row>
- <cell text="depth 4 a"/>
- <cell text="depth 4 b"/>
- <cell text="depth 4 c"/>
- </row>
- <row>
- <cell text="depth 4 a"/>
- <cell text="depth 4 b"/>
- <cell text="depth 4 c"/>
- </row>
- <row>
- <cell text="depth 4 a"/>
- <cell text="depth 4 b"/>
- <cell text="depth 4 c"/>
- <row>
- <cell text="depth 5 a"/>
- <cell text="depth 5 b"/>
- <cell text="depth 5 c"/>
- <row>
- <cell text="depth 6 a"/>
- <cell text="depth 6 b"/>
- <cell text="depth 6 c"/>
- <row>
- <cell text="depth 7 a"/>
- <cell text="depth 7 b"/>
- <cell text="depth 7 c"/>
- <row>
- <cell text="depth 8 a"/>
- <cell text="depth 8 b"/>
- <cell text="depth 8 c"/>
- </row>
- </row>
- </row>
- </row>
- </row>
-
- </row>
- </row>
- </xm:append>
- </xm:modifications>
- </macro:macro>
-
- <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
- <xm:append select="/ui">
- <horizontalBoxPane>
- <freePane width="500px" height="300px" backgroundColor="#FFFFFF"
- id="testComponentFreePane">
- <treeTable id="testComponent">
- <column>
- <header text="Column 1"/>
- </column>
- <column>
- <header text="Column 2"/>
- </column>
- <column id="column3" onCreate="mco:attributeSetter.registerElement(this)">
- <header text="Column 3"/>
- </column>
- <row id="row1" onCreate="mco:attributeSetter.registerElement(this)">
- <cell text="a"/>
- <cell text="b"/>
- <cell text="c"/>
- <row id="myBranch" onCreate="mco:attributeSetter.registerElement(this)">
- <cell text="depth 2 a"/>
- <cell text="depth 2 b"/>
- <cell text="depth 2 c"/>
- <row>
- <cell text="depth 3 a"/>
- <cell text="depth 3 b"/>
- <cell text="depth 3 c"/>
- </row>
- </row>
- </row>
- <row id="myRow" onCreate="mco:attributeSetter.registerElement(this)">
- <cell text="x"/>
- <cell text="y"/>
- <cell text="z"/>
- </row>
- <row id="row3" onCreate="mco:attributeSetter.registerElement(this)">
- <cell text="aaaaaaaaaaaaaaaaaa"/>
- <cell text="bbbbbb"/>
- <cell text="ccccc"/>
- </row>
- </treeTable>
- </freePane>
- </horizontalBoxPane>
- <scrollPane width="1100px" height="500px"
- onCreate="mco:attributeSetter.resizeScrollPane(this, testComponentFreePane)">
- <verticalBoxPane>
- <horizontalBoxPane borderStyle="solid" borderWidth="2px" borderColor="#000">
- <verticalBoxPane width="500px">
- <label height="25px" text="Specific tests:" fontWeight="bold"/>
- <label text="None right now"/>
- </verticalBoxPane>
- <!--standard test things -->
- <include href="includes/standardButtons.xal"
- xmlns="http://openxal.org/core/xinclude"/>
- </horizontalBoxPane>
- <horizontalBoxPane>
- <verticalBoxPane>
- <include href="includes/tableSmokeTests0.xal"
- xmlns="http://openxal.org/core/xinclude"/>
- <include href="includes/attributeAutoTest.xal"
- xmlns="http://openxal.org/core/xinclude"/>
- </verticalBoxPane>
- <include href="includes/tableSmokeTests1.xal"
- xmlns="http://openxal.org/core/xinclude"/>
- </horizontalBoxPane>
- </verticalBoxPane>
- </scrollPane>
- </xm:append>
- </xm:modifications>
-
-</xal>
+ <macro:macro xmlns:macro="http://openxal.org/core/macro" name="hidetable">
+ <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
+ <xm:set-attribute select="id('hideabletable')">
+ <xm:attribute name="visible" value="false"/>
+ </xm:set-attribute>
+ </xm:modifications>
+ </macro:macro>
+ <macro:macro xmlns:macro="http://openxal.org/core/macro" name="showtable">
+ <xm:modifications xmlns:xm="http://openxal.org/core/xmodify">
+ <xm:set-attribute select="id('hideabletable')">
+ <xm:attribute name="visible" value="true"/>
+ </xm:set-attribute>
+ </xm:modifications>
+ </macro:macro>
+
+ <rootPane>
+ <freePane width="1280px" height="1800px">
+ <tabPane id="resultpane" width="800px" height="150px">
+ <tab text="overview">
+ <treeTable id="schemaoverviewtable" height="100%" width="100%">
+ <column><header text="Schema Component"></header></column>
+ <column><header text="Client Bridge Class Name Information"></header></column>
+ <column dataType="number"><header text="Schema"></header></column>
+ <column dataType="number"><header text="Bridge"></header></column>
+ <column dataType="number"><header text="Missing"></header></column>
+ <column dataType="number"><header text="Extra"></header></column>
+ <column><header text="Missing Attributes"/></column>
+ <column><header text="Extra Attributes"/></column>
+ <row expanded="false">
+ <cell text="foo"/>
+ <cell text="bar"/>
+ <row><cell/><cell/><cell text="1"/></row>
+ <row><cell/><cell/><cell text="1"/></row>
+ <row><cell/><cell/><cell text="1"/></row>
+ </row>
+ <row expanded="false">
+ <cell text="foo2"/>
+ <cell text="bar2"/>
+ <row><cell/><cell/><cell text="2"/></row>
+ </row>
+ <row expanded="false">
+ <cell text="next"/>
+ <cell text="row"/>
+ </row>
+ </treeTable>
+ </tab>
+ <tab text="Tab bearing table">
+ <table width="100%" height="100%">
+ <column><header text="column 1"/></column>
+ <column><header text="column 2"/></column>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ </row>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ </row>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ </row>
+ </table>
+ </tab>
+ <tab text="Tab bearing treetable">
+ <treeTable height="100%" width="100%">
+ <column><header text="Schema Component"></header></column>
+ <column><header text="Client Bridge Class Name Information"></header></column>
+ <column dataType="number"><header text="Schema"></header></column>
+ <column dataType="number"><header text="Bridge"></header></column>
+ <column dataType="number"><header text="Missing"></header></column>
+ <column dataType="number"><header text="Extra"></header></column>
+ <column><header text="Missing Attributes"/></column>
+ <column><header text="Extra Attributes"/></column>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ <row><cell/><cell/><cell text="1"/></row>
+ <row><cell/><cell/><cell text="1"/></row>
+ <row><cell/><cell/><cell text="1"/></row>
+ </row>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ <row><cell/><cell/><cell text="2"/></row>
+ </row>
+ <row>
+ <cell text="next"/>
+ <cell text="row"/>
+ </row>
+ </treeTable>
+ </tab>
+ </tabPane>
+ <treeTable x="0px" y="160px" width="800px" height="150px">
+ <column><header text="Schema Component"></header></column>
+ <column><header text="Client Bridge Class Name Information"></header></column>
+ <column dataType="number"><header text="Schema"></header></column>
+ <column dataType="number"><header text="Bridge"></header></column>
+ <column dataType="number"><header text="Missing"></header></column>
+ <column dataType="number"><header text="Extra"></header></column>
+ <column><header text="Missing Attributes"/></column>
+ <column><header text="Extra Attributes"/></column>
+ <row expanded="false">
+ <cell text="foo"/>
+ <cell text="bar"/>
+ <row><cell/><cell/><cell text="1"/></row>
+ <row><cell/><cell/><cell text="1"/></row>
+ <row><cell/><cell/><cell text="1"/></row>
+ </row>
+ <row expanded="false">
+ <cell text="foo"/>
+ <cell text="bar"/>
+ <row><cell/><cell/><cell text="2"/></row>
+ </row>
+ <row expanded="false">
+ <cell text="next"/>
+ <cell text="row"/>
+ </row>
+ </treeTable>
+ <table id="hideabletable" x="820px" y="160px" width="800px" height="150px" visible="false">
+ <column><header text="column 1"/></column>
+ <column><header text="column 2"/></column>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ </row>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ </row>
+ <row>
+ <cell text="foo"/>
+ <cell text="bar"/>
+ </row>
+ </table>
+ <button width="80px" height="25px" x="820px" y="320px" text="Hide table" onCommand="macro:hidetable.execute()"/>
+ <button width="80px" height="25px" x="890px" y="320px" text="Show table" onCommand="macro:showtable.execute()"/>
+ </freePane>
+ </rootPane>
+</xal>
\ No newline at end of file