All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.mit.ai.psg.ui.outlines.OutlineTree

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----edu.mit.ai.psg.ui.outlines.OutlineTree

public class OutlineTree
extends Panel
implements ActionListener
OutlineTree: Base component class for outline components which can expand or collapse to show their children.

See method generateChildren() for instructions on how to add children.

Derived classes may tailor the behavior to generate children when item is expanded. See method actionPerformed() for how to do this.

Derived classes may tailor the popup menu provided with for their instances by adding an appropriate title string identifying the moused object at the top of its pop-up menu by overriding method addPopupMenuTitle(), or by adding additional popup menu items specific to the derived outline by overriding method addPopupMenuItems().

Author:
CarlManning, caroma@ai.mit.edu
Copyright (c) 1997, 1998 Massachusetts Institute of Technology

Constructor Index

 o OutlineTree(Component)

Method Index

 o actionPerformed(ActionEvent)
ActionPerformed: Toggles whether tree is displayed expanded (showing children) or not (only showing root).
 o addImpl(Component, Object, int)
 o addPopupMenuItems(PopupMenu)
Add popup menu items specific to this kind of outline, if any
 o addPopupMenuTitle(PopupMenu)
Add a menu item identifying the object the popup menu is for.
 o doLayout()
 o generateChildren()
GenerateChildren(): Subclasses may override this method with one which generates children.
 o getMinimumSize()
 o getPreferredSize()
 o getRootComponent()
 o hasChildren()
 o invalidateAndRepaintTree()
 o isExpanded()
 o makeLabelComponent(String)
 o setExpanded(boolean)

Constructors

 o OutlineTree
 public OutlineTree(Component component)

Methods

 o getRootComponent
 public Component getRootComponent()
 o isExpanded
 public boolean isExpanded()
 o setExpanded
 public void setExpanded(boolean isExpanded)
 o hasChildren
 public boolean hasChildren()
 o generateChildren
 public void generateChildren()
GenerateChildren(): Subclasses may override this method with one which generates children. This method removes parent's open/close button if this has no children. Overriding methods may call super.generateChildren() after all children have been generated if they want button removed in the no child case.

To add children, for each child, call this from subclass method:

.       this.add(Outliner.makeOutlineComponent(childObject),
.                makeLabelComponent("childLabel"));
Or if children are not labeled, then call this instead:
.       this.add(Outliner.makeOutlineComponent(obj));

 o makeLabelComponent
 public Component makeLabelComponent(String string)
 o addPopupMenuTitle
 public void addPopupMenuTitle(PopupMenu menu)
Add a menu item identifying the object the popup menu is for.

 o addPopupMenuItems
 public void addPopupMenuItems(PopupMenu menu)
Add popup menu items specific to this kind of outline, if any

 o actionPerformed
 public void actionPerformed(ActionEvent e)
ActionPerformed: Toggles whether tree is displayed expanded (showing children) or not (only showing root). If you want to generate children when opened, override the method with something like:
      
.       public void actionPerformed(ActionEvent e) {
.         if (! isExpanded() && ! hasChildren())
.            generateChildren();
.         super.actionPerformed(e)
.       } 

 o invalidateAndRepaintTree
 public void invalidateAndRepaintTree()
 o addImpl
 public void addImpl(Component comp,
                     Object label,
                     int index)
Overrides:
addImpl in class Container
 o doLayout
 public void doLayout()
Overrides:
doLayout in class Container
 o getPreferredSize
 public Dimension getPreferredSize()
Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Container

All Packages  Class Hierarchy  This Package  Previous  Next  Index