edu.neu.ccs.gui
Class ActionsPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byedu.neu.ccs.gui.DisplayPanel
                      extended byedu.neu.ccs.gui.ActionsPanel
All Implemented Interfaces:
Accessible, AlertListener, Displayable, EventListener, ImageObserver, JPTConstants, MalformedDataListener, MenuContainer, Serializable, SwingConstants

public class ActionsPanel
extends DisplayPanel

A panel containing Action objects represented by buttons that initiate their respective actions. Aspects of the action's user interface representation, for example, the button's label or icon, are extracted from the properties of the action object and updated if the properties of the action object are later changed.

An actions panel is designed to drive a GUI by containing buttons that cause actions to be performed by the program that makes use of the graphical interface.

The functionality of the ActionsPanel class is based on the functionality of Java JToolBar class. An ActionsPanel may be added to a JToolBar in order to make use of its floating and docking functionality.

Since:
1.0
Version:
2.2
See Also:
Action, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  Hashtable map
          Maps actions to their automatically created buttons, and vice-versa.
 
Fields inherited from class edu.neu.ccs.gui.DisplayPanel
background, codec, CODEC
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface edu.neu.ccs.gui.Displayable
DEFAULT_VIEW_STATE, VIEW_STATE
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ActionsPanel()
          Constructs an actions panel that contains no actions and uses the default layout manager for a JPanel.
ActionsPanel(Action[] actions)
          Constructs an actions panel that contains the given actions and uses the default layout manager for a JPanel.
ActionsPanel(Action[] actions, LayoutManager layout)
          Constructs an actions panel that contains the given actions and uses the given layout manager.
ActionsPanel(Action[] actions, Object[] constraints, LayoutManager layout)
          Constructs an actions panel that contains the given actions and uses the given layout manager with the given constraints.
ActionsPanel(LayoutManager layout)
          Constructs an actions panel that contains no actions and uses the given layout manager.
 
Method Summary
 JButton addAction(Action action)
          Adds the given action to the ActionsPanel by creating a JButton that, when clicked, will cause the performance of the given action.
 JButton addAction(Action action, Object constraint)
          Adds the given action to the ActionsPanel with the given layout constraint.
 JButton[] addActions(Action[] actions)
          Adds the given array of actions to this ActionsPanel by creating JButtons that, when clicked, will cause the performance of the corresponding action.
 JButton[] addActions(Action[] actions, Object[] constraints)
          Adds the given actions to this ActionsPanel with the given layout constraints.
 Action findMatchedAction(Action action)
          Returns the base action in this ActionsPanel that represents the given action, or null if there is no such base action.
 Action findMatchedAction(String name)
          Returns the first action in this ActionsPanel whose NAME property is equal to the given name.
 JButton findMatchedButton(Action action)
          Returns the button in this ActionsPanel associated with the base action for the given action, or null if there is no such button.
 JButton findMatchedButton(String name)
          Returns the button in this ActionsPanel associated with the first action found in this panel whose NAME property is equal to the given name.
 Action getAction(JButton button)
          Returns the action in this ActionsPanel corresponding with the given button, or null if the given button is null or not in this panel.
 JButton[] getActionButtons()
          Returns an array containing the buttons in this ActionsPanel created as a result of addAction or addActions.
 Action[] getActions()
          Returns an array containing the actions in this ActionsPanel.
 JButton getButton(Action action)
          Returns the button in this ActionsPanel corresponding with the given action, or null if the given action is null or not in this panel.
static Icon getIcon(Action action)
          Returns the icon (SMALL_ICON) associated with the given action.
static String getText(Action action)
          Returns the text (NAME) associated with the given action.
static String getToolTipText(Action action)
          Returns the tool tip text (SHORT_DESCRIPTION) associated with the given action.
 void setDefaultButton(Action action)
          Sets the button associated with the given action to be the default button for the root pane containing this ActionsPanel if this panel has a root pane parent, and the given button is in this panel.
 void setDefaultButton(JButton button)
          Sets the given button to be the default button for the root pane containing this ActionsPanel if this panel has a root pane parent, and the given button is in this panel.
 void setDefaultButton(String name)
          Sets the button associated with the first action found in this ActionsPanel whose NAME property is equal to the given name to be the default button for the root pane containing this ActionsPanel if this panel has a root pane parent, and the given button is in this panel.
static void setIcon(Action action, Icon icon)
          Sets the icon (SMALL_ICON) associated with the given action to the given icon.
static void setText(Action action, String text)
          Sets the text (NAME) associated with the given action to the given text.
static void setToolTipText(Action action, String text)
          Sets the tool tip text (SHORT_DESCRIPTION) associated with the given action to the given text.
 
Methods inherited from class edu.neu.ccs.gui.DisplayPanel
add, add, add, add, add, addBorder, addObject, addObject, addObject, addObject, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderLowered, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, bevelBorderRaised, compoundBorder, compoundBorder, dataMalformed, emptyBorder, emptyBorder, emptyBorder, endAlert, etchBorderLowered, etchBorderLowered, etchBorderLowered, etchBorderRaised, etchBorderRaised, etchBorderRaised, frame, frame, frame, frame, frame, frame, generalDialog, generalDialog, generalDialog, generalDialog, getCodec, getDefaultViewState, getDefaultViewStates, getDisplayables, getViewState, getViewStates, lineBorder, lineBorder, lineBorder, lineBorder, makeComponent, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, matteBorder, OKCancelDialog, OKCancelDialog, OKDialog, OKDialog, refreshComponent, remove, remove, removeAll, removeBorder, reset, sandwichBorder, setCodec, setDeepBackground, setDeepBackground, setDefaultViewState, setDefaultViewStates, setEnabled, setViewState, setViewStates, startAlert, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, titleBorder, uniformizeHeight, uniformizeSize, uniformizeWidth, YesNoCancelDialog, YesNoCancelDialog
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

private Hashtable map
Maps actions to their automatically created buttons, and vice-versa.

Constructor Detail

ActionsPanel

public ActionsPanel()
Constructs an actions panel that contains no actions and uses the default layout manager for a JPanel.

See Also:
ActionsPanel(LayoutManager), ActionsPanel(Action[]), ActionsPanel(Action[], LayoutManager), ActionsPanel(Action[], Object[], LayoutManager)

ActionsPanel

public ActionsPanel(LayoutManager layout)
Constructs an actions panel that contains no actions and uses the given layout manager. If the given layout manager is null, the default layout manager for a JPanel is used.

Parameters:
layout - the desired layout manager for the panel
See Also:
ActionsPanel(), ActionsPanel(Action[]), ActionsPanel(Action[], LayoutManager), ActionsPanel(Action[], Object[], LayoutManager)

ActionsPanel

public ActionsPanel(Action[] actions)
Constructs an actions panel that contains the given actions and uses the default layout manager for a JPanel. If the given array of actions is null, no actions are added to the panel.

Parameters:
actions - the actions to be added to the panel
See Also:
ActionsPanel(), ActionsPanel(LayoutManager), ActionsPanel(Action[], LayoutManager), ActionsPanel(Action[], Object[], LayoutManager)

ActionsPanel

public ActionsPanel(Action[] actions,
                    LayoutManager layout)
Constructs an actions panel that contains the given actions and uses the given layout manager. If the given array of actions is null, no actions are added to the panel. If the given layout manager is null, the default layout manager for a JPanel is used.

Parameters:
actions - the actions to be added to the panel
layout - the desired layout manager for the panel
See Also:
ActionsPanel(), ActionsPanel(LayoutManager), ActionsPanel(Action[]), ActionsPanel(Action[], Object[], LayoutManager)

ActionsPanel

public ActionsPanel(Action[] actions,
                    Object[] constraints,
                    LayoutManager layout)
Constructs an actions panel that contains the given actions and uses the given layout manager with the given constraints. If the given array of actions is null, no actions are added to the panel. If the given layout manager is null, the default layout manager for a JPanel is used.

Parameters:
actions - the actions to be added to the panel
constraints - the layout constraints for the button
layout - the desired layout manager for the panel
Since:
1.2
See Also:
ActionsPanel(), ActionsPanel(LayoutManager), ActionsPanel(Action[]), ActionsPanel(Action[], LayoutManager)
Method Detail

addAction

public JButton addAction(Action action)
Adds the given action to the ActionsPanel by creating a JButton that, when clicked, will cause the performance of the given action.

Parameters:
action - the action to be added to the panel
Returns:
the created button that causes the action to be performed
See Also:
addAction(Action, Object), addActions(Action[]), addActions(Action[], Object[])

addAction

public JButton addAction(Action action,
                         Object constraint)
Adds the given action to the ActionsPanel with the given layout constraint.

Parameters:
action - the action to be added to the panel
constraint - the layout constraint for the button
Returns:
the created button that causes the action to be performed
See Also:
addAction(Action), addActions(Action[]), addActions(Action[], Object[])

addActions

public JButton[] addActions(Action[] actions)
Adds the given array of actions to this ActionsPanel by creating JButtons that, when clicked, will cause the performance of the corresponding action.

Parameters:
actions - the actions to be added to the panel
Returns:
the created buttons that causes the actions to be performed
Since:
1.2
See Also:
addAction(Action), addAction(Action, Object), addActions(Action[], Object[])

addActions

public JButton[] addActions(Action[] actions,
                            Object[] constraints)
Adds the given actions to this ActionsPanel with the given layout constraints.

Parameters:
actions - the action to be added to the panel
constraints - the layout constraints for the button
Returns:
the created buttons that causes the actions to be performed
Since:
1.2
See Also:
addAction(Action), addAction(Action, Object), addActions(Action[])

getAction

public Action getAction(JButton button)
Returns the action in this ActionsPanel corresponding with the given button, or null if the given button is null or not in this panel.

Parameters:
button - the button whose action is desired
Returns:
the action corresponding to the button
Since:
1.2
See Also:
getButton(Action), getActions(), getActionButtons()

getButton

public JButton getButton(Action action)
Returns the button in this ActionsPanel corresponding with the given action, or null if the given action is null or not in this panel.

Parameters:
action - the action whose button is desired
Returns:
the button corresponding to the action
Since:
1.2
See Also:
getAction(JButton), getActions(), getActionButtons()

getActions

public Action[] getActions()
Returns an array containing the actions in this ActionsPanel.

Since:
1.1
See Also:
getAction(JButton), getButton(Action), getActionButtons()

getActionButtons

public JButton[] getActionButtons()
Returns an array containing the buttons in this ActionsPanel created as a result of addAction or addActions.

Since:
1.1
See Also:
getAction(JButton), getButton(Action), getActions()

findMatchedAction

public Action findMatchedAction(Action action)
Returns the base action in this ActionsPanel that represents the given action, or null if there is no such base action. If the given action is itself in this panel, the given action is returned.

Parameters:
action - the action that we seek to match in the panel
Since:
2.0
See Also:
findMatchedButton(Action), ActionWrapper.getBaseAction(Action)

findMatchedButton

public JButton findMatchedButton(Action action)
Returns the button in this ActionsPanel associated with the base action for the given action, or null if there is no such button.

Parameters:
action - the action that we seek to match in the panel
Since:
2.0
See Also:
findMatchedAction(Action), ActionWrapper.getBaseAction(Action)

findMatchedAction

public Action findMatchedAction(String name)
Returns the first action in this ActionsPanel whose NAME property is equal to the given name.

Parameters:
name - the name that we seek to match in the panel
Since:
2.0
See Also:
findMatchedButton(String)

findMatchedButton

public JButton findMatchedButton(String name)
Returns the button in this ActionsPanel associated with the first action found in this panel whose NAME property is equal to the given name.

Parameters:
name - the name that we seek to match in the panel
Since:
2.0
See Also:
findMatchedAction(String)

setDefaultButton

public void setDefaultButton(JButton button)
Sets the given button to be the default button for the root pane containing this ActionsPanel if this panel has a root pane parent, and the given button is in this panel.

Parameters:
button - the button to install as the default button
Since:
2.0
See Also:
setDefaultButton(Action), setDefaultButton(String)

setDefaultButton

public void setDefaultButton(Action action)
Sets the button associated with the given action to be the default button for the root pane containing this ActionsPanel if this panel has a root pane parent, and the given button is in this panel.

Parameters:
action - the action whose matched button will be the default button
Since:
2.0
See Also:
setDefaultButton(JButton), setDefaultButton(String)

setDefaultButton

public void setDefaultButton(String name)
Sets the button associated with the first action found in this ActionsPanel whose NAME property is equal to the given name to be the default button for the root pane containing this ActionsPanel if this panel has a root pane parent, and the given button is in this panel.

Parameters:
name - the name whose matched button will be the default button
See Also:
setDefaultButton(JButton), setDefaultButton(Action)

setText

public static void setText(Action action,
                           String text)
Sets the text (NAME) associated with the given action to the given text.

Parameters:
action - the action to modify
text - the text to set
Since:
1.2
See Also:
getText(Action), setIcon(Action, Icon), setToolTipText(Action, String), getIcon(Action), getToolTipText(Action), Action.NAME

setIcon

public static void setIcon(Action action,
                           Icon icon)
Sets the icon (SMALL_ICON) associated with the given action to the given icon.

Parameters:
action - the action to modify
icon - the icon to set
Since:
1.2
See Also:
getIcon(Action), setText(Action, String), setToolTipText(Action, String), getText(Action), getToolTipText(Action), Action.SMALL_ICON

setToolTipText

public static void setToolTipText(Action action,
                                  String text)
Sets the tool tip text (SHORT_DESCRIPTION) associated with the given action to the given text.

Parameters:
action - the action to modify
text - the tool tip text to set
Since:
1.2
See Also:
getToolTipText(Action), setText(Action, String), setIcon(Action, Icon), getText(Action), getIcon(Action), Action.SHORT_DESCRIPTION

getText

public static String getText(Action action)
Returns the text (NAME) associated with the given action. If the given action is null, the NAME property is not set, or it is not set to a String, this method returns null.

Parameters:
action - the action to query
Since:
2.0
See Also:
setText(Action, String), getIcon(Action), getToolTipText(Action), setIcon(Action, Icon), setToolTipText(Action, String), Action.NAME

getIcon

public static Icon getIcon(Action action)
Returns the icon (SMALL_ICON) associated with the given action. If the given action is null, the SMALL_ICON property is not set, or it is not set to an Icon, this method returns null.

Parameters:
action - the action to query
Since:
2.0
See Also:
setIcon(Action, Icon), getText(Action), getToolTipText(Action), setText(Action, String), setToolTipText(Action, String), Action.SMALL_ICON

getToolTipText

public static String getToolTipText(Action action)
Returns the tool tip text (SHORT_DESCRIPTION) associated with the given action. If the given action is null, the SHORT_DESCRIPTION property is not set, or it is not set to a String, this method returns null.

Parameters:
action - the action to query
Since:
2.0
See Also:
setToolTipText(Action, String), getText(Action), getIcon(Action), setText(Action, String), setIcon(Action, Icon), Action.SHORT_DESCRIPTION