Hi all,
I've created small class designer and code generator for Magritte. You
may see the initial version in action here:
http://comtalk.net/public/tmp/shorebase1.htm (flash demo) and download
here:
http://www.squeaksource.com/ShoreBase.html (package
ShoreBaseModel). The editor requires latest versions of Magritte,
Seaside 2.8a, Scriptaculous and ShoreComponents
*How it works*
The designer is based on Magritte meta modeling - it's very similar to
PierForms. The Magritte model is modified a bit. When you finish the
model design, the class and its Magritte descriptions are generated.
The code tries to be as short and readable as possible. The only data
source for the designer are existing source codes. That means that you
may re-edit the classes that were generated before only from the
sources. Currently the manual changes are not handled.
*More complex example*
In some cases the class design must be more complex. The example can
be the class element (description) where the user can choose some
system class:
- create new Single-Option element
- remove the default value of the element named Description (button Remove)
- choose Description type to Class
- press button Create
- press button Save. Here you edited the referenced description. This
description doesn't need description name
- set Description name to "cls". The description name is used for the
name of the generated description method. It's not required (see
above) but the code generation will not work without it here.
- set Accessor type to auto and name it "cls". The other kinds of
accessors are possible. The selector accessors have getter and setter
separated by space, the next kinds use Smalltalk expression
- set Label to "Class"
- set priority to 10
- set Required
- set Options to: "Smalltalk allClasses" and set "code"
- press Save
- press Generate
The generated description source code is
descriptionCls
^ MASingleOptionDescription new autoAccessor: #cls;
reference: (MAClassDescription new label: nil;
undefined: nil;
propertyAt: #descriptionName put: nil;
yourself);
options: [Smalltalk allClasses] asDynamicObject;
label: 'Class';
priority: 10;
beRequired;
undefined: nil;
propertyAt: #descriptionName put: 'cls';
yourself
If you will edit the options code next time, the source will by
decompiled. The description created by hand would probably look like:
descriptionCls
^ MASingleOptionDescription new
autoAccessor: #cls;
priority: 10;
label: 'Class';
beRequired;
reference: MAClassDescription new;
options: [Smalltalk allClasses] asDynamicObject;
yourself
Custom validators aren't supported now.
Please try to play with it and report bugs. You may write more tests too ;-)
Cheers,
-- Pavel