ptolemy.vergil.toolbox
Class RadioMenuActionFactory

java.lang.Object
  extended by ptolemy.vergil.toolbox.MenuActionFactory
      extended by ptolemy.vergil.toolbox.RadioMenuActionFactory
All Implemented Interfaces:
MenuItemFactory

public class RadioMenuActionFactory
extends MenuActionFactory

A factory that adds a given action or set of actions as radio selections to a context menu. All the actions created by an instance of this factory are in the same group. Selecting one item in a group causes the currently selected item in the same group unselected, if it is not the same as the newly selected one. If an array of actions is given to the constructor, then the actions will be put in a submenu with the specified label.

Since:
Ptolemy II 8.0
Version:
$Id: RadioMenuActionFactory.java 57044 2010-01-27 22:41:05Z cxh $
Author:
Thomas Huining Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Field Summary
private  javax.swing.ButtonGroup _group
          The group that contains all the actions for this factory.
 
Constructor Summary
RadioMenuActionFactory(javax.swing.Action action)
          Construct a factory that adds a given action as a radio selection to a given context menu.
RadioMenuActionFactory(javax.swing.Action[] actions, java.lang.String label)
          Construct a factory that adds a given group of actions as radio selections to a given context menu in a submenu with the specified label.
 
Method Summary
protected  javax.swing.JMenuItem _add(JContextMenu menu, javax.swing.Action action, java.lang.String tooltip)
          Add an action to the context menu.
protected  javax.swing.JMenuItem _add(javax.swing.JMenu submenu, javax.swing.Action action)
          Add an action to the submenu.
 javax.swing.JMenuItem create(JContextMenu menu, NamedObj object)
          Add an item to the given context menu that will configure the parameters on the given target.
 
Methods inherited from class ptolemy.vergil.toolbox.MenuActionFactory
addAction, addAction, addActions, addMenuItemListener, substitute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_group

private javax.swing.ButtonGroup _group
The group that contains all the actions for this factory.

Constructor Detail

RadioMenuActionFactory

public RadioMenuActionFactory(javax.swing.Action action)
Construct a factory that adds a given action as a radio selection to a given context menu.

Parameters:
action - The action to be associated with the context menu.

RadioMenuActionFactory

public RadioMenuActionFactory(javax.swing.Action[] actions,
                              java.lang.String label)
Construct a factory that adds a given group of actions as radio selections to a given context menu in a submenu with the specified label.

Parameters:
actions - The actions to be in the submenu.
label - The label for the submenu.
Method Detail

create

public javax.swing.JMenuItem create(JContextMenu menu,
                                    NamedObj object)
Add an item to the given context menu that will configure the parameters on the given target.

Specified by:
create in interface MenuItemFactory
Overrides:
create in class MenuActionFactory
Parameters:
menu - The context menu to add to.
object - The object that the menu item command will operate on.
Returns:
A menu item, or null to decline to provide a menu item.

_add

protected javax.swing.JMenuItem _add(JContextMenu menu,
                                     javax.swing.Action action,
                                     java.lang.String tooltip)
Add an action to the context menu.

Overrides:
_add in class MenuActionFactory
Parameters:
menu - The context menu.
action - The action to be added to the context menu.
tooltip - The tooltip for the action.
Returns:
The added menu item.

_add

protected javax.swing.JMenuItem _add(javax.swing.JMenu submenu,
                                     javax.swing.Action action)
Add an action to the submenu.

Overrides:
_add in class MenuActionFactory
Parameters:
submenu - The submenu.
action - The action to be added to the submenu.
Returns:
The added menu item.