> On Fri, Mar 26, 2010 at 11:40, Peter Schneider <[email protected]>wrote:
>
>> Thanks a million Derrell!
>>
>> Nice trick with the 'overwriteable' check-method! It solves _both_ of my
>> problems! *Respect* !! ;) It can be so easy if you know how
>>
>
> You're welcome.
>
> Note that I had no error checking in my code. It's possible, for example, to
> set the 'possibleLevels' property to a set of values that does not include
> the current value of the 'level' property. Setting 'possibleLevels' should
> do _something_ appropriate (although it's not entirely clear _what_ it
> should do) if 'level' is currently "tristate" and 'possibleLevels' is set to
> [ "high", "low" ]. Maybe set 'level' to the first element of the new array?
> Maybe throw an error? It's a bit of a race condition, in that you can't
> change 'level' to a value that's not currently in 'possibleLevels', yet you
> can't change 'possibleLevels' if 'level' is not in the new array...
>
> Derrell
You're right on this, but fortunately I have this kind of code under full
control, so that this conditions should not come up...
All derived classes have at least those 'possibleLevels' of the superclass;
they are only extending the list(s).
/Peter
P.S.: Just to go "over the top" ;) I've attached demo-code showing that
extending the lists works like a charm!
P.P.S.: URL-shortening in the playground sometimes refuses to work, else I
would have just posted that "bit.ly"-link...
//
// Class definitions
//
qx.Class.define("decimalDigit",
{
extend : qx.core.Object,
construct : function () {
this.base(arguments);
this.setValue("0");//init
},
properties :
{
value : {
check : function (value) {
return qx.lang.Array.contains(this.getPossibleValues(), value);
}
},
possibleValues : {
init : [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
}
}
});
qx.Class.define("hexDigit",
{
extend : decimalDigit,
construct : function ()
{
this.base(arguments);
var values = this.getPossibleValues();
qx.lang.Array.append(values, ["a", "b", "c", "d", "e", "f"]);
this.setPossibleValues(values);
}
});
qx.Class.define("twoDigitDecimalNumber",
{
extend : decimalDigit,
construct : function ()
{
this.base(arguments);
var values = this.getPossibleValues();
for (var i=10; i<100; ++i) {
values.push(""+i);
}
this.setPossibleValues(values);
}
});
//
// Instance creation (choose one)
//
var instance =
//new decimalDigit();
//new hexDigit();
new twoDigitDecimalNumber();
//
// UI section
//
var doc = this.getRoot();
var selection = new qx.ui.form.SelectBox;
doc.add(selection, { left : 10, top : 10});
var enum = instance.getPossibleValues();
enum.forEach(function (val) {
selection.add( new qx.ui.form.ListItem(val) );
}, this);
selection.addListener("changeSelection", function(e) {
instance.setLevel( e.getData()[0] );
});
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel