Updating a hierarchical list...

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

Updating a hierarchical list...

Elod Kironsky
Hi!

I am developing a hierarchical browser of hetergoenous objects (e.g.
objects of different classes). I am using an AbstractHiererachicalList
with a SimpleHierarchicalListMorph. The problem is, that if I add a new
item into the list, it does not update itself and I must manually toggle
the tree of the list to see the new item. I found out, that calling self
list: (self model getList) perfectly updates the whole list and keeps
the expanded trees expanded. The problem is, that the objects inside the
list have no reference to the list itself so I cannot use the above
call. Can anyone help? Is there a default mechanism to solve this
problem, or it has to be implemented by an EventHandler?

Thanks in advance,

Elod

Reply | Threaded
Open this post in threaded view
|

Re: Updating a hierarchical list...

Alain Plantec
Elod Kironsky a écrit :

> Hi!
>
> I am developing a hierarchical browser of hetergoenous objects (e.g.
> objects of different classes). I am using an AbstractHiererachicalList
> with a SimpleHierarchicalListMorph. The problem is, that if I add a
> new item into the list, it does not update itself and I must manually
> toggle the tree of the list to see the new item. I found out, that
> calling self list: (self model getList) perfectly updates the whole
> list and keeps the expanded trees expanded. The problem is, that the
> objects inside the list have no reference to the list itself so I
> cannot use the above call. Can anyone help? Is there a default
> mechanism to solve this problem, or it has to be implemented by an
> EventHandler?
>
> Thanks in advance,
>
> Elod
>
>
Hi Elod,

AbstractHierarchicalList is the model. It should have a method to build
the tree and send it to its SimpleHierarchicalListMorph.
Usually #getList is used and then if you want to refresh the list you
simply have to send "changed: #getList" to the model.

see #update: method in SimpleHierarchicalListMorph:
update: aSymbol
    aSymbol == getSelectionSelector
        ifTrue: [self selection: self getCurrentSelectionItem.
            ^ self].
    aSymbol == getListSelector
        ifTrue: [self list: self getList.
            ^ self].
    ((aSymbol isKindOf: Array)
            and: [aSymbol notEmpty
                    and: [aSymbol first == #openPath]])
        ifTrue: [^ (scroller submorphs
                at: 1
                ifAbsent: [^ self])
                openPath: aSymbol allButFirst]

alain

Reply | Threaded
Open this post in threaded view
|

Re: Updating a hierarchical list...

Elod Kironsky
Alain Plantec wrote:

> Elod Kironsky a écrit :
>
>> Hi!
>>
>> I am developing a hierarchical browser of hetergoenous objects (e.g.
>> objects of different classes). I am using an
>> AbstractHiererachicalList with a SimpleHierarchicalListMorph. The
>> problem is, that if I add a new item into the list, it does not
>> update itself and I must manually toggle the tree of the list to see
>> the new item. I found out, that calling self list: (self model
>> getList) perfectly updates the whole list and keeps the expanded
>> trees expanded. The problem is, that the objects inside the list have
>> no reference to the list itself so I cannot use the above call. Can
>> anyone help? Is there a default mechanism to solve this problem, or
>> it has to be implemented by an EventHandler?
>>
>> Thanks in advance,
>>
>> Elod
>>
>>
> Hi Elod,
>
> AbstractHierarchicalList is the model. It should have a method to
> build the tree and send it to its SimpleHierarchicalListMorph.
> Usually #getList is used and then if you want to refresh the list you
> simply have to send "changed: #getList" to the model.
>
> see #update: method in SimpleHierarchicalListMorph:
> update: aSymbol
>    aSymbol == getSelectionSelector
>        ifTrue: [self selection: self getCurrentSelectionItem.
>            ^ self].
>    aSymbol == getListSelector
>        ifTrue: [self list: self getList.
>            ^ self].
>    ((aSymbol isKindOf: Array)
>            and: [aSymbol notEmpty
>                    and: [aSymbol first == #openPath]])
>        ifTrue: [^ (scroller submorphs
>                at: 1
>                ifAbsent: [^ self])
>                openPath: aSymbol allButFirst]
>
> alain
>
>
Yes, that is clear to me. The problem is, that the objects inside the
list have no reference to the model (AbstractHierarchicalList), so they
cannot send changed: #getList. Is there a way, that i just fire and
event or message into the "Squeak world" and every object just gets it
and can react if it wants to?

Elod

Reply | Threaded
Open this post in threaded view
|

Re: Updating a hierarchical list...

Chris Muller
Hi Elod, have you considered the Smalltalk dependency mechanism, the
more general Listener pattern or even Notifications?

Good luck..

> Yes, that is clear to me. The problem is, that the objects inside the
>
> list have no reference to the model (AbstractHierarchicalList), so
> they
> cannot send changed: #getList. Is there a way, that i just fire and
> event or message into the "Squeak world" and every object just gets
> it
> and can react if it wants to?
>
> Elod
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Updating a hierarchical list...

Elod Kironsky
No, because I haven't got the slightest idea how those things work.
Maybe somebody could help me :-)

Elod

>Hi Elod, have you considered the Smalltalk dependency mechanism, the
>more general Listener pattern or even Notifications?
>
>Good luck..
>
>  
>
>>Yes, that is clear to me. The problem is, that the objects inside the
>>
>>list have no reference to the model (AbstractHierarchicalList), so
>>they
>>cannot send changed: #getList. Is there a way, that i just fire and
>>event or message into the "Squeak world" and every object just gets
>>it
>>and can react if it wants to?
>>
>>Elod
>>
>>
>>
>>    
>>
>
>
>
>  
>