com.borland.primetime.actions
Class ActionMenu

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.AbstractButton
                          |
                          +--javax.swing.JMenuItem
                                |
                                +--javax.swing.JMenu
                                      |
                                      +--com.borland.primetime.actions.ActionMenu
All Implemented Interfaces:
javax.accessibility.Accessible, ActionWidget, DelegateHandler, java.util.EventListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, javax.swing.MenuElement, java.beans.PropertyChangeListener, java.io.Serializable, javax.swing.SwingConstants

public class ActionMenu
extends javax.swing.JMenu
implements ActionWidget, java.beans.PropertyChangeListener, DelegateHandler

The ActionMenu subclass of JMenu defines a physical menu that is dynamically built from the contents of the ActionGroup it is constructed with. As the menu is expanded, the sub-items are dynamically created on the fly to display the current hierarchy of the ActionGroup. Between each poping-up of the menu, the contents of the ActionGroup may completely change, and the ActionMenu will handle it. When an ActionMenu is about to be displayed, its contained Actions are scanned for instances of UpdateableAction, which are updated before the menu displays. When a menu item is clicked, the associated Action's actionPerformed method is called.

The ActionMenu instantiates UI widgets to represent Action objects on the fly - as the menu and submenus are popped-up. The following Action sub- types are displayed using the follwing widgets:

Action sub-type Attributes UI Widget
ActionGroup POPUP = true ActionMenu
ActionGroup POPUP = false (recurse between separators)
StateAction JMenuItem (special check)
Action JMenuItem

ActionMenus are constructed with a source Object and an ActionGroup to represent. The source Object will be passed as the source of the ActionEvent in the associated actions' actionPerformed methods. This allows an ActionMenu to pass a particular source object (not the menu or menuitems themselves), so the associated Actions can have direct access to a specific Object. This source is determined by the code that instantiates the ActionMenu.

In all cases, the SHORT_DESCRIPTION attribute is used for the text, the SMALL_ICON attribute is used for the icon (icons on/off with static 'showIcons' property), the MNEMONIC attribute is used for the mnemonic, and the ACCELLERATOR attribute is used for the accellerator.

See Also:
Action, ActionGroup, StateAction, UpdateableAction, Serialized Form

Inner classes inherited from class javax.swing.JMenu
javax.swing.JMenu.AccessibleJMenu, javax.swing.JMenu.WinListener
 
Inner classes inherited from class javax.swing.JMenuItem
javax.swing.JMenuItem.AccessibleJMenuItem
 
Inner classes inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  ActionGroup aGroup
           
protected  java.lang.Object source
           
 
Fields inherited from class javax.swing.JMenu
popupListener
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, 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
ActionMenu(java.lang.Object source, ActionGroup group)
          Constructs an ActionMenu with the specified source object and ActionGroup.
 
Method Summary
static void expandMenuGroup(java.lang.Object source, java.awt.Container container, ActionGroup group, boolean boldDefault)
           
 javax.swing.Action getAction()
          Returns the action (ActionGroup) for this ActionMenu.
 javax.swing.Action getAction(DelegateAction delegate)
          Returns the Action instance associated with the specified DelegateAction.
 ActionGroup getGroup()
          Returns the ActionGroup for this ActionMenu.
protected  java.awt.Point getPopupMenuOrigin()
          This is a hack workaround BTS #85237 where drop up can be off the screen and drop down can be under a task bar.
 java.lang.Object getSource()
          Returns the object source for this ActionMenu.
 void propertyChange(java.beans.PropertyChangeEvent e)
           
static boolean scanForIcons(java.awt.Container container)
           
static void stripIcons(java.awt.Container container)
           
static void stripMnemonics(java.awt.Container container)
           
static void useAltText(java.awt.Container container)
           
 
Methods inherited from class javax.swing.JMenu
add, add, add, add, add, addMenuListener, addSeparator, createActionChangeListener, createActionComponent, createWinListener, doClick, fireMenuCanceled, fireMenuDeselected, fireMenuSelected, getAccessibleContext, getComponent, getDelay, getItem, getItemCount, getMenuComponent, getMenuComponentCount, getMenuComponents, getPopupMenu, getSubElements, getUIClassID, insert, insert, insert, insertSeparator, isMenuComponent, isPopupMenuVisible, isSelected, isTearOff, isTopLevelMenu, menuSelectionChanged, paramString, processKeyEvent, remove, remove, remove, removeAll, removeMenuListener, setAccelerator, setDelay, setMenuLocation, setModel, setPopupMenuVisible, setSelected, updateUI
 
Methods inherited from class javax.swing.JMenuItem
addMenuDragMouseListener, addMenuKeyListener, configurePropertiesFromAction, createActionPropertyChangeListener, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, init, isArmed, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setArmed, setEnabled, setUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createChangeListener, createItemListener, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getDisabledIcon, getDisabledSelectedIcon, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getLabel, getMargin, getMnemonic, getModel, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isFocusTraversable, isRolloverEnabled, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setLabel, setMargin, setMnemonic, setMnemonic, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
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, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.MenuElement
processKeyEvent, processMouseEvent
 

Field Detail

source

protected java.lang.Object source

aGroup

protected ActionGroup aGroup
Constructor Detail

ActionMenu

public ActionMenu(java.lang.Object source,
                  ActionGroup group)
Constructs an ActionMenu with the specified source object and ActionGroup.
Parameters:
source - The source object
group - The action group
Method Detail

getAction

public javax.swing.Action getAction(DelegateAction delegate)
Description copied from interface: DelegateHandler
Returns the Action instance associated with the specified DelegateAction. If this DelegateHandler does not with to handle the specified DelegateAction, null should be returned.
Specified by:
getAction in interface DelegateHandler
Following copied from interface: com.borland.primetime.actions.DelegateHandler
Parameters:
delegate - The DelegateAction searching for a handler
Returns:
The Action to associate with the DelegateAction, or null if the specified DelegateAction is not to be handled by this DelegateHandler

getSource

public java.lang.Object getSource()
Returns the object source for this ActionMenu.
Specified by:
getSource in interface ActionWidget
Returns:
The source object

getAction

public javax.swing.Action getAction()
Returns the action (ActionGroup) for this ActionMenu.
Specified by:
getAction in interface ActionWidget
Overrides:
getAction in class javax.swing.AbstractButton
Returns:
The action group

getGroup

public ActionGroup getGroup()
Returns the ActionGroup for this ActionMenu.
Returns:
The ActionGroup

scanForIcons

public static boolean scanForIcons(java.awt.Container container)

stripIcons

public static void stripIcons(java.awt.Container container)

stripMnemonics

public static void stripMnemonics(java.awt.Container container)

useAltText

public static void useAltText(java.awt.Container container)

expandMenuGroup

public static void expandMenuGroup(java.lang.Object source,
                                   java.awt.Container container,
                                   ActionGroup group,
                                   boolean boldDefault)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getPopupMenuOrigin

protected java.awt.Point getPopupMenuOrigin()
This is a hack workaround BTS #85237 where drop up can be off the screen and drop down can be under a task bar.
Overrides:
getPopupMenuOrigin in class javax.swing.JMenu