[Spec] List and notebook page

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

[Spec] List and notebook page

HilaireFernandes

Hi,

In a list contained in a notebook page, the display bloc is not called as expect:

Likely I missed something, any idea?

Thank. Keep safe.

Hilaire

connectPresenters 
    scripts whenSelectedItemChanged: [ :class |
        methods selectPageIndex: 1.
        ((methods pageAt: 1) activePresenter )
            items:  class methods;
            display: [:aMethod | self halt. aMethod selector].
        source     clearContent ].
newMethodsList
    methods := self newNotebook.
    methods
        addPage: self instanceMethodsTab;
        addPage: self classMethodsTab
instanceMethodsTab
    ^ SpNotebookPage 
        title: 'Methods' translated 
        provider: [ self newList ]
-- 
Dr. Geo
http://drgeo.eu
Reply | Threaded
Open this post in threaded view
|

[Spec] List and notebook page

HilaireFernandes

Hi,

I refactor a bit the code, to have a slightly better behavior.

I send the #display: message at the time the list is installed in the notebook page:

newMethodsList
    methods := self newNotebook.
    methods
        addPage: self instanceMethodsTab;
        addPage: self classMethodsTab
instanceMethodsTab
    ^ SpNotebookPage 
        title: 'Methods' translated 
        provider: [ self newList
            display: [:aMethod | aMethod selector ];
            yourself]
classMethodsTab
    ^ SpNotebookPage 
        title: 'Script data' translated 
        provider: [ self newList 
            display: [:aMethod | aMethod selector ];
            yourself]

Then I connect the presenters:

connectPresenters 
    scripts whenSelectedItemChanged: [ :class | 
        methods resetAllPageContents.
        (methods pageAt: 1) whenRetrievedDo: [ :list  |  list  items:  class methods].
        (methods pageAt: 2) whenRetrievedDo: [ :list  | list  items:  class class methods].
        methods selectPageIndex: 1.
        source     clearContent ].

The behavior is mostly as expected, but when the I click for the first time on a script at the left, the notebook list in page 1 is not updated (empty):

Then when I click a second time on another script it is updated, then also in the first clicked script:


Any idea ?

I joined the complete class too.

Thanks. Keep safe.

Hilaire

-- 
Dr. Geo
http://drgeo.eu

DrGScriptBrowser2.st (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

[Spec] List and notebook page

HilaireFernandes

I resolved the issue, but it looks counter intuitive. Any rational?

connectPresenters 
    scripts whenSelectedItemChanged: [ :class | 
        source clearContent; behavior: nil.
        class ifNotNil: [ 
            methods resetAllPageContents.
            (methods pageAt: 1) whenRetrievedDo: [ :list  |  list  items:  class methods].
            (methods pageAt: 2) whenRetrievedDo: [ :list  | list  items:  class class methods].
            methods resetAllPageContents.]].
-- 
Dr. Geo
http://drgeo.eu
Reply | Threaded
Open this post in threaded view
|

Re: [Spec] List and notebook page

EstebanLM
Probably the order of properties change triggering will affect the others. 
It depends on how you connected the presenters originally (aka: clearContent will maybe trigger something, etc.).

Esteban

On 29 Mar 2020, at 17:56, Hilaire <[hidden email]> wrote:

I resolved the issue, but it looks counter intuitive. Any rational?

connectPresenters 
    scripts whenSelectedItemChanged: [ :class | 
        source clearContent; behavior: nil.
        class ifNotNil: [ 
            methods resetAllPageContents.
            (methods pageAt: 1) whenRetrievedDo: [ :list  |  list  items:  class methods].
            (methods pageAt: 2) whenRetrievedDo: [ :list  | list  items:  class class methods].
            methods resetAllPageContents.]].
-- 
Dr. Geo
http://drgeo.eu