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 2006/08/04 04:29:48 UTC

svn commit: r428616 - in /incubator/xap/trunk: WebContent/examples/ WebContent/examples/dojo/ src/xap/bridges/dojo/ src/xap/taghandling/

Author: mturyn
Date: Thu Aug  3 21:29:45 2006
New Revision: 428616

URL: http://svn.apache.org/viewvc?rev=428616&view=rev
Log:
Continued shifting of methods into the superclass, with the result that the DatePicker and ColorPalette bridges are very small now.

Examples improved:  now get data from the Dojo widgets.  To do this, ColorPalette peer augmented with a working onColorSet method---default is a do-nothing stub.

Modified:
    incubator/xap/trunk/WebContent/examples/dojo/colorPicker.xal
    incubator/xap/trunk/WebContent/examples/dojo/colorPickerHandler.js
    incubator/xap/trunk/WebContent/examples/dojo/datePicker.html
    incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal
    incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js
    incubator/xap/trunk/WebContent/examples/index.html
    incubator/xap/trunk/src/xap/bridges/dojo/DojoColorPaletteBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
    incubator/xap/trunk/src/xap/taghandling/plugin.xml

Modified: incubator/xap/trunk/WebContent/examples/dojo/colorPicker.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/colorPicker.xal?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/colorPicker.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/colorPicker.xal Thu Aug  3 21:29:45 2006
@@ -14,11 +14,12 @@
 	
 		<colorPalette xmlns="http://www.dojotoolkit.org/" 		
 				elementId="targetNode"
+				id="theColorPicker"
 				height="60px"
 				width="90px"
 				x="10px"
 				y="10px"
-				onCommand="mco:handler.onPick(event)"
+				onCommand="mco:handler.onPick(event)"		
 		/>		
    	</xm:append> 	  	
 	  

Modified: incubator/xap/trunk/WebContent/examples/dojo/colorPickerHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/colorPickerHandler.js?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/colorPickerHandler.js (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/colorPickerHandler.js Thu Aug  3 21:29:45 2006
@@ -9,54 +9,15 @@
 						"<font color='#000000'>"
 						];						
 							
-colorPickerHandler.prototype.onPicked = function () {
-xap.util.Utils.interrogate(arguments) ;
-srcNode = arguments[0] ;
 
-	var attributes = srcNode.attributes;
+colorPickerHandler.prototype.onPick = function( clientEvent){							 
+	var uiDoc  = clientEvent.session.getDocumentContainer().getUiDocument();
+	var dpEl = uiDoc.getElementById("theColorPicker");
 	
-	var i0 = Math.floor(3*Math.random() );
-	var i1 = (i0+1)%3 ;
-	var i2 = (i0+2)%3 ;
+	var bridge = clientEvent.session.getUiDocumentHandler().getHandlerForElement( dpEl );	
 
-	var resultString = "<br/><br/>"+colorPickerHandler.colours[i0]
-						+"An MCO call got the attributes of the XAP button: " ;
-	if(!attributes){
-		resultString += "<br/><NONE>" ;
-	} else {
-		for (var ii = 0; ii <attributes.length; ++ii ){
-			resultString +="<br/>&nbsp;&nbsp;&nbsp;&nbsp;"
-							+ colorPickerHandler.colours[i1]
-							+attributes[ii].nodeName
-							+"</font>" ;
-			resultString +=":"+ colorPickerHandler.colours[i2]
-								+attributes[ii].nodeValue+"</font>" ;				
-		}
-	}
-	xap.showStatus() ;
-	var ticker = document.getElementById("xapStat") ;
-	ticker.innerHTML = ticker.innerHTML + resultString ;
-	
-}
-
-
-colorPickerHandler.prototype.onPick = function( event){							 
-						
-	var uiDoc  = event.session.getDocumentContainer().getUiDocument();
-	
-	var srcObj = uiDoc.getElementById(event.id) ;
-	
-	var palette =  event.source._attributeChangeListeners[0]._peer  ;
-	
-	var report = 	report = xap.util.Utils.fullDump(palette,1,true);
-	report = report.replace(/&/gm, "&amp;")
-	report = report.replace(/</gm, "&lt;")
-	report = report.replace(/>/gm, "&gt;")
-	report = report.replace(/\n/mg,"<br/>") ;
-	report = report.replace(/ /mg,"&nbsp;") ;
-
-	var ticker = document.getElementById("dump") ;
+	var palette = bridge.getPeer() ;
+	alert("Picked RGB: "+palette._color) ;
 
-	ticker.innerHTML += "<br><br/>Color: "+ report ;
 	
 }

Modified: incubator/xap/trunk/WebContent/examples/dojo/datePicker.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/datePicker.html?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/datePicker.html (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/datePicker.html Thu Aug  3 21:29:45 2006
@@ -28,8 +28,9 @@
 						"xap.session.ClientSession",
 						"xap.taghandling.AbstractTagImpl",
 						"xap.bridges.basic.AbstractBlackBoxWidgetBridge",
+						"xap.bridges.dojo.DojoWidgetBridge",
 						"xap.bridges.dojo.DojoDatePickerBridge",
-"src.dojo/src/widget.html.DatePicker"						
+						"xap.session.EventHandler"					
 							) ;
     </script>
    

Modified: incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal Thu Aug  3 21:29:45 2006
@@ -11,7 +11,8 @@
 
   <xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
     <xm:append select="/xal">
-		<datePicker xmlns="http://www.dojotoolkit.org/" 		
+		<datePicker xmlns="http://www.dojotoolkit.org/" 	
+				id="theDatePicker"	
 				elementId="targetNode"
 				height="60px"
 				width="90px"
@@ -22,7 +23,7 @@
 				onIncrementMonth="javascript:alert('Changed, event \'onIncrementMonth\' triggered the DEFAULT code that created this box.')"
 				onIncrementYear="javascript:alert('Changed, event \'onIncrementYear\' triggered the NON-DEFAULT code that created this box.')"
 				onClick="javascript:alert('Changed, event \'onClick\' triggered the DEFAULT code that created this box.')"
-				onSetDate="javascript:alert('Changed, event \'onSetDate\' triggered the DEFAULT code that created this box.')"
+				onSetDate="mco:handler.onSetDate(event)"
 		/>	
    	</xm:append> 	  	
 

Modified: incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js Thu Aug  3 21:29:45 2006
@@ -8,6 +8,18 @@
 						"<font color='#aa00aa'>",
 						"<font color='#000000'>"
 						];						
+
+
+datePickerHandler.prototype.onSetDate = function(clientEvent){
+	var uiDoc  = clientEvent.session.getDocumentContainer().getUiDocument();
+		var dpEl = uiDoc.getElementById("theDatePicker");
+		
+		var dp_0 = clientEvent.session.getUiDocumentHandler().getHandlerForElement(dpEl );	
+	
+		alert(dp_0.getPeer().date) ;
+}
+
+
 							
 datePickerHandler.prototype.onClick = function (srcNode) {
 //xap.util.Utils.interrogate(srcNode) ;

Modified: incubator/xap/trunk/WebContent/examples/index.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/index.html?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/index.html (original)
+++ incubator/xap/trunk/WebContent/examples/index.html Thu Aug  3 21:29:45 2006
@@ -23,7 +23,8 @@
       <li><a href="dojo/dojo1.html">Dojo example 1</a></li><br/>    
       
       <li><a href="basic/dom0.html">Wrapped dom example 0</a></li>
-      <li><a href="basic/datePicker.html">Wrapped DatePicker, treated as a black box.</a></li>      
+      <li><a href="dojo/datePicker.html">Wrapped DatePicker, with most code in DojoWidget superclass.</a></li>      
+      <li><a href="dojo/colorPicker.html">Wrapped ColorPalette, with most code in DojoWidget superclass.</a></li>      
 </ul>
   </body>
 </html>

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoColorPaletteBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoColorPaletteBridge.js?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoColorPaletteBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoColorPaletteBridge.js Thu Aug  3 21:29:45 2006
@@ -1,4 +1,3 @@
-
 /*
  * Copyright  2006 The Apache Software Foundation.
  *
@@ -23,14 +22,14 @@
 /**
  * @fileoverview
  * 
- * A wrapper for a Dojo DojoColorPalette, treated as a black box.
+ * A wrapper for a Dojo ColorPalette, treated as a black box.
  */
 /**
- * Creates a xap.bridges.basic.DojoColorPaletteBridge.
+ * Creates a xap.bridges.dojo.DojoColorPaletteBridge.
  * 
  * 
- * @class xap.bridges.basic.DojoColorPaletteBridge is the bridge between an XML element
- * representing a control and a subclass of DojoColorPalette. This class 
+ * @class xap.bridges.dojo.DojoColorPaletteBridge is the bridge between an XML element
+ * representing a control and a subclass of ColorPalette. This class 
  * is typically not used directly but is extended by other classes 
  * for its subclasses.
  * 
@@ -51,24 +50,30 @@
 xap.bridges.dojo.DojoColorPaletteBridge.prototype._peer = null ;
 
 
-
-
+xap.bridges.dojo.DojoColorPaletteBridge.prototype.getPeerString = function(){
+	return "ColorPalette" ;
+}
 
 
 xap.bridges.dojo.DojoColorPaletteBridge.prototype.attributeSet = function(){
 	//TO_DO anything useful here?  format-string?
 };
 
-xap.bridges.dojo.DojoColorPaletteBridge.prototype.getPeerString = function(){
-	return "ColorPalette" ;
-}
-
 
 xap.bridges.dojo.DojoColorPaletteBridge.prototype.getPeerOnCommandEvent = function(){
 	return "onColorSelect" ;
 }
 
 
-xap.bridges.dojo.DojoColorPaletteBridge.prototype.getRootDomNode= function(){
-	return this._peer.domNode ;
+// The peer is a bit deficient:
+xap.bridges.dojo.DojoColorPaletteBridge.prototype.setPeer = function(aWidget){
+	this.superclass.setPeer.call(this,aWidget) ;
+	aWidget.onColorSelect = function(aColor){
+		aWidget._color =  aColor ;
+	}
 }
+
+
+
+
+

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js Thu Aug  3 21:29:45 2006
@@ -62,8 +62,10 @@
 
 
 xap.bridges.dojo.DojoDatePickerBridge.prototype.getPeerOnCommandEvent = function(){
-	return "onSelectDate" ;
+	return "onSetDate" ;
 }
+
+
 
 
 // Just testing that the superclass event-mapper doesn't destroy any explicitly-defined 

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=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Thu Aug  3 21:29:45 2006
@@ -15,7 +15,7 @@
  *
  */
  
- Xap.require("xap.bridges.basic.AbstractBlackBoxWidgetBridge"); 
+Xap.require("xap.bridges.basic.AbstractBlackBoxWidgetBridge"); 
 Xap.provide("xap.bridges.dojo.DojoWidgetBridge"); 
  
  /**

Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?rev=428616&r1=428615&r2=428616&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Thu Aug  3 21:29:45 2006
@@ -30,6 +30,7 @@
 		
 		<mapping class="xap.bridges.basic.DomNodeBridge" name="dom"/>
 		<mapping class="xap.bridges.dojo.DojoDatePickerBridge" name="datePicker"/>
+		<mapping class="xap.bridges.dojo.DojoColorPaletteBridge" name="colorPalette"/>		
 										
 	</tag-mappings>