com.sas.visuals
Class MenuBar

com.sas.visuals.MenuBar
All Implemented Interfaces:
ForwardedActionSource, ForwardedItemSource, MultipleValueEventSourceInterface, java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class MenuBar
implements ForwardedActionSource, ForwardedItemSource, java.awt.ItemSelectable, java.awt.event.ItemListener, java.awt.event.ActionListener, MultipleValueEventSourceInterface

MenuBar is a sub-class of java.awt.MenuBar that sends out events when any of the MenuItems on it are triggered. ForwardedActionEvents and ForwardedItemEvents are sent out. The individual MenuItems are also accessable from their ActionCommands using this MenuBar.

Notes:


See Also:
Serialized Form

Field Summary
protected  ForwardedActionListenerList forwardedActionListenerList
          Manages a list of listeners for ForwardedActionEvent
protected  ForwardedItemListenerList forwardedItemListenerList
          Manages a list of listeners for ForwardedItemEvent
protected  java.awt.event.ItemListener itemListenerList
          ItemListener that listens to Item events
 
Constructor Summary
MenuBar()
          Constructor, empty and no initializing
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Handles ActionEvents from the MenuItems on this MenuBar.
 java.awt.Menu add(java.awt.Menu m)
          Adds the specified menu to the menu bar.
 void addForwardedActionListener(ForwardedActionListener listener)
          Add an ForwardedActionListener to listen for ForwardedActionEvents on the MenuBar.
 void addForwardedItemListener(ForwardedItemListener listener)
          Adds a ForwardedItemListener to listen for ForwardedItemEvents on the BaseButton The events are sent whenever an ItemSelectable MenuItem component sends out an ForwardedItemEvent.
 void addItemListener(java.awt.event.ItemListener listener)
          Adds an ItemListener to listen for ForwardedItemEvents on the MenuBar.
 void addListeners(java.awt.MenuItem menuItem, boolean parseMenu)
          Adds event listeners needed to the given MenuItem.
 java.lang.reflect.Method getEventMethod(java.lang.reflect.Method lMethod)
          Gets the event method.
 java.lang.String[] getEventValues(java.lang.reflect.Method lMethod)
          Gets a string array of event values.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this MenuBar.
 java.awt.MenuItem[] getMenuItems(java.lang.String cmdStr)
          Get the MenuItems that have the specified actionCommand String.
 java.lang.Object[] getSelectedObjects()
          Here for compatibility with the java.awt.ItemSelectable interface.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          Handles ActionEvents from the ItemSelectable MenuItems on this MenuBar.
protected  java.util.Enumeration parseCommands(java.awt.Menu currentMenu)
          Parses the Menu to get and add action commands to an OrderedCollection, and returns enumeration of the action commands
protected  void parseMenu(java.awt.Menu currentMenu, boolean addListeners)
          Parses the Menu to add or remove the MenuBar as a listener to any events sent out by MenuItems on the given Menu.
protected  java.util.Enumeration parseMenuCommands(java.awt.Menu currentMenu, java.lang.String cmdStr)
          Parses a Menu to find any MenuItems that use the specified actionCommand String.
protected  void processForwardedActionEvent(ForwardedActionEvent e)
          Process ForwardedActionEvents sent from the MenuBar to its ForwardedActionListeners.
protected  void processForwardedItemEvent(ForwardedItemEvent e)
          Process ForwardedItemEvents sent from the MenuBar to its ForwardedItemListeners.
protected  void processItemEvent(java.awt.event.ItemEvent e)
          Process ItemEvents sent from the MenuBar to its ItemListeners.
 void removeForwardedActionListener(ForwardedActionListener listener)
          Removes a ForwardedActionListener from the list of listeners to be notified of ForwardedActionEvents.
 void removeForwardedItemListener(ForwardedItemListener listener)
          Removes a ForwardedItemListener from the list of listeners to be notified of an ForwardedItemEvent.
 void removeItemListener(java.awt.event.ItemListener listener)
          Removes an ItemListener from the list of listeners to be notified of ForwardedItemEvents.
 void removeListeners(java.awt.MenuItem menuItem, boolean parseMenu)
          Removes event listeners from the given MenuItem.
 void setMenuItemsEnabled(java.lang.String cmd, boolean enabled)
          Sets the MenuItems with the specified actionCommand to the given enabled state.
 boolean supportsListenerInterface(java.lang.Class listenerInterface)
          Indicates whether the listenerInterface class passed in is a ForwardedActionListener .
 void updateMenuItems()
          Parses all of the current MenuItems and add the MenuBar as a listener to any events that they send out.
 

Field Detail

itemListenerList

protected transient java.awt.event.ItemListener itemListenerList
ItemListener that listens to Item events


forwardedActionListenerList

protected transient ForwardedActionListenerList forwardedActionListenerList
Manages a list of listeners for ForwardedActionEvent


forwardedItemListenerList

protected transient ForwardedItemListenerList forwardedItemListenerList
Manages a list of listeners for ForwardedItemEvent

Constructor Detail

MenuBar

public MenuBar()
Constructor, empty and no initializing

Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this MenuBar.

Returns:
the ExtendedBeanInfo for this class

add

public java.awt.Menu add(java.awt.Menu m)
Adds the specified menu to the menu bar. Also parses the Menu and its items to add the MenuBar as an ActionListener and an ItemListener if possible. This allows the MenuBar to forward any menu events on to its listeners.

Overrides:
add in class java.awt.MenuBar

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Handles ActionEvents from the MenuItems on this MenuBar.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - the ActionEvent that occurred

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
Handles ActionEvents from the ItemSelectable MenuItems on this MenuBar.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
evt - the ItemEvent that changed

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Here for compatibility with the java.awt.ItemSelectable interface. Does nothing except return null

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Returns:
null

addForwardedActionListener

public void addForwardedActionListener(ForwardedActionListener listener)
Add an ForwardedActionListener to listen for ForwardedActionEvents on the MenuBar. The events are sent whenever a MenuItem component sends out an ActionEvent.

Specified by:
addForwardedActionListener in interface ForwardedActionSource
Parameters:
listener - the ForwardedActionListener to send the ForwardedActionEvents to.
See Also:
ForwardedActionEvent, ForwardedActionListener, removeForwardedActionListener(com.sas.visuals.ForwardedActionListener)

removeForwardedActionListener

public void removeForwardedActionListener(ForwardedActionListener listener)
Removes a ForwardedActionListener from the list of listeners to be notified of ForwardedActionEvents.

Specified by:
removeForwardedActionListener in interface ForwardedActionSource
Parameters:
listener - the ForwardedActionListener to stop sending the ForwardedActionEvents to.
See Also:
ForwardedActionEvent, ForwardedActionListener, addForwardedActionListener(com.sas.visuals.ForwardedActionListener)

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Adds an ItemListener to listen for ForwardedItemEvents on the MenuBar. ItemEvents sent out are a sub-class of ItemEvent, com.sas.visuals.ForwardedItemEvent. The events are sent whenever an ItemSelectable MenuItem component sends out an ItemEvent.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the ItemListener to send the ItemEvents to.
See Also:
ItemEvent, ItemListener, removeItemListener(java.awt.event.ItemListener)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Removes an ItemListener from the list of listeners to be notified of ForwardedItemEvents.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
listener - the ItemListener to stop sending the ItemEvents to.
See Also:
ItemEvent, ItemListener, addItemListener(java.awt.event.ItemListener)

addForwardedItemListener

public void addForwardedItemListener(ForwardedItemListener listener)
Adds a ForwardedItemListener to listen for ForwardedItemEvents on the BaseButton The events are sent whenever an ItemSelectable MenuItem component sends out an ForwardedItemEvent.

Specified by:
addForwardedItemListener in interface ForwardedItemSource
Parameters:
listener - the ForwardedItemListener to send the ItemEvents to.
See Also:
ForwardedItemEvent, ForwardedItemListener, removeForwardedItemListener(com.sas.visuals.ForwardedItemListener)

removeForwardedItemListener

public void removeForwardedItemListener(ForwardedItemListener listener)
Removes a ForwardedItemListener from the list of listeners to be notified of an ForwardedItemEvent.

Specified by:
removeForwardedItemListener in interface ForwardedItemSource
Parameters:
listener - the ForwardedItemListener to stop sending the ForwardedItemEvents to.
See Also:
ForwardedItemEvent, ForwardedItemListener, addForwardedItemListener(com.sas.visuals.ForwardedItemListener)

processForwardedActionEvent

protected void processForwardedActionEvent(ForwardedActionEvent e)
Process ForwardedActionEvents sent from the MenuBar to its ForwardedActionListeners.

Parameters:
e - the ForwardedActionEvent that needs to be processed

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent e)
Process ItemEvents sent from the MenuBar to its ItemListeners.

Parameters:
e - the ItemEvent that needs to be processed

processForwardedItemEvent

protected void processForwardedItemEvent(ForwardedItemEvent e)
Process ForwardedItemEvents sent from the MenuBar to its ForwardedItemListeners.

Parameters:
e - the ForwardedItemEvent that needs to be processed

getMenuItems

public java.awt.MenuItem[] getMenuItems(java.lang.String cmdStr)
Get the MenuItems that have the specified actionCommand String.

Parameters:
cmdStr - the actionCommand String of the MenuItems to return.
Returns:
an array of MenuItems containing the MenuItems that use the specified actionCommand String, or null if no MenuItems are found with the actionCommand String.

setMenuItemsEnabled

public void setMenuItemsEnabled(java.lang.String cmd,
                                boolean enabled)
Sets the MenuItems with the specified actionCommand to the given enabled state.

Parameters:
cmd - the actionCommand of the MenuItems to find
enabled - the new enabled state of the MenuItems found

parseMenuCommands

protected java.util.Enumeration parseMenuCommands(java.awt.Menu currentMenu,
                                                  java.lang.String cmdStr)
Parses a Menu to find any MenuItems that use the specified actionCommand String.

Parameters:
currentMenu - the Menu to parse for MenuItems with cmdStr for their actionCommand String.
cmdStr - the actionCommand String of the MenuItems to return or null to return all MenuItems.
Returns:
an Enumeration of the MenuItems with the specified actionCommand String on the given Menu.

updateMenuItems

public void updateMenuItems()
Parses all of the current MenuItems and add the MenuBar as a listener to any events that they send out.


parseMenu

protected void parseMenu(java.awt.Menu currentMenu,
                         boolean addListeners)
Parses the Menu to add or remove the MenuBar as a listener to any events sent out by MenuItems on the given Menu.

Parameters:
currentMenu - the Menu to add or remove the MenuBar as a listener to all of its MenuItems.
addListeners - if true, add the MenuBar as a listener to the MenuItems on this Menu, when false, remove the MenuBar as a listener to the MenuItems on this Menu.

removeListeners

public void removeListeners(java.awt.MenuItem menuItem,
                            boolean parseMenu)
Removes event listeners from the given MenuItem. Also remove listeners from all of its child MenuItems if it is a Menu instance and parseMenu is true.

Parameters:
menuItem - the MenuItem to remove the MenuBar as a listener.
parseMenu - if true and the menuItem is a Menu instance, remove the MenuBar as a listener from all sub-MenuItems

addListeners

public void addListeners(java.awt.MenuItem menuItem,
                         boolean parseMenu)
Adds event listeners needed to the given MenuItem. Also add listeners to all of its child MenuItems if it is a Menu instance and parseMenu is true.

Parameters:
menuItem - the MenuItem to add the MenuBar as a listener.
parseMenu - if true and the menuItem is a Menu instance, add the MenuBar as a listener to all sub-MenuItems

supportsListenerInterface

public boolean supportsListenerInterface(java.lang.Class listenerInterface)
Indicates whether the listenerInterface class passed in is a ForwardedActionListener .

Specified by:
supportsListenerInterface in interface MultipleValueEventSourceInterface
Parameters:
listenerInterface - the class to be tested
Returns:
true if listenerInterface is a ForwardedActionListener.

getEventMethod

public java.lang.reflect.Method getEventMethod(java.lang.reflect.Method lMethod)
Gets the event method.

Specified by:
getEventMethod in interface MultipleValueEventSourceInterface
Parameters:
IMethod - Method object to get the event method from
Returns:
a Method object if exists else returns null

getEventValues

public java.lang.String[] getEventValues(java.lang.reflect.Method lMethod)
Gets a string array of event values.

Specified by:
getEventValues in interface MultipleValueEventSourceInterface
Parameters:
IMethod - Method object to get the event values from
Returns:
a string array of event values

parseCommands

protected java.util.Enumeration parseCommands(java.awt.Menu currentMenu)
Parses the Menu to get and add action commands to an OrderedCollection, and returns enumeration of the action commands

Parameters:
currentMenu - the Menu to get and add action commands to the ordered collection
Returns:
an enumeration of the action commands from the Menu.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.