Yes, that is currently how I've done it -- although with Java 1.4 and
my own enumeration stuff. I have to manually register my enums with
Cayenne on startup. (Typing in the enumerated value in the modeler
doesn't auto-initialize them and make them available -- they have to
be individually registered with the DataNode --
node.getAdapter().getExtendedTypes().registerType(...).)
I'd like another section in the modeler where you define enumerated
values, just as you define classes. I'd only want to support integer
and string based values, like RED -> 1, GREEN -> 2, BLUE -> 3. (Or,
to use an actual example from the code I maintain, ELDERLY_TYPE_NO ->
"N", ELDERLY_TYPE_YES -> "Y", ELDERLY_TYPE_YES_WITH_EXTENDED_SERVICE
-> "E") Once you define an enumeration, it would be saved in the XML
files, you could generate the source code for it, and in the ObjEntity
section, since you are defining the enums in the modeler, they could
be automatically added to the Java Type pulldown. When Cayenne reads
the XML configuration, it could look to see what enumerations are
defined and automatically register them with the DataNode for you. I
personally think this would be a HUGE feature and it is great for
having more type safety and for documentation. I know it would be a
lot of work, too -- hence I'd need to be stubborn and figure Swing
out. :-)
Did I explain it well enough? Please ask more questions if I didn't.
Thanks!
/dev/mrg
On 8/9/07, Andrus Adamchik <andru..bjectstyle.org> wrote:
> You can use Java enums with the Modeler already (even with Cayenne
> 1.2). Not *selecting* from dropdown, but rather typing your enum
> class in the dropdown field.
>
> Could you explain how are you planning to add enums to dropdowns?
> They are user defined classes after all.
>
> Andrus
>
>
> On Aug 9, 2007, at 3:25 PM, Michael Gentry wrote:
>
> > Another advantage of deciding on 1.5 is we can have native enumeration
> > support. I would definitely like to see this in the modeler and could
> > try to add it (my Swing skills aren't so hot, but I can be stubborn).
> > I'd like to be able to define the enumerated values in the modeler and
> > be able to choose them in the data type pull downs. Then hook into
> > the code generation to create the enumerations and have Cayenne
> > automatically register them. Then your _Classes could have valid
> > setLoanType(com.foo.bar.LoanTypeEnum loanType) calls.
> >
> > This is kind of what I've implemented with the enumerations example I
> > put on the wiki, but I'd like it to be much more native in Cayenne.
> > Any thoughts?
> >
> > Thanks,
> >
> > /dev/mrg
> >
> > PS. At one point, my example didn't work under Java 5, but I suspect
> > that was a bug in the JVM. I haven't tried it since, though.
> > PPS. Yeah, I need to get to work on this stuff ...
> >
>
>
This archive was generated by hypermail 2.0.0 : Thu Aug 09 2007 - 09:13:15 EDT