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/07/05 20:36:47 UTC
svn commit: r419336 - in /incubator/xap/trunk/src/xap/bridges/dojo:
DojoButtonBridge.js DojoFloatingPaneBridge.js DojoWidgetBridge.js
Author: mturyn
Date: Wed Jul 5 13:36:46 2006
New Revision: 419336
URL: http://svn.apache.org/viewvc?rev=419336&view=rev
Log:
Added machinery to go along with Dojo's preferred technique of setting values for widgets on creation; they are as a result deficient in setters, and so it seemed at least worth a try to do this, though we'll have to get setters written at some point. (This was suggested by getting a FloatingPane::setTitle written which worked well in Mozilla but was rubbish in IE; creating the widget with the right title worked fine under both browsers---being able to reset the title later is of secondary concern, and shouldn't block us at this point.)
Modified:
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
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=419336&r1=419335&r2=419336&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoButtonBridge.js Wed Jul 5 13:36:46 2006
@@ -138,3 +138,28 @@
}
}
}
+
+
+
+
+/**
+ *
+ * @return a list of allowed properties for the underlying widget's creation
+ * via dojo.wiget.createWidget(type, initial_properties[, replacement_node]) ;
+ */
+ DojoButtonBridge.prototype.getAllowedInitialProperties = function(){
+ return ["text"] ;
+ }
+
+ /**
+ *
+ * @return an object mapping allowed XAL properties to their Dojo equivalents
+ */
+ DojoButtonBridge.prototype.getXalToToolkitMapper = function(){
+ return {text:"caption"} ;
+ }
+
+
+
+
+
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=419336&r1=419335&r2=419336&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoFloatingPaneBridge.js Wed Jul 5 13:36:46 2006
@@ -62,6 +62,21 @@
return "FloatingPane" ;
}
+/**
+ * Is this allowed as an initial property?
+**/
+DojoFloatingPaneBridge.prototype.getAllowedInitialProperties = function(){
+ return ["title","resizable", "layoutAlign"] ;
+}
+
+ /**
+ *
+ * @return an object mapping allowed XAL properties to their Dojo equivalents
+ */
+ DojoFloatingPaneBridge.prototype.getXalToToolkitMapper = function(){
+ return {} ;
+ }
+
@@ -95,10 +110,22 @@
}
else if (name=="title"){
peer.title = value ;
+ // Mozilla:
+ if (peer.titleBar.textContent){
+ peer.titleBar.textContent = value ;
+ peer.titleBar.title = value ;
+ } // IE
+ else if (peer.titleBar.innerText){
+
+ }
+
} else {
DojoWidgetBridge.prototype.attributeSet.call( this, event );
}
peer.onResized() ;
}
+
+
+
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=419336&r1=419335&r2=419336&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Wed Jul 5 13:36:46 2006
@@ -39,11 +39,6 @@
*/
DojoWidgetBridge = function() {
AbstractTagImpl.call( this );
- // handle a object that we might pass in directly
- // to the dojo object peer:
- if( arguments.length > 0 && (typeof arguments[0] == "object") ) {
- this._passedInDojoProperties = arguments[0] ;
- }
}
DojoWidgetBridge.prototype = new AbstractTagImpl;
@@ -72,6 +67,36 @@
AbstractTagImpl.prototype.init.call( this );
this.getPeer().show();
}
+
+/**
+ *
+ * @return an object mapping allowed XAL properties to their Dojo equivalents
+ */
+ DojoWidgetBridge.prototype.getXalToToolkitMapper = function(){
+ return {} ;
+ }
+
+ /**
+ *
+ * @return a list of allowed properties for the underlying widget's creation
+ * via dojo.wiget.createWidget(type, initial_properties[, replacement_node]) ;
+ */
+ DojoWidgetBridge.prototype.getAllowedInitialProperties = function(){
+ return ["widgetId"] ;
+ }
+
+
+
+
+
+/**
+ *
+ * Is the property in the list of allowed ones?
+ */
+DojoWidgetBridge.prototype.allowsInitialProperty = function(prop){
+ return Utils.doesArrayContain(this.getAllowedInitialProperties(),prop) ;
+}
+
/**
*
* Since the <code>dojo.widget.createWidget()</code>
@@ -84,6 +109,8 @@
var handler = this.getUiContentHandler().getHandlerForElement( parent );
var parentPeer = handler.getPeer();
+
+
// This is necessary if a Dojo widget is the parentPeer:
// This is probably a kludge, but I don't want to
// muck around with handler.getPeer() at the moment:
@@ -110,15 +137,17 @@
// getPropertyMap that can be widget-specific:
var propertyMap = {widgetId:this.getElement().getAttribute("id"),
position:"absolute", title:"TO DO: working 'setTitle()' method"
- } ;
- // Allow us to put in any properties that might be in some dojo
- // original:
- if(this._passedInDojoProperties){
- for(var prop in this._passedInDojoProperties){
- propertyMap[prop] = this._passedInDojoProperties[prop] ;
- }
- }
- // Forbid changing the dojoType if we've got one:
+ } ;
+
+
+
+ // Allow us to create the object with attributes in place:
+ // TO DO: An Atributes object with toArray() and toObject() methods:
+ var arrAttr = this.getElement().attributes ;
+ this.mapAllowedInitialPropertiesFromXalToDojo(propertyMap, arrAttr) ;
+
+ //alert(propertyMap.title) ;
+ // Forbid changing the dojoType if we're in a subclass and "already got one":
var dojoType = null ;
if ( this.getPeerString ){
dojoType = this.getPeerString() ;
@@ -132,6 +161,8 @@
throw new Exception("No dojo type specified by class or passed-in map.") ;
}
+ // The candy in the middle of the wrapper:
+ //Utils.interrogate(propertyMap) ;
var peer = dojo.widget.createWidget(dojoType,propertyMap,tmp);
this.setPeer( peer );
@@ -265,3 +296,42 @@
}
}
+
+/**
+ * Create a valid widget creation object for the peer based on the XAL
+ * properties (names may be different); maybe there's a way of
+ * combining this with setAttributes, or rather letting setAttributes
+ * use this:
+ * @param propertyMap A JS object holding name/value pairs
+ * @param arrAttributes---an array of attribute nodes produced by the parser/handler
+**/
+DojoWidgetBridge.prototype.mapAllowedInitialPropertiesFromXalToDojo = function(propertyMap,arrAttributes){
+ //Doesn't do much here, but in subclasses:
+ var mapper = this.getXalToToolkitMapper() ;
+ if(arrAttributes){
+ for(var ii =0; ii<arrAttributes.length; ++ii){
+ var xalName = arrAttributes[ii].nodeName ;
+ // This might get remapped:
+ var name = xalName ;
+ if (mapper[xalName]){
+ name = mapper[xalName] ;
+ }
+ // What about the value? If necessary we could introduce
+ // an object holding a map-to name and a callback used
+ // to get the right value....
+ var xalValue = arrAttributes[ii].nodeValue ;
+ //...but we'll just do a little bit here:
+ var value = xalValue ;
+ if (xalValue == "true"){
+ value = true ;
+ } else if (xalValue == "false"){
+ value = false ;
+ }
+ //Doesn't do much here, but for subclasses:
+ if( this.allowsInitialProperty(name)){
+ propertyMap[name] = value ;
+ }
+ }
+ }
+}
+