I am creating a model class that only has a few core attributes and
will allow the user to create descriptions through a description editor. Is subclassing MAAdaptiveModel a smart alternative to using customDescription on the class side (as seen in Exercise 18 in magritte-solutions.pdf)? Thanks, Chad _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> I am creating a model class that only has a few core attributes and
> will allow the user to create descriptions through a description > editor. Is subclassing MAAdaptiveModel a smart alternative to using > customDescription on the class side (as seen in Exercise 18 in > magritte-solutions.pdf)? Yes, I think that's a good solution. Sometimes this is not possible, so a stateful trait -- to turn any class into an adaptive model -- would be a really a cool thing to have. I basically end up re-implementing the few methods necessary over and over again. Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Subclassing MAAdaptiveModel works with the MADescriptionEditor.
However, when I try to get an edit for for my model with "mymodel asComponent", none of the descriptions appear in the form, not even the ones that are hard-coded into the class-side. BTW, I have cleared caches and initialized my model class. Chad On 4/19/07, Lukas Renggli <[hidden email]> wrote: > > I am creating a model class that only has a few core attributes and > > will allow the user to create descriptions through a description > > editor. Is subclassing MAAdaptiveModel a smart alternative to using > > customDescription on the class side (as seen in Exercise 18 in > > magritte-solutions.pdf)? > > Yes, I think that's a good solution. > > Sometimes this is not possible, so a stateful trait -- to turn any > class into an adaptive model -- would be a really a cool thing to > have. I basically end up re-implementing the few methods necessary > over and over again. > > Cheers, > Lukas > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki > -- Chad Nantais http://myspace.com/chadnantais http://www.last.fm/music/Chad+Nantais _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
On 19 Apr 2007, at 22:56, Chad Nantais wrote: > Subclassing MAAdaptiveModel works with the MADescriptionEditor. > > However, when I try to get an edit for for my model with "mymodel > asComponent", none of the descriptions appear in the form, not even > the ones that are hard-coded into the class-side. BTW, I have cleared > caches and initialized my model class. MAAdaptiveModel doesn't take the hard-coded class side descriptions into account as it overrides #description without calling super. You can change that of course, but doing something like I did in the class PRForm in the package Pier-Forms. description "Answer a generic description with the properties of the structure." ^ (MAContainer withAll: super description) , self metamodel readUsing: aDescription ^ (self metamodel includes: aDescription) ifFalse: [ super readUsing: aDescription ] ifTrue: [ self model at: aDescription ifAbsent: [ aDescription default ] ] write: anObject using: aDescription (self metamodel includes: aDescription) ifFalse: [ super write: anObject using: aDescription ] ifTrue: [ self model at: aDescription put: anObject ] In this example I store the adaptive descriptions in the variable metamodel. You need change your description editor to reflect that. HTH, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Yes, your response was helpful, as always.
One thing I don't quite get though is whether it is safe/smart/possible to use a description editor on the hard-coded descriptions (eg. change priority; add more options to an MASingleOptionDescription). Chad On 4/21/07, Lukas Renggli <[hidden email]> wrote: > > On 19 Apr 2007, at 22:56, Chad Nantais wrote: > > > Subclassing MAAdaptiveModel works with the MADescriptionEditor. > > > > However, when I try to get an edit for for my model with "mymodel > > asComponent", none of the descriptions appear in the form, not even > > the ones that are hard-coded into the class-side. BTW, I have cleared > > caches and initialized my model class. > > MAAdaptiveModel doesn't take the hard-coded class side descriptions > into account as it overrides #description without calling super. You > can change that of course, but doing something like I did in the > class PRForm in the package Pier-Forms. > > description > "Answer a generic description with the properties of the structure." > > ^ (MAContainer withAll: super description) , self metamodel > > readUsing: aDescription > ^ (self metamodel includes: aDescription) > ifFalse: [ super readUsing: aDescription ] > ifTrue: [ self model at: aDescription ifAbsent: [ aDescription > default ] ] > > write: anObject using: aDescription > (self metamodel includes: aDescription) > ifFalse: [ super write: anObject using: aDescription ] > ifTrue: [ self model at: aDescription put: anObject ] > > In this example I store the adaptive descriptions in the variable > metamodel. You need change your description editor to reflect that. > > HTH, > Lukas > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > > > _______________________________________________ > SmallWiki, Magritte, Pier and Related Tools ... > https://www.iam.unibe.ch/mailman/listinfo/smallwiki > -- Chad Nantais http://myspace.com/chadnantais http://www.last.fm/music/Chad+Nantais _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
> One thing I don't quite get though is whether it is
> safe/smart/possible to use a description editor on the hard-coded > descriptions (eg. change priority; add more options to an > MASingleOptionDescription). No, this is not save, unless you copy them before editing. If you flush the description cache (and this happens automatically if you edit your code), they will be flushed. Btw, I did not forget your mail "Magritte: Error when adding Multiple- Option, Single-Option through editor" however I couldn't fix the problem yet. Stay tuned. Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ SmallWiki, Magritte, Pier and Related Tools ... https://www.iam.unibe.ch/mailman/listinfo/smallwiki |
Free forum by Nabble | Edit this page |