Administrator
|
From https://github.com/moosetechnology/Moose/issues/1130 :
Right now, by default, a presentation constructor must be an annotated method which takes a composite (and optional context) as arguments, and configures a presentation. For example: gtInspectorStepsIn: composite <gtInspectorPresentationOrder: 10> composite list title: 'Steps'; display: [ self children ] While this serves the basic purpose, I found myself continuously duplicating info which I had already described with Magritte, as in the description mirroring the above: descriptionChildren <magritteDescription> ^ MAToManyRelationDescription new accessor: #children; label: 'Steps'; "..." yourself So, playing around, I created the following general purpose hook to give more latitude in constructing presentations: gtInspectorPresentationsIn: composite inContext: aGTInspector "..." eachPragma selector numArgs = 0 ifTrue: [ | configurationProvider | configurationProvider := self perform: eachPragma selector. configurationProvider gtPresentation cull: composite cull: aGTInspector cull: self ]. "..." This enables you to get presentations almost for free by leaning on (in this case) Magritte. The Magritte description gets a slight upgrade: descriptionChildren <magritteDescription> <gtInspectorPresentationOrder: 10> ^ MAToManyRelationDescription new accessor: #children; label: 'Steps'; "..." gtPresentation: [ :a | a list ]; yourself #gtPresentation: sets default mappings, eliminating the original duplication: gtPresentation: aBlock | wrapper | wrapper := [ :composite :context :subject | | presentation | presentation := aBlock cull: composite cull: context. presentation hasTitle ifFalse: [ presentation title: self label ]. presentation hasTransformation ifFalse: [ presentation display: (self accessor read: subject) ] ]. self propertyAt: #gtPresentation put: wrapper
Cheers,
Sean |
On 16 aug. 2015, at 14:33, Sean P. DeNigris <[hidden email]> wrote:
> > descriptionChildren > <magritteDescription> > <gtInspectorPresentationOrder: 10> > ^ MAToManyRelationDescription new > accessor: #children; > label: 'Steps'; > "..." > gtPresentation: [ :a | a list ]; > yourself > 1 Do you want the gtPresentation to be so direct, or would it be helpful to make some kind of builder/visitor responsible for creating the block? 2 To fit in the glamour style, also support gtPresentation: #list ? Not just a block, also a symbol. Stephan _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Administrator
|
Although it works, the API is a proof-of-concept because I don't know much about Glamour's design. Specific suggestions from an expert are welcome.
Cheers,
Sean |
Administrator
|
In reply to this post by Stephan Eggermont-3
I'm not sure I understand. Would you say more about that? My primary requirement was to get it up and running. I'm not attached to any particular approach. But, I'm be hesitant to re-implement what we can just pass to Glamour and get for free. Done. Also, Magritte actions are now picked up and added to the context menu for the selection in e.g. list presentations. For example: N.B. gtPresentation: is now glmPresentation: because it really has nothing to do with GT specifically. It creates a pane suitable for any Glamour browser. Thus, you can splice them together into a full browser like: browser := GLMTabulator new. browser column: #one; column: #two; column: #three. "..." (browser transmit) to: #two; from: #one; andShow: [ :a :model | model gtInspectorMagritteIn: a ].
Cheers,
Sean |
Free forum by Nabble | Edit this page |