incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r442101 - in /incubator/xap/trunk/src/xap: bridges/dojo/ColumnBridge.js bridges/dojo/RowBridge.js bridges/dojo/TableBridge.js taghandling/plugin.xml widgets/dojo/TreeTable.js
Date Mon, 11 Sep 2006 05:11:37 GMT
Author: jmargaris
Date: Sun Sep 10 22:11:36 2006
New Revision: 442101

URL: http://svn.apache.org/viewvc?view=rev&rev=442101
Log:
more work on table

Added:
    incubator/xap/trunk/src/xap/bridges/dojo/ColumnBridge.js   (with props)
    incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js   (with props)
Modified:
    incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js
    incubator/xap/trunk/src/xap/taghandling/plugin.xml
    incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js

Added: incubator/xap/trunk/src/xap/bridges/dojo/ColumnBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/ColumnBridge.js?view=auto&rev=442101
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/ColumnBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/ColumnBridge.js Sun Sep 10 22:11:36 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright  2006 The Apache Software Foundation.
+ *
+ *  Licensed 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.
+ *
+ */
+ 
+ /**
+ * @fileoverview
+ * 
+ * A bridge class that controls a dojo Table peer.
+ */
+
+Xap.provide("xap.bridges.dojo.ColumnBridge"); 
+
+Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+Xap.require("xap.widgets.dojo.TreeTable"); 
+
+
+ 
+ /**
+ * @fileoverview
+ * 
+ * A bridge class with dojo toolkit box panel peer.
+ */
+ 
+xap.bridges.dojo.ColumnBridge= function() {
+	xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+				"xap.bridges.dojo.ColumnBridge",
+				"xap.bridges.dojo.DojoWidgetBridge"						
+);
+
+
+
+xap.bridges.dojo.ColumnBridge.prototype.getPeerString = function(){
+    return "TableColumn" ;
+}
+
+ 
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.ColumnBridge.prototype.getNewAllowedAttributes = function(){
+	return [];
+}	
+
+xap.bridges.dojo.ColumnBridge.prototype.childAdded = function( e ) {
+	//nothing for now
+}
+
+

Propchange: incubator/xap/trunk/src/xap/bridges/dojo/ColumnBridge.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js?view=auto&rev=442101
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js Sun Sep 10 22:11:36 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright  2006 The Apache Software Foundation.
+ *
+ *  Licensed 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.
+ *
+ */
+ 
+ /**
+ * @fileoverview
+ * 
+ * A bridge class that controls a dojo Table peer.
+ */
+
+Xap.provide("xap.bridges.dojo.RowBridge"); 
+
+Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+Xap.require("xap.widgets.dojo.TreeTable"); 
+
+
+ 
+ /**
+ * @fileoverview
+ * 
+ * A bridge class with dojo toolkit box panel peer.
+ */
+ 
+xap.bridges.dojo.RowBridge= function() {
+	xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+				"xap.bridges.dojo.RowBridge",
+				"xap.bridges.dojo.DojoWidgetBridge"						
+);
+
+
+
+xap.bridges.dojo.RowBridge.prototype.getPeerString = function(){
+    return "TableRow" ;
+}
+
+ 
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.RowBridge.prototype.getNewAllowedAttributes = function(){
+	return [];
+}	
+
+xap.bridges.dojo.RowBridge.prototype.childAdded = function( e ) {
+	//nothing for now
+}
+
+
+

Propchange: incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js?view=diff&rev=442101&r1=442100&r2=442101
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js Sun Sep 10 22:11:36 2006
@@ -81,4 +81,15 @@
 	return [];
 }	
 
+xap.bridges.dojo.TableBridge.prototype.addChild = function(childHandler, index){
+	var childPeer = childHandler.getPeer();
+	alert("Add child peer:" + childPeer);
+	if (childPeer instanceof xap.widgets.dojo.TableColumn){
+		//TODO interpret index correctly
+		this.getPeer().insertColumn(childPeer,-1);
+	}
+	else if (childPeer instanceof xap.widgets.dojo.TableRow){
+		this.getPeer().insertRow(childPeer,-1);
+	}
+}
 

Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?view=diff&rev=442101&r1=442100&r2=442101
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Sun Sep 10 22:11:36 2006
@@ -24,6 +24,12 @@
 		<mapping class="xap.bridges.dojo.TextFieldBridge" name="textField"/>
 		<mapping class="xap.bridges.dojo.PasswordFieldBridge" name="passwordField"/>
 		<mapping class="xap.bridges.dojo.TextAreaBridge" name="textArea"/>
+		<mapping class="xap.bridges.dojo.TableBridge" name="table"/>
+		<mapping class="xap.bridges.dojo.RowBridge" name="row"/>
+		<mapping class="xap.bridges.dojo.ColumnBridge" name="column"/>
+		
+		<!-- for now cell just maps to label -->
+		<mapping class="xap.bridges.xap.LabelBridge" name="cell"/>
 
 	</tag-mappings>
 

Modified: incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js?view=diff&rev=442101&r1=442100&r2=442101
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js Sun Sep 10 22:11:36 2006
@@ -2,6 +2,9 @@
 dojo.widget.manager.registerWidgetPackage("xap.widgets.dojo");
 
 Xap.provide("xap.widgets.dojo.TreeTable");
+Xap.provide("xap.widgets.dojo.TableColumn");
+Xap.provide("xap.widgets.dojo.TableRow");
+Xap.provide("xap.widgets.dojo.TableCell");
 
 dojo.require("dojo.widget.*");
 dojo.require("dojo.widget.HtmlWidget");
@@ -11,6 +14,8 @@
 dojo.require("dojo.event");
 
 dojo.widget.tags.addParseTreeHandler("dojo:TreeTable");
+dojo.widget.tags.addParseTreeHandler("dojo:TableColumn");
+dojo.widget.tags.addParseTreeHandler("dojo:TableRow");
 
 xap.widgets.dojo.TreeTable = function(){
 	dojo.widget.HtmlWidget.call(this);
@@ -20,12 +25,12 @@
 dojo.inherits(xap.widgets.dojo.TreeTable,dojo.widget.HtmlWidget);
 
 dojo.lang.extend(xap.widgets.dojo.TreeTable, {
-	templateString: '<table><thead dojoAttachPoint="thead"><tr></tr></thead>'
+
+	templateString: '<table><colgroup dojoAttachPoint="colgroup"></colgroup><thead
dojoAttachPoint="thead"><tr></tr></thead>' +
 			'<tbody dojoAttachPoint="tbody"></tbody></table>',
 	
 	templateCssPath: null ,
 	widgetType: "TreeTable",
-	isContainer: true,
+	isContainer: false,
 	columns : [],
 	rows : [],
 	validatePending : false,
@@ -38,36 +43,42 @@
 	},
 	
 	_createTable: function(){
-		this.domNode.removeChild(this.thead);
-		this.domNode.removeChild(this.tbody);
 		this._rebuildHead();
 		this._rebuildBody();
 		this.validatePending = false;
 	},
 	
 	_rebuildHead: function(){
+		this.domNode.removeChild(this.colgroup);
+		this.colgroup = document.createElement("colgroup");
+		this.domNode.appendChild(this.colgroup);
+		alert("Rubuild head num columns = " + this.columns.length);
+		for (var i = 0; i<this.columns.length; i++){
+			alert("Rebuild head with column " + this.columns[i]);
+			alert("Rebuild head add node:" + this.columns[i].domNode);
+			this.colgroup.appendChild(this.columns[i].domNode);
+		}
+		
+		this.domNode.removeChild(this.thead);
 		this.thead = document.createElement("thead");
 		this.domNode.appendChild(this.thead);
 		var headerRow = document.createElement("tr");
 		this.thead.appendChild(headerRow);
 		for (var i = 0; i<this.columns.length; i++){
 			var header = document.createElement("th");
-			header.innerHTML = "Column " + i;
+			if (this.columns[i]._header){
+				header.appendChild(this.columns[i]._header);
+			}
 			headerRow.appendChild(header);
 		}
 	},
 	
 	_rebuildBody: function(){
+		this.domNode.removeChild(this.tbody);
 		this.tbody = document.createElement("tbody");
 		this.domNode.appendChild(this.tbody);
 		for (var i =0; i<this.rows.length; i++){
-			var rowElement = document.createElement("tr");
-			this.tbody.appendChild(rowElement);
-			for (var column = 0; column<this.columns.length; column++){
-				var cell = document.createElement("td");
-				cell.innerHTML = "Row:" + i + " Col:" + column;
-				rowElement.appendChild(cell);
-			}
+			this.tbody.appendChild(this.rows[i].domNode);
 		}
 	},
 	
@@ -80,8 +91,81 @@
 		else{
 			this.columns.push(column);
 		}
-		this.revalidate();
+		this._revalidate();
+	},
+	
+	insertRow: function(row, index){
+		if (index&&index>=0){
+			this.rows.splice(index,0, row);
+		}
+		else{
+			this.rows.push(row);
+		}
+		this._revalidate();
 	}	
 	
 }
-);
\ No newline at end of file
+);
+
+
+/*
+ *
+ * TABLE COLUMN
+ *
+ *
+ */
+ 
+xap.widgets.dojo.TableColumn = function(){
+	dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(xap.widgets.dojo.TableColumn,dojo.widget.HtmlWidget);
+
+dojo.lang.extend(xap.widgets.dojo.TableColumn, {
+	templateString: null,
+	templateCssPath: null ,
+	widgetType: "TableColumn",
+	isContainer: true,
+	_header : null,
+	
+	fillInTemplate: function(args, frag){
+		this.domNode = document.createElement("col");
+	}
+});
+		
+
+
+
+/*
+ *
+ * TABLE ROW
+ *
+ *
+ */
+ 
+xap.widgets.dojo.TableRow = function(){
+	dojo.widget.HtmlWidget.call(this);
+}
+
+
+dojo.inherits(xap.widgets.dojo.TableRow,dojo.widget.HtmlWidget);
+
+dojo.lang.extend(xap.widgets.dojo.TableRow, {
+	templateString: '<tr></tr>',
+	
+	templateCssPath: null ,
+	widgetType: "TableRow",
+	isContainer: false,
+	
+	addCell : function( cell ){
+		var td = document.createElement("td");
+		this.domNode.appendChild(td);
+		td.appendChild(cell);
+		cell._td = td;
+	},
+	
+	removeCell : function( cell ){
+		this.domNode.removeChild(cell._td);
+	},
+	
+});
\ No newline at end of file



Mime
View raw message