EchoPoint
1.0

echopoint
Class ExpandableMenu

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.Container
          extended byechopoint.EchoPointComponent
              extended byechopoint.ExpandableMenu
All Implemented Interfaces:
java.util.EventListener, nextapp.echo.event.HierarchyListener, MouseCursorable, ReflectionSetter, java.io.Serializable, ToolTipPopUpSupport, nextapp.echo.ToolTipSupport

public class ExpandableMenu
extends EchoPointComponent
implements nextapp.echo.event.HierarchyListener

The ExpandableMenu class provides a Component that shows a hierarchial menu of Component objects. These can then be expanded and collapsed, according to the parent-child hierarchy of the components.

The component works in "client side mode" only. It does not raise events on the server when Component are expanded or collapse.

However if you use Components such as Menu's,MenuItem's or Buttons you can add the usual ActionListeners in the usual manner, and hence be notified when they raise events.

Author:
Brad Baker
See Also:
Serialized Form

Nested Class Summary
static class ExpandableMenu.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static nextapp.echo.ImageReference defaultBlankLeafImage
          a blank image for an leaf menu
static nextapp.echo.ImageReference defaultBulletLeafImage
          a bullet image for an leaf menu
static nextapp.echo.ImageReference defaultCollapsedImage
          the default image for an collapsed menu
static nextapp.echo.ImageReference defaultExpandedImage
          the default image for an expanded menu
static java.lang.String IMAGES_CHANGED_PROPERTY
          image support component
static java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
          Tree Row Height
static java.lang.String STYLE_ROW_HEIGHT
          A style constant for the Row Height property.
 
Fields inherited from class echopoint.EchoPointComponent
STYLE_TOOL_TIP_TEXT, TOOL_TIP_TEXT_CHANGED_PROPERTY, toolTipPopUp
 
Fields inherited from class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopoint.positionable.MouseCursorable
borderStyleSymbolics, CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, STYLE_MOUSE_CURSOR, STYLE_MOUSE_CURSOR_URI
 
Constructor Summary
ExpandableMenu()
          ExpandableMenu constructor.
 
Method Summary
 void add(nextapp.echo.Component c)
          Adds a Component derived object to the ExpandableMenu.
 void add(nextapp.echo.Component c, int index)
          Adds a Component derived object to the ExpandableMenu.
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
 void collapseAll()
          Collapses all nodes in the ExpandableMenu
 void expandAll()
          Expand all nodes in the ExpandableMenu
 TreeCellRenderer getCellRender()
          Returns the cell renderer of the underlying tree component.
 nextapp.echo.ImageReference getCollapsedImage()
          Returns the icon to use for collapsed Menus (with children)
 nextapp.echo.ImageReference getExpandedImage()
          Returns the icon to use for expanded Menus (with children)
 nextapp.echo.ImageReference getLeafImage()
          Returns the icon to use for leaf Menus (ie they have no children)
 int getRowHeight()
          Returns the row height to be used for each row within the ExpandableMenu.
 void hierarchyChanged(nextapp.echo.event.HierarchyEvent e)
          Notifies the listener of a heirarchy change.
 void remove(nextapp.echo.Component c)
          Removes a Component from the ExpandableMenu.
 void remove(int index)
          Removes a Menu from the ExpandableMenu at the specified index.
 void removeAll()
          Removes all Menu under management.
 java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue)
          Called to save the old value of a field, set in a new value and return the old value of a field.
 void setCellRenderer(TreeCellRenderer cellRenderer)
          Sets the cell renderer of the underlying tree
 void setCollapsedImage(nextapp.echo.ImageReference newCollapsedImage)
          Sets the icon to use for collapsed Menus (with children)
 void setEnabled(boolean newValue)
           
 void setExpandedImage(nextapp.echo.ImageReference newExpandedImage)
          Sets the icon to use for expanded Menus (with children)
 void setLeafImage(nextapp.echo.ImageReference newLeafImage)
          Sets the icon to use for leaf Menus (ie they have no children)
 void setRowHeight(int newRowHeight)
          Sets the row height to be used for each row within the ExpandableMenu.
 void validate()
          Called just before the ExpandableMenu is to be rendered, to give it a chance to updates its internal state.
 
Methods inherited from class echopoint.EchoPointComponent
getMouseCursor, getMouseCursorURI, getToolTipPopUp, getToolTipText, set, set, set, set, set, set, set, set, set, setEnabledAllChildren, setMouseCursor, setMouseCursorURI, setToolTipText
 
Methods inherited from class nextapp.echo.Component
addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getLocale, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, removeHierarchyListener, removePropertyChangeListener, setBackground, setFont, setForeground, setIdentifier, setLocale, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROW_HEIGHT_CHANGED_PROPERTY

public static final java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
Tree Row Height

See Also:
Constant Field Values

STYLE_ROW_HEIGHT

public static final java.lang.String STYLE_ROW_HEIGHT
A style constant for the Row Height property. Values of this key must be of type int

See Also:
Constant Field Values

defaultExpandedImage

public static nextapp.echo.ImageReference defaultExpandedImage
the default image for an expanded menu


defaultCollapsedImage

public static nextapp.echo.ImageReference defaultCollapsedImage
the default image for an collapsed menu


defaultBlankLeafImage

public static nextapp.echo.ImageReference defaultBlankLeafImage
a blank image for an leaf menu


defaultBulletLeafImage

public static nextapp.echo.ImageReference defaultBulletLeafImage
a bullet image for an leaf menu


IMAGES_CHANGED_PROPERTY

public static final java.lang.String IMAGES_CHANGED_PROPERTY
image support component

See Also:
Constant Field Values
Constructor Detail

ExpandableMenu

public ExpandableMenu()
ExpandableMenu constructor.

Method Detail

add

public void add(nextapp.echo.Component c)
Adds a Component derived object to the ExpandableMenu.

This may or may not have child Component objects

Remember to add ActionListeners to the child components to ensure they can raise events.


add

public void add(nextapp.echo.Component c,
                int index)
Adds a Component derived object to the ExpandableMenu. at the specified index.

This may or may not have child Component objects.

Remember to add ActionListeners to the child components to ensure they can raise events.


applyStyle

public void applyStyle(nextapp.echo.Style style)
Applies the provided style to the component. The base nextapp.echo.Component style names can be used as well.

Specified by:
applyStyle in interface MouseCursorable
Overrides:
applyStyle in class EchoPointComponent
See Also:
Component.applyStyle(nextapp.echo.Style)

getCollapsedImage

public nextapp.echo.ImageReference getCollapsedImage()
Returns the icon to use for collapsed Menus (with children)

Returns:
nextapp.echo.ImageReference

getExpandedImage

public nextapp.echo.ImageReference getExpandedImage()
Returns the icon to use for expanded Menus (with children)

Returns:
nextapp.echo.ImageReference

getLeafImage

public nextapp.echo.ImageReference getLeafImage()
Returns the icon to use for leaf Menus (ie they have no children)

Returns:
nextapp.echo.ImageReference

getRowHeight

public int getRowHeight()
Returns the row height to be used for each row within the ExpandableMenu. If this value is 0 or less, then no row height will be used.

Returns:
int

hierarchyChanged

public void hierarchyChanged(nextapp.echo.event.HierarchyEvent e)
Notifies the listener of a heirarchy change.

Specified by:
hierarchyChanged in interface nextapp.echo.event.HierarchyListener
Parameters:
e - An HierarchyEvent describing the change.

remove

public void remove(int index)
Removes a Menu from the ExpandableMenu at the specified index.


remove

public void remove(nextapp.echo.Component c)
Removes a Component from the ExpandableMenu.


removeAll

public void removeAll()
Removes all Menu under management.


setCellRenderer

public void setCellRenderer(TreeCellRenderer cellRenderer)
Sets the cell renderer of the underlying tree

Parameters:
cellRenderer - - the new cell renderer

getCellRender

public TreeCellRenderer getCellRender()
Returns the cell renderer of the underlying tree component.

Returns:
the cell renderer of the underlying tree component.

setCollapsedImage

public void setCollapsedImage(nextapp.echo.ImageReference newCollapsedImage)
Sets the icon to use for collapsed Menus (with children)

Parameters:
newCollapsedImage - nextapp.echo.ImageReference

setExpandedImage

public void setExpandedImage(nextapp.echo.ImageReference newExpandedImage)
Sets the icon to use for expanded Menus (with children)

Parameters:
newExpandedImage - nextapp.echo.ImageReference

setLeafImage

public void setLeafImage(nextapp.echo.ImageReference newLeafImage)
Sets the icon to use for leaf Menus (ie they have no children)

Parameters:
newLeafImage - nextapp.echo.ImageReference

setRowHeight

public void setRowHeight(int newRowHeight)
Sets the row height to be used for each row within the ExpandableMenu. If this value is 0 or less, then no row height will be used.

Parameters:
newRowHeight - int

setEnabled

public void setEnabled(boolean newValue)
See Also:
Component.setEnabled(boolean)

expandAll

public void expandAll()
Expand all nodes in the ExpandableMenu


collapseAll

public void collapseAll()
Collapses all nodes in the ExpandableMenu


validate

public void validate()
Called just before the ExpandableMenu is to be rendered, to give it a chance to updates its internal state.

Overrides:
validate in class EchoPointComponent
See Also:
Component.validate()

set

public java.lang.Object set(java.lang.reflect.Field field,
                            java.lang.Object newValue)
                     throws java.lang.Exception
Description copied from interface: ReflectionSetter
Called to save the old value of a field, set in a new value and return the old value of a field. This interface allows a field set operation to be "delegated" back into the class that has permission to perform the field set.

 public Object set(Field f, Object newValue) throws Exception {
      Object oldValue = f.get(this);
      f.set(this,newValue);
      return oldValue;
 }
 

Specified by:
set in interface ReflectionSetter
Parameters:
field - - the field to be set
newValue - - the new value to be set
Returns:
the oldValue of the field
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0