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 2006/08/25 22:24:00 UTC

svn commit: r436983 - in /incubator/xap/trunk/src/xap: bridges/basic/ bridges/dojo/ requestservice/

Author: jmargaris
Date: Fri Aug 25 15:24:00 2006
New Revision: 436983

URL: http://svn.apache.org/viewvc?rev=436983&view=rev
Log:
reafctoring

Modified:
    incubator/xap/trunk/src/xap/bridges/basic/DomNodeBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
    incubator/xap/trunk/src/xap/requestservice/NetServiceListener.js
    incubator/xap/trunk/src/xap/requestservice/RequestService.js

Modified: incubator/xap/trunk/src/xap/bridges/basic/DomNodeBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/DomNodeBridge.js?rev=436983&r1=436982&r2=436983&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/DomNodeBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/basic/DomNodeBridge.js Fri Aug 25 15:24:00 2006
@@ -105,7 +105,7 @@
 /**
  *  Since this just wraps a dom node peer, this function is simple here---return the peer.
  *  ---and because we haven't overwritten AbstractBlackBoxWidgetBridge,
- *  this.getDisplayDomNode == this.getRootDomeNode....
+ *  this.getNodeForChildren == this.getRootDomeNode....
 **/
 xap.bridges.basic.DomNodeBridge.prototype.getRootDomNode = function(){
 	return this.getPeer() ;
@@ -115,7 +115,7 @@
  *  Since this just wraps a dom node peer, this 
  *  function is simple here---return the peer.
 **/
-xap.bridges.basic.DomNodeBridge.prototype.getDisplayDomNode = function(){
+xap.bridges.basic.DomNodeBridge.prototype.getNodeForChildren = function(){
 	return this.getPeer() ;
 }
  

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js?rev=436983&r1=436982&r2=436983&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js Fri Aug 25 15:24:00 2006
@@ -23,7 +23,7 @@
 
 
 Xap.provide("xap.bridges.dojo.DojoButtonBridge"); 
- // Auto-added---o.k.?
+
 Xap.require("xap.util.LogFactory");
 Xap.require("xap.bridges.dojo.DojoWidgetBridge"); 
 Xap.require("dojo.widget.html.Button") ;
@@ -68,24 +68,6 @@
     return "Button" ;
 }
 
-
-/**
- *  Sets the widget as our peer, upgrades it with new methods to adapt it to our use:
-**/
-xap.bridges.dojo.DojoButtonBridge.prototype.setPeer = function(aButton){
-	this.superclass.setPeer.call(this,aButton) ;
-	aButton.setText = function(aString){
-		xap.bridges.dojo.DojoButtonBridge.changeCaption(aButton,aString) ; 
-	}
-	aButton.getText = function(){
-		aButton.getCaption()  ; 
-	}	
-}	
-
-
-
-
-
 /**
  * The callback for the selection listener on DojoButton.
  * When this is called we fire an "onCommand" event.
@@ -95,7 +77,9 @@
 }
 
 
-
+/**
+ * Called by setTextAttribute to actually change the text of the dojo button
+ */
 xap.bridges.dojo.DojoButtonBridge.changeCaption = function(aButton,newCaption){
     var currentCaption = aButton.caption ;
     if ( newCaption == aButton.caption ){
@@ -120,48 +104,42 @@
         }
     }
 }
-
-
-
-
  
- /**
- * 
- * @return a list of allowed properties for the underlying widget's creation
- *  via dojo.wiget.createWidget(type, initial_properties[, replacement_node]) ;
- */
- xap.bridges.dojo.DojoButtonBridge.prototype.getAllowedInitialProperties = function(){
- 	// Cache this?
- 	var arra  = this.superclass.getAllowedInitialProperties() ;
- 	arra.push("text") ;
- 	
- 	return arra ;
- }
  
- /**
+/**
  * 
- * @return an object mapping allowed XAL properties to their Dojo equivalents
- */
- xap.bridges.dojo.DojoButtonBridge.prototype.getXalToToolkitMapper = function(){
- 	var map  = this.superclass.getXalToToolkitMapper() ; 
- 	map.text = "caption" ;
- 	return map ;
- }
+ * 
+ * Attribute definitions
+ * 
+ */ 
+ 
+ 
+/**
+ * This widget understands "text" in addition to basic attributes.
+**/
+xap.bridges.dojo.DojoButtonBridge.prototype.getNewAllowedAttributes = function(){
+	return ["text"];
+}	
+
+
  
 
+
 xap.bridges.dojo.DojoButtonBridge.prototype.setTextAttribute = function(value){
 	xap.bridges.dojo.DojoButtonBridge.changeCaption(this.getPeer(),value) ;
 }
 
-/**
- * Add this widget's needs to the superclass' more general list:
-**/
-xap.bridges.dojo.DojoButtonBridge.prototype.getAllowedAttributes = function(){
-	if( !this._allowedAttributes ){
-	// Memoise
-		this._allowedAttributes = this.superclass.getAllowedAttributes() ;
-		this._allowedAttributes.text = null ;
-	}
-	return this._allowedAttributes ;
-}	
+/** XML attribute set method for "width" */
+xap.bridges.dojo.DojoButtonBridge.prototype.setWidthAttribute = function(value){
+	this.getPeer().containerNode.style.width = value ;
+	dojo.lang.setTimeout(this.getPeer(), this.getPeer().sizeMyself, 0);
+}
+
+/** XML attribute set method for "height" */
+xap.bridges.dojo.DojoButtonBridge.prototype.setHeightAttribute = function(value){
+	this.getPeer().containerNode.style.height = value ;
+	dojo.lang.setTimeout(this.getPeer(), this.getPeer().sizeMyself, 0);
+}
+
+
 

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js?rev=436983&r1=436982&r2=436983&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js Fri Aug 25 15:24:00 2006
@@ -144,7 +144,7 @@
 } 
 
 
-xap.bridges.dojo.DojoFloatingPaneBridge.prototype.getDisplayDomNode = function(){  
+xap.bridges.dojo.DojoFloatingPaneBridge.prototype.getNodeForChildren = function(){  
 // This is the large pane in the middle of the widget, and so the best parent for other
 // components:
 	return this._peer.containerNode ;

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js?rev=436983&r1=436982&r2=436983&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Fri Aug 25 15:24:00 2006
@@ -70,7 +70,7 @@
  *  via dojo.wiget.createWidget(type, initial_properties[, replacement_node]) ;
  */
  xap.bridges.dojo.DojoWidgetBridge.prototype.getAllowedInitialProperties = function(){
- 	return ["id"] ; 
+ 	return ["id", "x", "y"] ; 
  }
 
 
@@ -128,8 +128,8 @@
       
     
 		// This is necessary if a Dojo widget is the parentPeer:
-		if( handler.getDisplayDomNode ){
-			if (!handler.getDisplayDomNode()){
+		if( handler.getNodeForChildren ){
+			if (!handler.getNodeForChildren()){
 				throw new xap.util.Exception(
 							"Problem inserting component managed by "
 							+ this.toString()
@@ -139,7 +139,7 @@
 												) ;
 				return ;
 			}			
-			parentPeerNode = handler.getDisplayDomNode() ;
+			parentPeerNode = handler.getNodeForChildren() ;
 		}	    
 
 		// If we've specified a node....
@@ -278,100 +278,11 @@
 		this.getPeer().show();
 	}
 }
-
-
-
-
 /**
- * These will be recognised by all peers; subclasses will
- * have to add their own attributes to match their peers:
+ * Add this widget's needs to the superclass' more general list:
 **/
-xap.bridges.dojo.DojoWidgetBridge.prototype.getAllowedAttributes = function(){
-	if( !this._allowedAttributes ){
-	// Memoise
-		this._allowedAttributes = 
-			 { x:null, y:null, width:null, height:null, 
-			 		color:null, backgroundColor:null 
-			} ;		
-	}
-	return this._allowedAttributes ;
+xap.bridges.dojo.DojoWidgetBridge.prototype.getNewAllowedAttributes = function(){
+	return [];
 }	
 
-
-// Attribute setter  methods:
-
-/**
- * Attribute setter method for 'x' designed to be triggered by
- * <code>xap.bridges.basic.AbstractBlackBoxWidgetBridge.setAttribute</code>
- * after it's been found via that class' implementation of
- * <code>getSetterFunctionForAttribute</code>.
- * @param{string} value The new x-value for the new left edge of the component.
-**/
-xap.bridges.dojo.DojoWidgetBridge.prototype.setXAttribute = function(value){
-	// Mediocre behaviour, can improve in subclasses as needed
-	this.getPeer().domNode.style.left = value ;
-}
-
-/**
- * Attribute setter method for 'y' designed to be triggered by
- * <code>xap.bridges.basic.AbstractBlackBoxWidgetBridge.setAttribute</code>
- * after it's been found via that class' implementation of
- * <code>getSetterFunctionForAttribute</code>.
- * @param{string} value The new y-value for the new top edge of the component.
-**/
-xap.bridges.dojo.DojoWidgetBridge.prototype.setYAttribute = function(value){
-	// Mediocre behaviour, can improve in subclasses as needed
-	this.getPeer().domNode.style.top = value ;
-}
-
-
-/**
- * Attribute setter method for component width, designed to be triggered by
- * <code>xap.bridges.basic.AbstractBlackBoxWidgetBridge.setAttribute</code>
- * after it's been found via that class' implementation of
- * <code>getSetterFunctionForAttribute</code>.
- * @param{string} value The new width value for the component.
-**/
-xap.bridges.dojo.DojoWidgetBridge.prototype.setWidthAttribute = function(value){
-	// Mediocre behaviour, can improve in subclasses as needed
-	this.getPeer().domNode.style.width = value ;
-}
-
-
-/**
- * Attribute setter method for component height, designed to be triggered by
- * <code>xap.bridges.basic.AbstractBlackBoxWidgetBridge.setAttribute</code>
- * after it's been found via that class' implementation of
- * <code>getSetterFunctionForAttribute</code>.
- * @param{string} value The new height value for the component.
-**/
-xap.bridges.dojo.DojoWidgetBridge.prototype.setHeightAttribute = function(value){
-	// Mediocre behaviour, can improve in subclasses as needed
-	this.getPeer().domNode.style.height = value ;
-}
-
-/**
- * Attribute setter method for the component foreground color, designed to be triggered by
- * <code>xap.bridges.basic.AbstractBlackBoxWidgetBridge.setAttribute</code>
- * after it's been found via that class' implementation of
- * <code>getSetterFunctionForAttribute</code>.
- * @param{string} value The new value for the component's foreground color.
-**/
-xap.bridges.dojo.DojoWidgetBridge.prototype.setColorAttribute = function(value){
-	// Mediocre behaviour, can improve in subclasses as needed
-	this.getPeer().domNode.style.color = value ;
-}
-
-
-/**
- * Attribute setter method for the component's background's color, designed to be triggered by
- * <code>xap.bridges.basic.AbstractBlackBoxWidgetBridge.setAttribute</code>
- * after it's been found via that class' implementation of
- * <code>getSetterFunctionForAttribute</code>.
- * @param{string} value The new value for the component background-color.
-**/
-xap.bridges.dojo.DojoWidgetBridge.prototype.setBackgroundColorAttribute = function(value){
-	// Mediocre behaviour, can improve in subclasses as needed
-	this.getPeer().domNode.style.backgroundColor = value ;
-}
 

Modified: incubator/xap/trunk/src/xap/requestservice/NetServiceListener.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/requestservice/NetServiceListener.js?rev=436983&r1=436982&r2=436983&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/requestservice/NetServiceListener.js (original)
+++ incubator/xap/trunk/src/xap/requestservice/NetServiceListener.js Fri Aug 25 15:24:00 2006
@@ -46,7 +46,7 @@
  * of the returned XML has taken place.
  * 
  * @param requestUrl The request URL
- * @param responseContent The response content (String)
+ * @param response The response object
  */
 xap.requestservice.NetServiceListener.prototype.requestCompleted = function( url, responseContent ) {}
 
@@ -54,7 +54,8 @@
  * Called when the NetService operation fails.
  * 
  * @param url The original request URL
- * @param exception The xap.requestservice.RequestServiceException detailing the failure cause.
+ * @param response The response object
+ * @param exception An exception describing the error, may be null
  */
-xap.requestservice.NetServiceListener.prototype.requestFailed = function( url, exception ) {}
+xap.requestservice.NetServiceListener.prototype.requestFailed = function( url, response, exception ) {}
 

Modified: incubator/xap/trunk/src/xap/requestservice/RequestService.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/requestservice/RequestService.js?rev=436983&r1=436982&r2=436983&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/requestservice/RequestService.js (original)
+++ incubator/xap/trunk/src/xap/requestservice/RequestService.js Fri Aug 25 15:24:00 2006
@@ -77,17 +77,24 @@
  * 
  */
 xap.requestservice.RequestService.prototype.retrieveAndProcessAsynchronously = function(url, listener) {
-  var self = this;
-  var callback = function(response) {
-    if (response.status == xap.util.HttpUtils.OK) {
-      self._processXmlString(response.responseText);
-      listener.requestCompleted(url, response.responseText);
-    } else {
-      listener.requestFailed(url, response.statusText);
-    }
-  };
-  xap.util.HttpUtils.get(url, callback);
+	var self = this;
+	var callback = function(response) {
+		if (response.status == xap.util.HttpUtils.OK) {
+			try{
+ 				self._processXmlString(response.responseText);
+				listener.requestCompleted(url, response);
+			}
+			catch(e){
+				listener.requestFailed(url, response, e);
+			}
+		} else {
+      	listener.requestFailed(url, response);
+		}
+	};
+	xap.util.HttpUtils.get(url, callback);
 }
+
+
 
 /**
  * Retrieves the content from the specified URL.