initializeTree defines the root of the class hierarchy we will be displaying, the
Collection class, adds it to the tree view, and invokes
initializeSubTree to populate the tree view with subclasses of
Collection.
Return to the Composition Editor and connect the openedWidget event of the tree view to the
initializeTree script. Then, add icons to the tree view to improve its appearance. An icon will appear just before each text entry in the tree view. Open the settings of the tree view and set the
defaultGraphicsDescriptor property to be the icon at index 45 of
abtico40.dll.
abtCwTreeNode returns the
AbtCwTreeNode for a
ClassTreeNode and uses lazy initialization to set the value on the first reference.
initialize is invoked when a
ClassTreeNode is created and sets the
graphicsDescriptor attribute of the
AbtCwTreeNode to be a VA Smalltalk graphics descriptor representing the VA Smalltalk part through the
abtInstanceGraphicsDescriptor method. We defined
printString so that the text labels associated with each object in the tree view will be the class name. We did not do this previously because
Classes already have this behavior defined.
As you can see, we are now adding instances of ClassTreeNode to the tree view instead of the actual classes. The instances of
ClassTreeView contain references to the classes they represent as well as implement behavior that enables the display of unique icons for each class in the tree view. We've also changed the root class from
Collection to
AbtPart.
In addition to what we've seen, AbtCwTree nodes also allow you to specify menus for each entry in the tree view. This is useful for defining context menus specific to each object or each different type of object. You would then use the
clicked event of the menu buttons to invoke the selected action on the selected object.