On Fri, Mar 26, 2010 at 10:49, Peter Schneider <[email protected]>wrote:
> Hi there,
>
> I've come along a general question: Is it possible to override the
> "enumeration"-check of a property?
> To make my vague question a bit more clear, please take a look at the
> attached
> code.
>
> What I like to know is: When the base class (here, "pin") has defined a
> property with a number of possible values ('enumeration'), is it possible
> to
> override this list/array in a derived class ("tristatePin")?
>
> I've tried the attached code in playground, but with no joy :-/
> The "refine" key in the property definition does not seem to change the
> possibility to re-define the 'enumeration'.
>
>
> Another question arises: Is it good practice to get the list/array of
> possible
> values from such a property by calling
> <code>
> qx.Class.getPropertyDefinition(tristatePin, "level").check
> </code> ?
> Or is there a 'cleaner' way of accessing it?
> The static class "qx.util.PropertyUtil" looked promising, but no method
> like
> "getCheck" or "getPossibleValues" there ;)
>
Hi Peter, her you go.
Derrell
qx.Class.define("pin",
{
extend : qx.core.Object,
type : "abstract",
construct : function()
{
this.base(arguments);
this.setLevel("low");
},
properties :
{
level :
{
check : function(value)
{
return qx.lang.Array.contains(this.getPossibleLevels(), value);
}
},
possibleLevels :
{
init : [ "high", "low" ]
}
}
});
qx.Class.define("tristatePin",
{
extend : pin,
construct : function()
{
this.setPossibleLevels(["high", "low", "tristate"]);
this.base(arguments);
}
});
var portA = new tristatePin();
portA.setLevel("low");
portA.setLevel("high");
portA.setLevel("tristate");
var output = [];
output.push("Final state of portA is '" + portA.getLevel() + "'\n");
output.push(qx.dev.Debug.debugObjectToString(portA.getPossibleLevels(),
"Possible levels"));
alert(output.join("\n"));
------------------------------------------------------------------------------
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