The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Customizing the VW Tree Widget

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Customizing the VW Tree Widget Posted: Oct 30, 2003 1:21 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Customizing the VW Tree Widget
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement
Supporting the new in tree view in BottomFeeder, I had to get the tree widget - the one holding the feeds and folders - to dynamically change based on attributes of the contained items. As it turns out, the tree widget already supports that quite easily - Have a look at class TreeModel. From the class comment:

childrenBlock:  block with one argument.  Is evaluated to get an
object's children.  The result is expected to be a
SequenceableCollection.  Defaults to: [:ea | ea children].

So the childrenBlock is what determines what the tree shows. Change the block, and you change the items displayed. In my case, I simply had to add query methods to the folder and feed objects. These methods look like this:

RSSFeed>>displayChildren
	"custom display of items"

	^#()


RSSFolder>>displayChildren
	"custom display of items"

	^self children select: [:each | each hasUnreadItems]

Feeds have no children; they are nodes. Folders, on the other hand have to be tested. The #hasUnreadItems method actually does the work of drilling all the way to the bottom of a given folder, in search of unread items. The main point is though - in order to change the way the tree displays, all I had to do is send this message in response to a user request:


	self feedTree list childrenBlock: [:each | each displayChildren].


which replaces the default block of:

	self feedTree list childrenBlock: [:each | each children]

And that's all there is to it. Modify the block that determines children to display, and create any necessary support protocol in the objects you put in the tree. I had been resisting looking at this, as I somehow convinced myself that doing this would be hard. I got constant prodding from Micahel Lucas-Smith though, and - as a result - got a new feature added to BottomFeeder

Read: Customizing the VW Tree Widget

Topic: PDC - not for non Softies? Previous Topic   Next Topic Topic: On becoming a student again

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use