edu.mit.ai.psg.ui.outliner.awt
Class OutlineTree

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--edu.mit.ai.psg.ui.outliner.awt.OutlineTree
Direct Known Subclasses:
ObjectOutline

public class OutlineTree
extends Panel
implements ActionListener

OutlineTree: Base component class for outline components which can expand or collapse to show their children. (Similar to trees in many UI toolkits, but elements can be labeled.)

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(ActionEvent) 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(PopupMenu), or by adding additional popup menu items specific to the derived outline by overriding method addPopupMenuItems(PopupMenu).

See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
OutlineTree(Component component)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
          ActionPerformed: Toggles whether tree is displayed expanded (showing children) or not (only showing root).
protected  void addImpl(Component comp, Object label, int index)
           
 void addPopupMenuItems(PopupMenu menu)
          Add popup menu items specific to this kind of outline, if any
 void addPopupMenuTitle(PopupMenu menu)
          Add a menu item identifying the object the popup menu is for.
 void doLayout()
           
 void generateChildren()
          GenerateChildren(): Subclasses may override this method with one which generates children.
 Component getChildComponent(int index)
           
 Component getChildLabel(int index)
           
 int getChildrenCount()
           
 Dimension getMinimumSize()
           
 Dimension getPreferredSize()
           
 Component getRootComponent()
           
 boolean hasChildren()
           
 void invalidateAndRepaintTree()
           
 boolean isExpanded()
           
 Component makeLabelComponent(String string)
           
 void setExpanded(boolean isExpanded)
           
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OutlineTree

public OutlineTree(Component component)
Method Detail

getRootComponent

public Component getRootComponent()

isExpanded

public boolean isExpanded()

setExpanded

public void setExpanded(boolean isExpanded)

hasChildren

public boolean hasChildren()

getChildrenCount

public int getChildrenCount()

getChildComponent

public Component getChildComponent(int index)

getChildLabel

public Component getChildLabel(int index)

generateChildren

public void generateChildren()
GenerateChildren(): Subclasses may override this method with one which generates children.

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));


makeLabelComponent

public Component makeLabelComponent(String string)

addPopupMenuTitle

public void addPopupMenuTitle(PopupMenu menu)
Add a menu item identifying the object the popup menu is for.

addPopupMenuItems

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

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)
.       } 
Specified by:
actionPerformed in interface ActionListener

invalidateAndRepaintTree

public void invalidateAndRepaintTree()

addImpl

protected void addImpl(Component comp,
                       Object label,
                       int index)
Overrides:
addImpl in class Container

doLayout

public void doLayout()
Overrides:
doLayout in class Container

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class Container

getMinimumSize

public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Container

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu