setAlias and getAlias are today limited to only one alias each. As it is
needed in many cases, I have extended the class by the attached patch
and propose the change. The syntax is now of two ways:

QxSplitPane.addProperty({ name : "leftWidget", getAlias : "getTopWidget", 
setAlias : "setTopWidget", type : QxConst.TYPEOF_OBJECT });

or the new one

QxSplitPane.addProperty({ name : "leftWidget", getAlias : ["getTopWidget", 
"getFirstWidget"], setAlias : ["setTopWidget", "setFirstWidget"], type : 
QxConst.TYPEOF_OBJECT });

Additionally, if, for error tracing purposes, the following code can
check for the array type not only that it is an object (not added in the
diff):

function getObjectClass(obj)
{
    if (obj && obj.constructor && obj.constructor.toString)
    {
        var arr = obj.constructor.toString().match(/function\s*(\w+)/);
        return arr && arr.length == 2 ? arr[1] : undefined;
    }
    else
    {
        return undefined;
    }
}

That can also be added for stricter type checking.

Kent
Index: source/script/core/QxExtend.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/core/QxExtend.js,v
retrieving revision 1.14
diff -u -r1.14 QxExtend.js
--- source/script/core/QxExtend.js	17 Feb 2006 20:42:44 -0000	1.14
+++ source/script/core/QxExtend.js	2 Apr 2006 14:53:13 -0000
@@ -650,11 +650,23 @@
   // building user configured get alias for property
   if (typeof p.getAlias === QxConst.TYPEOF_STRING) {
     pp[p.getAlias] = pp[QxConst.INTERNAL_GET + p.method];
+  }
+  else if(typeof p.getAlias === QxConst.TYPEOF_OBJECT) {
+    for(i = 0; i < p.getAlias.length; i++)
+    {
+      pp[p.getAlias[i]] = pp[QxConst.INTERNAL_GET + p.method];
+    };
   };
 
   // building user configured set alias for property
   if (typeof p.setAlias === QxConst.TYPEOF_STRING) {
     pp[p.setAlias] = pp[QxConst.INTERNAL_SET + p.method];
+  }
+  else if(typeof p.setAlias === QxConst.TYPEOF_OBJECT) {
+    for(i = 0; i < p.setAlias.length; i++)
+    {
+      pp[p.setAlias[i]] = pp[QxConst.INTERNAL_SET + p.method];
+    };
   };
 };
 

Reply via email to