jfreerails.client.common
Class ActionAdapter

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultComboBoxModel
          extended by jfreerails.client.common.ActionAdapter
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel

public class ActionAdapter
extends javax.swing.DefaultComboBoxModel

Provides a mapping from a set of ButtonModels or a ComboBoxModel to a set of Actions. To use with a set of buttons, call elements() to obtain the set of ButtonModels to apply to the buttons, and add each button in the enumeration to a ButtonGroup. Listeners should listen for changes to the model and not to any events from UI components, although UI components may call setAction() in order to receive property change updates and to set icons etc.

Author:
Rob
See Also:
Serialized Form

Nested Class Summary
 class ActionAdapter.MappedButtonModel
           
 
Field Summary
private  javax.swing.Action[] actions
          The set of actions which each button / menu item correspond to.
private  java.util.Vector<ActionAdapter.MappedButtonModel> buttonModels
          The set of MappedButtonModels corresponding to the actions.
private  boolean initialised
           
private  boolean performActionOnSetSelectedItem
           
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ActionAdapter(javax.swing.Action[] actions)
          An array of the actions to be used.
ActionAdapter(javax.swing.Action[] actions, int selected)
           
 
Method Summary
 java.util.Enumeration<javax.swing.Action> getActions()
           
 java.util.Enumeration<ActionAdapter.MappedButtonModel> getButtonModels()
           
 void setPerformActionOnSetSelectedItem(boolean performActionOnSetSelectedItem)
           
 void setSelectedItem(java.lang.Object item)
           
 
Methods inherited from class javax.swing.DefaultComboBoxModel
addElement, getElementAt, getIndexOf, getSelectedItem, getSize, insertElementAt, removeAllElements, removeElement, removeElementAt
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

actions

private final javax.swing.Action[] actions
The set of actions which each button / menu item correspond to.


initialised

private boolean initialised

performActionOnSetSelectedItem

private boolean performActionOnSetSelectedItem

buttonModels

private final java.util.Vector<ActionAdapter.MappedButtonModel> buttonModels
The set of MappedButtonModels corresponding to the actions.

Constructor Detail

ActionAdapter

public ActionAdapter(javax.swing.Action[] actions)
An array of the actions to be used. The ComboBoxModel objects are taken from the NAME property of the Action. The ButtonModel icons are obtained from the SMALL_ICON property.


ActionAdapter

public ActionAdapter(javax.swing.Action[] actions,
                     int selected)
Parameters:
actions - An array of the actions to be used. The ComboBoxModel objects are taken from the NAME property of the Action. The ButtonModel icons are obtained from the SMALL_ICON property.
selected - Index of the default selected action.
Method Detail

getActions

public java.util.Enumeration<javax.swing.Action> getActions()
Returns:
an enumeration of Action

getButtonModels

public java.util.Enumeration<ActionAdapter.MappedButtonModel> getButtonModels()
Returns:
an enumeration of MappedButtonModel

setSelectedItem

public void setSelectedItem(java.lang.Object item)
Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Overrides:
setSelectedItem in class javax.swing.DefaultComboBoxModel
Parameters:
item - The NAME of the Action selected

setPerformActionOnSetSelectedItem

public void setPerformActionOnSetSelectedItem(boolean performActionOnSetSelectedItem)