[Newbies] [4.1] How do I use ToolBuilder to construct a three pane browser?

Hannes Hirzel hannes.hirzel at gmail.com
Mon Apr 19 15:15:51 UTC 2010


Bert

This was a very helpful learning experience.

Crucial is that lesson and section are the keys (strings) of the dictionaries.

Very neat that only a model class with the GUI code defined in one
method is needed.

Thank you!

Hannes

On 4/19/10, Hannes Hirzel <hannes.hirzel at gmail.com> wrote:
> Bert
> Thank you for this second mail. I actually was struggling with
> converting the 'lesson1', 'lesson2' etc back to the index.
>
> I had a method
>
> lessonListIndex: aLessonString
> 	lessonListIndex := self lessonList indexOf: aLessonString.
> 	self changed: #sectionList
>
> Your 'buildWith: builder' looks very need. So I'll go for that do not
> go for Integer indices.
>
> I'll try it - without looking at your solution :-)
>
> Hannes
>
> On 4/19/10, Bert Freudenberg <bert at freudenbergs.de> wrote:
>> On 19.04.2010, at 12:02, Bert Freudenberg wrote:
>>>
>>> On 19.04.2010, at 11:45, Hannes Hirzel wrote:
>>>>
>>>> Hello
>>>>
>>>> I would like to construct a three pane browser to inspect a dictionary
>>>> of dictionaries (see data structure example code below). How do I do
>>>> this using the ToolBuilder? I would like to learn to use it.
>>>
>>> Maybe look at Browser>>buildWith: or all the other buildWith:
>>> implementations? No need to subclass DictionaryInspector, I'd simply
>>> subclass Model.
>>>
>>> You would have two lists, and a text pane. Your model will have to
>>> provide
>>> methods to get the list and get/set the current index. E.g. #lessonList,
>>> #lessonListIndex, #lessonListIndex: and #sectionList, #sectionListIndex,
>>> #sectionListIndex:.
>>>
>>> When you select something in the lesson list, #lessonListIndex: will be
>>> sent. In response, you would send "self changed: #sectionList" which
>>> will
>>> cause the section list to be updated. Etc.
>>>
>>> - Bert -
>>
>> After actually having a look, Browser>>buildWith: etc. are already
>> specialized for code tools. No need for that.
>>
>> Also, for lists as in your case, working with indices for the selection
>> is
>> less convenient than with objects.
>>
>> So here's a build method for your model - just implement all the
>> accessors
>> and it works. A complete UI in one method ;)
>>
>> buildWith: builder
>> 	^builder build:
>> 		(builder pluggableWindowSpec new
>> 			model: self;
>> 			children: {
>> 				(builder pluggableListSpec new)
>> 					model: self;
>> 					list: #lessonList;
>> 					getSelected: #lesson;
>> 					setSelected: #lesson:;
>> 					frame: (0 at 0 corner: 0.5 at 0.2).
>> 				(builder pluggableListSpec new)
>> 					model: self;
>> 					list: #sectionList;
>> 					getSelected: #section;
>> 					setSelected: #section:;
>> 					frame: (0.5 at 0 corner: 1 at 0.2).
>> 				(builder pluggableTextSpec new)
>> 					model: self;
>> 					getText: #contents;
>> 					frame: (0 at 0.2 corner: 1 at 1).
>> 			})
>>
>>
>


More information about the Beginners mailing list