[Pharo-users] Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

Nicolai Hess nicolaihess at gmail.com
Thu Jan 14 03:56:41 EST 2016


2016-01-13 23:07 GMT+01:00 Offray Vladimir Luna Cárdenas <offray at riseup.net>
:

> Hi,
>
> I've reading the code at [1] but I'm still having problems understanding
> the dynamic spec. I have created a small dictionary and populated with
> data, then created the accessors and initializePresenter, initializeWidgets
> and rebuildWithdCodeLayout and rebuildWithTextLayout, as you can see on the
> following snippets, but nothing happens despite the debugging Transcript is
> showing me that the content subwidget has the proper model, but is not
> rebuild in the GUI.
>
> Any help is, as always, very much appreciated.
>

Hi Offray,

I think you have to call
    self needRebuild: false.
in both rebuild... methods.
Otherwise the all "inner"-widgets are rebuild:



>
> [1]
> https://github.com/spec-framework/documentation/blob/master/output/book.md#rebuildDynamically
>
> ----------------------
> DynamicDict>>initializeWidgets
>
>     | data |
>     data := { 'first' -> 'I\"m just text' . 'second' -> 'ProfStef
> openPharoZenWorkspace'} asOrderedDictionary.
>     list := self newList.
>     list items: data keys.
>     content := self newText.
>     self focusOrder
>         add: list;
>         add: content.
> ----------------------
> DynamicDict>>initializePresenter
>     list whenSelectedItemChanged: [:item |
>         item = 'first'
>             ifTrue: [ self rebuildWithTextLayout ].
>         item = 'second'
>             ifTrue: [ self rebuildWithCodeLayout ].
>     ]
> ----------------------
> DynamicDict>>rebuildWithCodeLayout
>     | newLayout |
>
>     content := self instantiate: GlamourPresentationModel.
>     newLayout := SpecLayout composed
>         newRow: [:row |
>             row
>                 add: #list right: 0.7;
>                 add: #content left: 0.3];
>         yourself.
>     self needRebuild: true.
>     content needRebuild: true.
>     Transcript show: 'código + ', self content asString, String cr.
>     self buildWithSpecLayout: newLayout.
> ----------------------
> DynamicDict>>rebuildWithTextLayout
>     | newLayout |
>
>     content := self newText.
>     newLayout := SpecLayout composed
>         newRow: [:row |
>             row
>                 add: #list right: 0.7;
>                 add: #content left: 0.3];
>         yourself.
>     self needRebuild: false.
>     list needRebuild: false.
>     content needRebuild: true.
>     Transcript show: 'texto + ', self content asString, String cr..
>     self buildWithSpecLayout: newLayout.
> ----------------------
>
> Cheers,
>
> Offray
>
> On 10/01/16 13:39, Johan Fabry wrote:
>
> Sorry for the lateness and short reply but I’m involved in a bunch of
> other things that are taking almost all of my time ...
>
> From what I understand and what I can see in your code, you want to modify
> a widget when the UI is open. However you never trigger the rebuilding of
> the window. For example, see the Spec docs that I sent, where in 9.1 there
> is code that calls buildWithSpecLayout: .
>
> Actually, I am not sure you need to subclass DynamicComposableModel since
> the number of widgets never changes. You can use a normal ComposableModel
> subclass and use what is detailed in 9.1 to change the layout between the
> two options you want to have (a TextModel or a GlamourPresentationModel).
>
> On Jan 8, 2016, at 23:07, Offray Vladimir Luna Cárdenas <offray at riseup.net>
> wrote:
>
> Shouldn't be #right dynamically defined according to the values of 'item'
> and be replaced on the m2 layout?
>
>
>
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University
> of Chile
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20160114/76b5345a/attachment.html>


More information about the Pharo-users mailing list