incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r449911 - in /incubator/xap/trunk: WebContent/examples/widgets/table.xal src/xap/bridges/dojo/RowBridge.js src/xap/bridges/dojo/TableBridge.js src/xap/widgets/dojo/TreeTable.js
Date Tue, 26 Sep 2006 05:38:16 GMT
Author: jmargaris
Date: Mon Sep 25 22:38:14 2006
New Revision: 449911

URL: http://svn.apache.org/viewvc?view=rev&rev=449911
Log:
expand/collpase event notificatio and attributes,
still need to test with sample

Modified:
    incubator/xap/trunk/WebContent/examples/widgets/table.xal
    incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js
    incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js

Modified: incubator/xap/trunk/WebContent/examples/widgets/table.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/table.xal?view=diff&rev=449911&r1=449910&r2=449911
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/table.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/table.xal Mon Sep 25 22:38:14 2006
@@ -25,6 +25,8 @@
 	<table id="testComponent" width="200px" height="100px" 
 		onSelect="mco:attributeSetter.reportEvent(event)"
 		onStateChange="mco:attributeSetter.reportEvent(event)"
+		onExpand="mco:attributeSetter.reportEvent(event)"
+		onCollapse="mco:attributeSetter.reportEvent(event)"
 	>
 		<column><header text="Column 1"/></column>
 		<column><header text="Column 2"/></column>

Modified: 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=diff&rev=449911&r1=449910&r2=449911
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/RowBridge.js Mon Sep 25 22:38:14 2006
@@ -52,10 +52,18 @@
 
  
 /**
- * No new dynamic attributes
+ * dynamic attributes
  */
 xap.bridges.dojo.RowBridge.prototype.getNewAllowedAttributes = function(){
-	return [];
+	return ["selected", "expanded"];
+}	
+
+xap.bridges.dojo.RowBridge.prototype.setSelectedAttribute = function( value ){
+	this.getPeer().setSelected(value=="true");
+}	
+
+xap.bridges.dojo.RowBridge.prototype.setExpandedAttribute = function( value ){
+	this.getPeer().setExpanded(value=="true");
 }	
 
 xap.bridges.dojo.RowBridge.prototype.addChild = function(childHandler, index){

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=449911&r1=449910&r2=449911
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TableBridge.js Mon Sep 25 22:38:14 2006
@@ -51,7 +51,8 @@
 	//add listener last so we don't fire for the initial set
 	dojo.event.connect(this.getPeer(), "onActivateRow",this,"onActivateRow");	
 	dojo.event.connect(this.getPeer(), "onSelectRow",this,"onSelectRow");	
-	dojo.event.connect(this.getPeer(), "onDeselectRow",this,"onDeselectRow");	
+	dojo.event.connect(this.getPeer(), "onDeselectRow",this,"onDeselectRow");
+	dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow");	
 }
 
 xap.bridges.dojo.TableBridge.prototype.getPeerString = function(){
@@ -63,6 +64,16 @@
 	clientEvent.rowId = this.getSelectedRowIds();
    this.fireEvent("onSelect", null, null, clientEvent);
 }
+
+xap.bridges.dojo.TableBridge.prototype.onExpandRow = function( row, expanded ){
+	var handler = this.getUiContentHandler().getHandlerForPeer(row);
+	handler.writeBackAttribute("expanded",""+expanded);
+	var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
+	clientEvent.rowId = handler.getElement().getAttribute("id");
+   this.fireEvent(expanded?"onExpand":"onCollapse", null, null, clientEvent);
+
+}
+
 
 xap.bridges.dojo.TableBridge.prototype.onDeselectRow = function( row ){
 	var handler = this.getUiContentHandler().getHandlerForPeer(row);

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=449911&r1=449910&r2=449911
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js Mon Sep 25 22:38:14 2006
@@ -198,7 +198,7 @@
 			height:"100%",
 			overflow:"auto"});
 
-		dojo.event.connect(this.scrollDiv, "onscroll", this, "onscroll");
+		dojo.event.connect(this.scrollDiv, "onscroll", this, "onScrollCallback");
 		
 		this.table = document.createElement("table");
 		this.scrollDiv.appendChild(this.table);
@@ -348,6 +348,12 @@
 	_rowAdded: function(row){
 		row.setTable(this);
 		
+		//if the row starts as selected when it is added,
+		//make sure to catch that.
+		if (row._selected){
+			this.selectRow(row);
+		}
+		
 		//recurse through all children
 		for (var i = 0; i<row._rows.length;i++){
 			this._rowAdded(row._rows[i]);
@@ -378,14 +384,20 @@
 	 
 	 selectRow: function(row){
 	 	if (this.isSelected(row)){
-	 		return;
+	 		return false;
 	 	}
 	 	if (this._selectionMode=="singleRow"){
 	 		this.clearSelection();
 	 	}
 	 	dojo.html.addClass(row.domNode,"selectedRow");
 	 	this._selectedItems.push(row);
-	 	this.onSelectRow(row);
+	 	return true;
+	 },
+	 
+	 selectRowByUser: function(row){
+	 	if (this.selectRow(row)){
+	 		this.onSelectRow(row);
+	 	}
 	 },
 	 
 	 onSelectRow : function(row){
@@ -424,8 +436,11 @@
 	 * 
 	 */	
 	 
+	 onExpandRow : function(row, expanded){
+	 	//event hook
+	 },
 	 
-	onscroll : function(event){
+	onScrollCallback : function(event){
 		if (this.scrollDiv){
 			this.headerDiv.style.left = -this.scrollDiv.scrollLeft + "px";
 		}
@@ -478,7 +493,7 @@
 	
 	setHeader: function( domNode ){
 		this._header = domNode;
-		dojo.event.connect(domNode, "onclick", this, "onSort");
+		dojo.event.connect(domNode, "onclick", this, "onClickCallback");
 		dojo.html.addClass(domNode,"header");
 	},
 	
@@ -486,7 +501,7 @@
 		this._table = table;
 	},
 	
-	onSort : function(){
+	onClickCallback : function(){
 		if (this._table){
 			this._table.sortColumn();
 		}
@@ -506,6 +521,7 @@
 xap.widgets.dojo.TableRow = function(){
 	dojo.widget.HtmlWidget.call(this);
 	this._rows = [];
+	//TODO start closed and fire a first expand event
 	this._expanded = true;
 }
 
@@ -521,15 +537,15 @@
 	
 	setTable: function(table){
 		this._table = table;
-		dojo.event.connect(this.domNode, "onclick", this, "onClick");
-		dojo.event.connect(this.domNode, "ondblclick", this, "onDblClick");
+		dojo.event.connect(this.domNode, "onclick", this, "onClickCallback");
+		dojo.event.connect(this.domNode, "ondblclick", this, "onDblClickCallback");
 	},
 	
-	onClick : function(){
-		this._table.selectRow(this);
+	onClickCallback : function(){
+		this._table.selectRowByUser(this);
 	},
 	
-	onDblClick : function(){
+	onDblClickCallback : function(){
 		this._table.activateRow(this);
 	},
 	
@@ -550,7 +566,7 @@
 			this._indentSpan = document.createElement("span");
 			td.appendChild(this._indentSpan);
 			this._indentSpan.innerHTML = "&nbsp;";
-			dojo.event.connect(this._indentSpan, "onclick", this, "onExpand");
+			dojo.event.connect(this._indentSpan, "onclick", this, "onExpandCallback");
 			this._adjustImage();
 		}
 		td.appendChild(cell);
@@ -590,12 +606,26 @@
 		}
 	},
 	
-	onExpand : function( ){
-		this._expanded = !this._expanded;
+	onExpandCallback : function( ){
+		this.setExpanded(!this._expanded);
+		if (this._table){
+			this._table.onExpandRow(this,this._expanded);
+		}
+	},
+	
+	setExpanded : function (expanded){
+		this._expanded = expanded;
 		for (var i = 0; i<this._rows.length; i++){
 			this._rows[i].setVisible(this._expanded);
 		}
 		this._adjustImage();
+	},
+	
+	setSelected : function (selected){
+		this._selected = selected;
+		if (this._table && selected){
+			this._table.selectRow(this);
+		}
 	},
 	
 	//if we set to invis, set all children to invis as well



Mime
View raw message