edu.wisc.ssec.mcidasv.ui
Class McvToolbarEditor

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.ui.McvToolbarEditor
All Implemented Interfaces:
ActionListener, EventListener

public class McvToolbarEditor
extends Object
implements ActionListener


Nested Class Summary
private static class McvToolbarEditor.IconCellRenderer
          Renders a toolbar action and its icon within the TwoListPanel's JLists.
private static class McvToolbarEditor.SpaceIcon
          SpaceIcon is a class that represents a "space" entry in the TwoListPanel that holds the current toolbar actions.
 
Field Summary
private static String CMD_ADDSPACE
          Add a "space" entry
private static String CMD_EXPORTMENUPLUGIN
          action command
private static String CMD_EXPORTPLUGIN
          action command
private static String CMD_RELOAD
          Action command for reloading the toolbar list with original items
private  JComponent contents
          All of the toolbar editor's GUI components.
protected static int ICON_SIZE
          Size of the icons to be shown in the TwoListPanel.
private static String MENU_PLUGINEXPORT
           
private  JComboBox menuIdBox
          Used to export toolbars to plugin.
private  JTextField menuNameFld
          Used to export toolbars to plugin.
private  JCheckBox menuOverwriteCbx
          Used to export toolbars to plugin.
private static String MSG_ENTER_NAME
           
private static String MSG_SELECT_ENTRIES
           
(package private)  XmlResourceCollection resources
          The toolbar XML resources.
private static String SPACE
          ID that represents a "space" in the toolbar.
private  int spaceCount
          Provides simple IDs for the space entries.
private static String TT_EXPORT_SELECT
           
private static String TT_EXPORT_SELECTMENU
           
private static String TT_OVERWRITE
           
private  TwoListPanel twoListPanel
          The GUI component that stores both available and selected actions.
private  UIManager uiManager
          Used to notify the application that a toolbar update should occur.
 
Constructor Summary
McvToolbarEditor(UIManager mngr)
          Builds a toolbar editor and associates it with the UIManager.
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Handles events such as exporting plugins, reloading contents, and adding spaces.
 boolean anyChanges()
          Has twoListPanel been changed?
 void doApply()
          Writes out the toolbar xml.
private  void doExport(Object[] tfos)
          Export the actions
private  void doExportToMenu(Object[] tfos)
          Export the selected actions as a menu to the plugin manager.
protected  Icon getActionIcon(String actionId)
          Returns the icon associated with actionId.
private  List<TwoFacedObject> getAllActions()
          Returns a List of TwoFacedObjects containing all of the actions known to McIDAS-V.
 JComponent getContents()
          Returns the JComponent that contains all of the toolbar editor's UI components.
private  List<TwoFacedObject> getCurrentToolbar()
           
 TwoListPanel getTLP()
          Returns the TwoListPanel being used to store the lists of available and selected actions.
private  void init()
          Initializes the editor window contents.
static boolean isSpace(TwoFacedObject tfo)
          Determines if a given toolbar entry (in the form of a TwoFacedObject) represents a space.
private  List<TwoFacedObject> sortTwoFaced(List<TwoFacedObject> objs)
           Sorts a List of TwoFacedObjects by label.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_SIZE

protected static final int ICON_SIZE
Size of the icons to be shown in the TwoListPanel.

See Also:
Constant Field Values

MENU_PLUGINEXPORT

private static final String MENU_PLUGINEXPORT
See Also:
Constant Field Values

MSG_ENTER_NAME

private static final String MSG_ENTER_NAME
See Also:
Constant Field Values

MSG_SELECT_ENTRIES

private static final String MSG_SELECT_ENTRIES
See Also:
Constant Field Values

CMD_ADDSPACE

private static final String CMD_ADDSPACE
Add a "space" entry

See Also:
Constant Field Values

CMD_RELOAD

private static final String CMD_RELOAD
Action command for reloading the toolbar list with original items

See Also:
Constant Field Values

CMD_EXPORTPLUGIN

private static final String CMD_EXPORTPLUGIN
action command

See Also:
Constant Field Values

CMD_EXPORTMENUPLUGIN

private static final String CMD_EXPORTMENUPLUGIN
action command

See Also:
Constant Field Values

TT_EXPORT_SELECT

private static final String TT_EXPORT_SELECT
See Also:
Constant Field Values

TT_EXPORT_SELECTMENU

private static final String TT_EXPORT_SELECTMENU
See Also:
Constant Field Values

TT_OVERWRITE

private static final String TT_OVERWRITE
See Also:
Constant Field Values

SPACE

private static final String SPACE
ID that represents a "space" in the toolbar.

See Also:
Constant Field Values

spaceCount

private int spaceCount
Provides simple IDs for the space entries.


uiManager

private UIManager uiManager
Used to notify the application that a toolbar update should occur.


contents

private JComponent contents
All of the toolbar editor's GUI components.


twoListPanel

private TwoListPanel twoListPanel
The GUI component that stores both available and selected actions.


resources

XmlResourceCollection resources
The toolbar XML resources.


menuNameFld

private JTextField menuNameFld
Used to export toolbars to plugin.


menuIdBox

private JComboBox menuIdBox
Used to export toolbars to plugin.


menuOverwriteCbx

private JCheckBox menuOverwriteCbx
Used to export toolbars to plugin.

Constructor Detail

McvToolbarEditor

public McvToolbarEditor(UIManager mngr)
Builds a toolbar editor and associates it with the UIManager.

Parameters:
mngr - The application's UI Manager.
Method Detail

getActionIcon

protected Icon getActionIcon(String actionId)
Returns the icon associated with actionId.


isSpace

public static boolean isSpace(TwoFacedObject tfo)
Determines if a given toolbar entry (in the form of a TwoFacedObject) represents a space.

Parameters:
tfo - The entry to test.
Returns:
Whether or not the entry represents a space.

getCurrentToolbar

private List<TwoFacedObject> getCurrentToolbar()
Returns:
Current toolbar contents as action IDs mapped to labels.

getAllActions

private List<TwoFacedObject> getAllActions()
Returns a List of TwoFacedObjects containing all of the actions known to McIDAS-V.


getTLP

public TwoListPanel getTLP()
Returns the TwoListPanel being used to store the lists of available and selected actions.


getContents

public JComponent getContents()
Returns the JComponent that contains all of the toolbar editor's UI components.


init

private void init()
Initializes the editor window contents.


doExportToMenu

private void doExportToMenu(Object[] tfos)
Export the selected actions as a menu to the plugin manager.

Parameters:
tfos - selected actions

doExport

private void doExport(Object[] tfos)
Export the actions

Parameters:
tfos - the actions

actionPerformed

public void actionPerformed(ActionEvent ae)
Handles events such as exporting plugins, reloading contents, and adding spaces.

Specified by:
actionPerformed in interface ActionListener
Parameters:
ae - The event that invoked this method.

anyChanges

public boolean anyChanges()
Has twoListPanel been changed?

Returns:
true if there have been changes, false otherwise.

doApply

public void doApply()
Writes out the toolbar xml.


sortTwoFaced

private List<TwoFacedObject> sortTwoFaced(List<TwoFacedObject> objs)

Sorts a List of TwoFacedObjects by label. Case is ignored.

Parameters:
objs - The list that needs some sortin' out.
Returns:
The sorted contents of objs.