[BUG] TreeView refresh

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

[BUG] TreeView refresh

Alain Fischer-3
Andy, Blair,

I have found a small bug when working with TreeView.
When I add an object to a child of an existing object
in a TreeModel it's TreeView is not refreshed and
the small box containing a plus at the left of a parent
object is not displayed.

Here is the code that show the bug:
(execute each line with a doit)

    tm := TreeModel new
    tp := TreePresenter showOn: tm
    tm add: #toto asChildOf: nil
    tm add: #titi asChildOf: #toto

You must see here that the plus box on the left of "toto"
is missing. You must execute the next line to see the plus box.

    tm refresh: #toto

As a workaround to this box, I have modified the following method:

    !TreeModel methodsFor!
    add: leaf asChildOf: branch
     "Adds the <Object>, leaf, to the receiver as a child of the <Object>,
     branch, answering the new leaf. If branch is nil then leaf is added
     as a root of the tree.
     If leaf already exists in the tree, then answer the existing node which
is
     left in place (i.e. it is not an error to attempt to add an equivalent
node
     twice, and the existing node is not overwritten with the new object).
     If branch does not exist then raise a suitable exception. "

     | parentNode childNode |
     childNode := self getNodeFor: leaf ifAbsent: [].
     childNode notNil ifTrue: [^childNode object].

     "Find the parent leaf"
     parentNode := branch isNil
      ifTrue: [anchorNode]
      ifFalse: [self getNodeFor: branch].

     self addChild: leaf parentNode: parentNode.

     "Inform dependents"
     self trigger: #item:addedInParent: with: leaf with: branch.
>>   branch notNil ifTrue: [self refresh: branch].

     ^leaf
     ! !

Hope that help you to improve your already nice product.

Have a nice day.
Alain.


Reply | Threaded
Open this post in threaded view
|

Re: [BUG] TreeView refresh

Blair McGlashan
Alain

You wrote in message news:[hidden email]...
>
> I have found a small bug when working with TreeView.
> When I add an object to a child of an existing object
> in a TreeModel it's TreeView is not refreshed and
> the small box containing a plus at the left of a parent
> object is not displayed.
> ...

Thanks for your bug report. It was quite an interesting one to investigate.
I've attached a patch.

Regards

Blair
























begin 666 348.st
M(B,S-#@Z(B$-"@T*(51R9656:65W(&UE=&AO9'-&;W(A#0H-"F]N271E;3H@
M86Y/8FIE8W0@861D961);E!A<F5N=#H@85!A<F5N=$]B:F5C= T*"2)%=F5N
M="!R96-E:79E9"!W:&5N(&%N3V)J96-T(&AA<R!B965N(&%D9&5D('1O('1H
M92!R96-E:79E<B=S#0H);6]D96P@=VET:&EN(&%087)E;G1/8FIE8W0N(@T*
M#0H)?"!P87)E;G1(86YD;&4@<&%R96YT5'9)=&5M('P-"@EA4&%R96YT3V)J
M96-T(&ES3FEL(&EF5')U93H@6PT*"0DB061D:6YG(&$@<F]O="!O8FIE8W0B
M#0H)"5YS96QF(&)A<VEC061D06QL.B H07)R87D@=VET:#H@86Y/8FIE8W0I
M(&EN2&%N9&QE.B!45D=.7U)/3U0@869T97)(86YD;&4Z(%1625],05-4("!=
M+@T*#0H)(D=E="!T:&4@5%9)5$5-('-T<G5C='5R92!F;W(@=&AE('!A<F5N
M="(-"@EP87)E;G1(86YD;&4@.CT@<V5L9B!H86YD;&5&<F]M3V)J96-T.B!A
M4&%R96YT3V)J96-T(&EF06)S96YT.B!;7G-E;&9=+@T*#0H)*'!A<F5N=%1V
M271E;2 Z/2!45DE414T@;F5W*0T*"0EH271E;3H@<&%R96YT2&%N9&QE.PT*
M"0EM87-K.B C(RA45DE&7T-(24Q$4D5.('P@5%9)1E]35$%412DN#0H)<V5L
M9B!T=FU'971)=&5M.B!P87)E;G14=DET96TN#0H-"@DB57!D871E('!A<F5N
M="!I9B!I="!H87,@9V%I;F5D(&ET)W,@9FER<W0@8VAI;&0N(@T*"2(C,S0X
M.B!7:&5N(%1635]'151)5$5-(&ES('-E;G0@=&AE(&-O;G1R;VPL(&EF(&ET
M(&AA<R!N;W0@<')E=FEO=7-L>2!B965N(')E<&%I;G1E9"P@;6%Y('-E;F0@
M8F%C:R!A( T*"6-H:6QD<F5N(&-A;&QB86-K('1O(')E<75E<W0@=&AE(&YU
M;6)E<B!O9B!C:&EL9')E;B!O9B!T:&4@<&%R96YT+"!T;R!W:&EC:"!T:&4@
M86YS=V5R(&ES(&YO=R G,2<@*'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