echopoint
Class ExpandableMenu

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

public class ExpandableMenu
extends EchoPointComponent
implements 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.

See Also:
Serialized Form

Nested Class Summary
static class ExpandableMenu.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static ImageReference defaultBlankLeafImage
          a blank image for an leaf menu
static ImageReference defaultBulletLeafImage
          a bullet image for an leaf menu
static ImageReference defaultCollapsedImage
          the default image for an collapsed menu
static 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 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
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
ExpandableMenu()
          ExpandableMenu constructor.
 
Method Summary
 void add(Component c)
          Adds a Component derived object to the ExpandableMenu.
 void add(Component c, int index)
          Adds a Component derived object to the ExpandableMenu.
 void applyStyle(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.
 ImageReference getCollapsedImage()
          Returns the icon to use for collapsed Menus (with children)
 ImageReference getExpandedImage()
          Returns the icon to use for expanded Menus (with children)
 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(HierarchyEvent e)
          Notifies the listener of a heirarchy change.
 void remove(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(ImageReference newCollapsedImage)
          Sets the icon to use for collapsed Menus (with children)
 void setEnabled(boolean newValue)
          Sets whether the component is enabled.
 void setExpandedImage(ImageReference newExpandedImage)
          Sets the icon to use for expanded Menus (with children)
 void setLeafImage(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.AbstractComponent
addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, 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 ImageReference defaultExpandedImage
the default image for an expanded menu


defaultCollapsedImage

public static ImageReference defaultCollapsedImage
the default image for an collapsed menu


defaultBlankLeafImage

public static ImageReference defaultBlankLeafImage
a blank image for an leaf menu


defaultBulletLeafImage

public static 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(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.

Specified by:
add in interface Component
Overrides:
add in class AbstractComponent
Parameters:
c - The child component to add.

add

public void add(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.

Specified by:
add in interface Component
Overrides:
add in class AbstractComponent
Parameters:
c - The child component to add.
index - The index at which to add the child component, or -1 to add the component at the end.

applyStyle

public void applyStyle(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
Specified by:
applyStyle in interface Component
Overrides:
applyStyle in class EchoPointComponent
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(nextapp.echo.Style)

getCollapsedImage

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

Returns:
nextapp.echo.ImageReference

getExpandedImage

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

Returns:
nextapp.echo.ImageReference

getLeafImage

public 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(HierarchyEvent e)
Notifies the listener of a heirarchy change.

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

remove

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

Specified by:
remove in interface Component
Overrides:
remove in class AbstractComponent
Parameters:
index - The index of the child component to remove.

remove

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

Specified by:
remove in interface Component
Overrides:
remove in class AbstractComponent
Parameters:
c - The child component to remove.

removeAll

public void removeAll()
Removes all Menu under management.

Specified by:
removeAll in interface Component
Overrides:
removeAll in class AbstractComponent

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(ImageReference newCollapsedImage)
Sets the icon to use for collapsed Menus (with children)

Parameters:
newCollapsedImage - nextapp.echo.ImageReference

setExpandedImage

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

Parameters:
newExpandedImage - nextapp.echo.ImageReference

setLeafImage

public void setLeafImage(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)
Description copied from interface: Component
Sets whether the component is enabled.

Specified by:
setEnabled in interface Component
Overrides:
setEnabled in class AbstractComponent
Parameters:
newValue - True if the component is enabled.
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.

Specified by:
validate in interface Component
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.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.NullPointerException
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)