Logo

18.5.10 Dynamic presentation

The specification of Glamour transmissions and presentations are interpreted at creation time. Thus, by default we do not have the possibility to decide the presentation based on a given entity. The DynamicPresentation rectifies the situation by simply expecting a presentation returned from the block via the display: message.

There are two distinct classes of applications for DynamicPresentations: deciding the type or the amount of presentations based on the input entity.

describe how the type can also be simulated with when: conditions on regular presentations

While the type of presentations can be simulated, deciding the number of presentations based on a given entity is not possible without a DynamicPresentation. The following code shows an example of how we could have a method browser that spawns multiple source code viewers when we select multiple methods.

| browser |
browser := GLMTabulator new.
browser title: 'Multi Methods Viewer'.
browser
column: [:c | c row: #classes; row: #methods];
column: #source.
browser transmit to: #classes; andShow: [ :a |
a list
title: 'Classes';
display: [:model | model allClasses ] ].
browser transmit to: #methods; from: #classes; andShow: [ :a |
a list
title: [ :class | 'Methods from ', class name ];
beMultiple;
display: [ :class | class methods ];
format: [ :class | class name ] ].
browser transmit to: #source; from: #methods; andShow: [ :a |
a dynamic with: [ :some :methods |
methods do: [ :each |
some text
title: each name asString;
display: [ each sourceText] ].
some stackedArrangement ] ].
browser openOn: MooseModel root allModels last.

The above browser works on a model. For example, the picture below shows it spawned on the ArgoUML model.

Using DynamicPresentation for a multi methods viewer

User Contributed Notes

rafatals3ode (15 March 2012, 2:27 pm)

how i can write this code; through ?

i am using XP

Add a Note