Spec: Binding widgets how to

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

Nicolai Hess-3-2


2016-01-14 17:20 GMT+01:00 Offray Vladimir Luna Cárdenas <[hidden email]>:
Hi Nicolai,

That was the issue. Now it's working! I was trying to test different combinations to see why UI updating was not happening but I got the variations wrong (one true, another false, instead of both false :-) ).

The next step I'm working on in populating the GTPlayPage with some particular content. In my previous interface I made something like this:

-[1]---------------------
GrafoscopioBrowser>>panelAsCodeFor: aNode
    "Shows an interactive playground for Smalltalk code in a node body"

    browser := GLMTabulator new.
    browser title: 'Código'.
    browser column: #code.
    browser transmit
        to: #code;
        transformed: [ GTPlayPage new content: aNode body ];
        andShow: [ :a | a custom: GTPlayground new ].
    browser sendToOutside: #nodeBody from: #code -> #text.
    ^ browser.
------------------------

In this one I tried some variation of GlamourPresentationModel>>glmPres that let the user predefine a content for the GTPlayPage like this:

-[2]----------------------
glmPresWithContent: aString
    glmPres isNil ifTrue:[
        glmPres := GTPlayground new startOn:  (GTPlayPage new content: aString)].
    ^glmPres
---------------------------

but if I try running the interface with this I get: "MessageNotUnderstood: GlamourPresentationModel>>content:", so I think that something more is needed to create Playgrounds in the Spec-Glamour that are pre-populated with content.

How can I create a playground inside a Spec-Glamour interface that is already populated with a given content?


I would expect (content is the GlamourPresentationModel)

content glmPres codePresentation text: 'new text'.

but it does not work.



 
Thanks,

Offray

On 14/01/16 03:56, Nicolai Hess wrote:


2016-01-13 23:07 GMT+01:00 Offray Vladimir Luna Cárdenas <[hidden email][hidden email]>:ui insp presentationClass: GTInspector startOn: 42.

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 <[hidden email][hidden email]> 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





Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

jfabry

Ah this is actually a Glamour question: If I have a GTPlayground, how do I set its content programmatically? I have been able to do it with something like the following:

| play |
“play is the GTPlayground instance"
play := (GTPlayground new openOn: GTPlayPage new) model.
play entity saveContent: '42'.
play update.

I don’t know if this is the officially approved way of doing it, maybe the Glamour crew can enlighten us.

On Jan 14, 2016, at 18:34, Nicolai Hess <[hidden email]> wrote:

but if I try running the interface with this I get: "MessageNotUnderstood: GlamourPresentationModel>>content:", so I think that something more is needed to create Playgrounds in the Spec-Glamour that are pre-populated with content.

How can I create a playground inside a Spec-Glamour interface that is already populated with a given content?


I would expect (content is the GlamourPresentationModel)

content glmPres codePresentation text: 'new text'.

but it does not work.



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile

Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

Tudor Girba-2
Here is a simpler way:
GTPlayground new openOn: (GTPlayPage new content: '42’)

Cheers,
Doru

> On Jan 16, 2016, at 4:23 PM, Johan Fabry <[hidden email]> wrote:
>
>
> Ah this is actually a Glamour question: If I have a GTPlayground, how do I set its content programmatically? I have been able to do it with something like the following:
>
> | play |
> “play is the GTPlayground instance"
> play := (GTPlayground new openOn: GTPlayPage new) model.
> play entity saveContent: '42'.
> play update.
>
> I don’t know if this is the officially approved way of doing it, maybe the Glamour crew can enlighten us.
>
>> On Jan 14, 2016, at 18:34, Nicolai Hess <[hidden email]> wrote:
>>
>> but if I try running the interface with this I get: "MessageNotUnderstood: GlamourPresentationModel>>content:", so I think that something more is needed to create Playgrounds in the Spec-Glamour that are pre-populated with content.
>>
>> How can I create a playground inside a Spec-Glamour interface that is already populated with a given content?
>>
>>
>> I would expect (content is the GlamourPresentationModel)
>>
>> content glmPres codePresentation text: 'new text'.
>>
>> but it does not work.
>
>
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile
>

--
www.tudorgirba.com
www.feenk.com

"Problem solving efficiency grows with the abstractness level of problem understanding."





Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

jfabry

Ah, sorry for the confusion, for the sake of the example I oversimplified things. Let’s say that I have a GTPlayground instance that has been around for some time, and then I want to change its content. What should I do?

| play |
“play is the GTPlayground instance"
play := (GTPlayground new openOn: GTPlayPage new) model.

“… lots of things happen … the world turns … sun and moon go up and down … "

play entity saveContent: '42'.
play update.

Still like this ?

> On Jan 16, 2016, at 12:27, Tudor Girba <[hidden email]> wrote:
>
> Here is a simpler way:
> GTPlayground new openOn: (GTPlayPage new content: '42’)
>
> Cheers,
> Doru
>
>> On Jan 16, 2016, at 4:23 PM, Johan Fabry <[hidden email]> wrote:
>>
>>
>> Ah this is actually a Glamour question: If I have a GTPlayground, how do I set its content programmatically? I have been able to do it with something like the following:
>>
>> | play |
>> “play is the GTPlayground instance"
>> play := (GTPlayground new openOn: GTPlayPage new) model.
>> play entity saveContent: '42'.
>> play update.
>>
>> I don’t know if this is the officially approved way of doing it, maybe the Glamour crew can enlighten us.
>>
>>> On Jan 14, 2016, at 18:34, Nicolai Hess <[hidden email]> wrote:
>>>
>>> but if I try running the interface with this I get: "MessageNotUnderstood: GlamourPresentationModel>>content:", so I think that something more is needed to create Playgrounds in the Spec-Glamour that are pre-populated with content.
>>>
>>> How can I create a playground inside a Spec-Glamour interface that is already populated with a given content?
>>>
>>>
>>> I would expect (content is the GlamourPresentationModel)
>>>
>>> content glmPres codePresentation text: 'new text'.
>>>
>>> but it does not work.
>>
>>
>>
>> ---> Save our in-boxes! http://emailcharter.org <---
>>
>> Johan Fabry   -   http://pleiad.cl/~jfabry
>> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile
>>
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "Problem solving efficiency grows with the abstractness level of problem understanding."
>
>
>
>
>
>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

Offray
Hi,

I'm still kind of lost here. If I try with these approaches I get a
*new* GTPlayground window populated with content, instead of an embedded
one. How can I made this GTPlayPage one that is embedded in a spec
glamour interface, like the one in the minimalist example: a dictionary
with two keys/values: one which is shown as text and other that is shown
as a playground, both populated with the content in the dict values and
both, embedded in a widget instead of on separate windows. Is this
possible with the current Spec-Glamour implementation?, if not how can
be it extended to make this happen?

Thanks,

Offray

On 16/01/16 10:36, Johan Fabry wrote:

> Ah, sorry for the confusion, for the sake of the example I oversimplified things. Let’s say that I have a GTPlayground instance that has been around for some time, and then I want to change its content. What should I do?
>
> | play |
> “play is the GTPlayground instance"
> play := (GTPlayground new openOn: GTPlayPage new) model.
>
> “… lots of things happen … the world turns … sun and moon go up and down … "
>
> play entity saveContent: '42'.
> play update.
>
> Still like this ?
>
>> On Jan 16, 2016, at 12:27, Tudor Girba <[hidden email]> wrote:
>>
>> Here is a simpler way:
>> GTPlayground new openOn: (GTPlayPage new content: '42’)
>>
>> Cheers,
>> Doru
>>
>>> On Jan 16, 2016, at 4:23 PM, Johan Fabry <[hidden email]> wrote:
>>>
>>>
>>> Ah this is actually a Glamour question: If I have a GTPlayground, how do I set its content programmatically? I have been able to do it with something like the following:
>>>
>>> | play |
>>> “play is the GTPlayground instance"
>>> play := (GTPlayground new openOn: GTPlayPage new) model.
>>> play entity saveContent: '42'.
>>> play update.
>>>
>>> I don’t know if this is the officially approved way of doing it, maybe the Glamour crew can enlighten us.
>>>
>>>> On Jan 14, 2016, at 18:34, Nicolai Hess <[hidden email]> wrote:
>>>>
>>>> but if I try running the interface with this I get: "MessageNotUnderstood: GlamourPresentationModel>>content:", so I think that something more is needed to create Playgrounds in the Spec-Glamour that are pre-populated with content.
>>>>
>>>> How can I create a playground inside a Spec-Glamour interface that is already populated with a given content?
>>>>
>>>>
>>>> I would expect (content is the GlamourPresentationModel)
>>>>
>>>> content glmPres codePresentation text: 'new text'.
>>>>
>>>> but it does not work.
>>>
>>>
>>> ---> Save our in-boxes! http://emailcharter.org <---
>>>
>>> Johan Fabry   -   http://pleiad.cl/~jfabry
>>> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile
>>>
>> --
>> www.tudorgirba.com
>> www.feenk.com
>>
>> "Problem solving efficiency grows with the abstractness level of problem understanding."
>>
>>
>>
>>
>>
>>
>
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

jfabry

Well that’s actually much easier. :-) What you need to do is to use the presentationClass:startOn: API method.

| ui |
ui := GlamourPresentationModel new.
ui presentationClass: GTPlayground startOn: (GTPlayPage new saveContent: '42').
ui openWithSpec

I just realized that this was not clear from the examples in the class comment. I have updated the class comment to reflect this.

I hope this resolves all your issues!

> On Jan 16, 2016, at 14:24, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
>
> Hi,
>
> I'm still kind of lost here. If I try with these approaches I get a *new* GTPlayground window populated with content, instead of an embedded one. How can I made this GTPlayPage one that is embedded in a spec glamour interface, like the one in the minimalist example: a dictionary with two keys/values: one which is shown as text and other that is shown as a playground, both populated with the content in the dict values and both, embedded in a widget instead of on separate windows. Is this possible with the current Spec-Glamour implementation?, if not how can be it extended to make this happen?
>
> Thanks,
>
> Offray
>
> On 16/01/16 10:36, Johan Fabry wrote:
>> Ah, sorry for the confusion, for the sake of the example I oversimplified things. Let’s say that I have a GTPlayground instance that has been around for some time, and then I want to change its content. What should I do?
>>
>> | play |
>> “play is the GTPlayground instance"
>> play := (GTPlayground new openOn: GTPlayPage new) model.
>>
>> “… lots of things happen … the world turns … sun and moon go up and down … "
>>
>> play entity saveContent: '42'.
>> play update.
>>
>> Still like this ?
>>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

Tudor Girba-2
In reply to this post by Offray
Hi,

For your tabulator example, you can do something like:

    browser := GLMTabulator new.
    browser title: 'Código'.
    browser column: #code.
    browser transmit 
        to: #code;
  transformed: [ :text | GTPlayPage new content: text ];
        andShow: [ :a :page | a custom: (GTPlayground new startOn: page) ].
    ^ browser openOn: 'a := 42’.

Does this help?

Cheers,
Doru


On Jan 16, 2016, at 6:24 PM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:

Hi,

I'm still kind of lost here. If I try with these approaches I get a *new* GTPlayground window populated with content, instead of an embedded one. How can I made this GTPlayPage one that is embedded in a spec glamour interface, like the one in the minimalist example: a dictionary with two keys/values: one which is shown as text and other that is shown as a playground, both populated with the content in the dict values and both, embedded in a widget instead of on separate windows. Is this possible with the current Spec-Glamour implementation?, if not how can be it extended to make this happen?

Thanks,

Offray

On 16/01/16 10:36, Johan Fabry wrote:
Ah, sorry for the confusion, for the sake of the example I oversimplified things. Let’s say that I have a GTPlayground instance that has been around for some time, and then I want to change its content. What should I do?

| play |
“play is the GTPlayground instance"
play := (GTPlayground new openOn: GTPlayPage new) model.

“… lots of things happen … the world turns … sun and moon go up and down … "

play entity saveContent: '42'.
play update.

Still like this ?

On Jan 16, 2016, at 12:27, Tudor Girba <[hidden email]> wrote:

Here is a simpler way:
GTPlayground new openOn: (GTPlayPage new content: '42’)

Cheers,
Doru

On Jan 16, 2016, at 4:23 PM, Johan Fabry <[hidden email]> wrote:


Ah this is actually a Glamour question: If I have a GTPlayground, how do I set its content programmatically? I have been able to do it with something like the following:

| play |
“play is the GTPlayground instance"
play := (GTPlayground new openOn: GTPlayPage new) model.
play entity saveContent: '42'.
play update.

I don’t know if this is the officially approved way of doing it, maybe the Glamour crew can enlighten us.

On Jan 14, 2016, at 18:34, Nicolai Hess <[hidden email]> wrote:

but if I try running the interface with this I get: "MessageNotUnderstood: GlamourPresentationModel>>content:", so I think that something more is needed to create Playgrounds in the Spec-Glamour that are pre-populated with content.

How can I create a playground inside a Spec-Glamour interface that is already populated with a given content?


I would expect (content is the GlamourPresentationModel)

content glmPres codePresentation text: 'new text'.

but it does not work.


---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile

--
www.tudorgirba.com
www.feenk.com

"Problem solving efficiency grows with the abstractness level of problem understanding."








---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile






--
www.tudorgirba.com
www.feenk.com

"Speaking louder won't make the point worthier."

Reply | Threaded
Open this post in threaded view
|

Re: Spec: Populating a playground with a particular content (was Re: Spec: Binding widgets how to)

Offray
In reply to this post by jfabry
Thanks Johan, it's working fine. Once I have better results I'll share
them with all of you.

Cheers,

Offray

On 16/01/16 14:00, Johan Fabry wrote:

> Well that’s actually much easier. :-) What you need to do is to use the presentationClass:startOn: API method.
>
> | ui |
> ui := GlamourPresentationModel new.
> ui presentationClass: GTPlayground startOn: (GTPlayPage new saveContent: '42').
> ui openWithSpec
>
> I just realized that this was not clear from the examples in the class comment. I have updated the class comment to reflect this.
>
> I hope this resolves all your issues!
>
>> On Jan 16, 2016, at 14:24, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
>>
>> Hi,
>>
>> I'm still kind of lost here. If I try with these approaches I get a *new* GTPlayground window populated with content, instead of an embedded one. How can I made this GTPlayPage one that is embedded in a spec glamour interface, like the one in the minimalist example: a dictionary with two keys/values: one which is shown as text and other that is shown as a playground, both populated with the content in the dict values and both, embedded in a widget instead of on separate windows. Is this possible with the current Spec-Glamour implementation?, if not how can be it extended to make this happen?
>>
>> Thanks,
>>
>> Offray
>>
>> On 16/01/16 10:36, Johan Fabry wrote:
>>> Ah, sorry for the confusion, for the sake of the example I oversimplified things. Let’s say that I have a GTPlayground instance that has been around for some time, and then I want to change its content. What should I do?
>>>
>>> | play |
>>> “play is the GTPlayground instance"
>>> play := (GTPlayground new openOn: GTPlayPage new) model.
>>>
>>> “… lots of things happen … the world turns … sun and moon go up and down … "
>>>
>>> play entity saveContent: '42'.
>>> play update.
>>>
>>> Still like this ?
>>>
>
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD and RyCh labs  -  Computer Science Department (DCC)  -  University of Chile
>
>
>


12