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
--
View this message in context:
http://forum.world.st/Request-Feedback-for-Issue-1130-Hook-for-Customized-P…
Sent from the Moose mailing list archive at
Nabble.com.