com.tensegrity.gui.swing
Class SwingCommandRegistry

java.lang.Object
  extended bycom.tensegrity.generic.command.CommandRegistry
      extended bycom.tensegrity.gui.swing.SwingCommandRegistry

public class SwingCommandRegistry
extends CommandRegistry

The SwingCommandRegistry encapsulates the creation of all sorts of MenuItems, Buttons and Menu's. All these controls are associated with an Action, which triggers the underlying Command implementation. This class creates Actions for Commands and stores these in a internal Map. This ensures that there is only one Action for each Command (and vice versa).

Version:
$Id: SwingCommandRegistry.java,v 1.34 2004/10/28 09:34:41 BurkhardWick Exp $
Author:
GillesIachelini

Nested Class Summary
static class SwingCommandRegistry.ActionCommand
          Deprecated. This class has been moved to SwingCommandRegistry.ActionCommand
 
Constructor Summary
SwingCommandRegistry()
          Creates a new SwingCommandRegistry.
 
Method Summary
 javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, javax.swing.KeyStroke ks, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, javax.swing.KeyStroke ks, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu, java.util.HashMap uiMap, java.lang.String id, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, javax.swing.KeyStroke ks, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, java.lang.String iconurl, java.lang.Class resourceClass, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu, java.util.HashMap uiMap, java.lang.String id, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JButton addToToolBar(SwingToolBar toolbar, Command command, int index, java.util.HashMap uiMap, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JButton addToToolBar(SwingToolBar toolbar, Command command, int index, java.util.HashMap uiMap, UIManager uiManager, java.lang.String displayTextId)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JButton addToToolBar(SwingToolBar toolbar, Command command, java.lang.String iconurl, int index, java.lang.Class resourceClass)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar, Command command, int index, java.util.HashMap uiMap, UIManager uiManager)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar, Command command, int index, java.util.HashMap uiMap, UIManager uiManager, java.lang.String displayTextId)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar, Command command, java.lang.String iconurl, java.lang.String iconurlToggled, java.lang.Class resourceClass)
          Deprecated. Please use SwingUtil instead!
 javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar, Command command, java.lang.String iconurl, java.lang.String iconurlToggled, int index, java.lang.Class resourceClass)
          Deprecated. Please use SwingUtil instead!
 javax.swing.Action getAction(java.lang.String id)
          The method getAction returns the action instance for a given command id.
protected  javax.swing.JMenuItem makeMenuItem(java.lang.String title, javax.swing.Action action)
          Deprecated. Please use SwingUtil instead!
 
Methods inherited from class com.tensegrity.generic.command.CommandRegistry
clear, contains, dump, get, remove, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingCommandRegistry

public SwingCommandRegistry()
Creates a new SwingCommandRegistry.

Method Detail

makeMenuItem

protected javax.swing.JMenuItem makeMenuItem(java.lang.String title,
                                             javax.swing.Action action)
Deprecated. Please use SwingUtil instead!

The method makeMenuItem creates a new JMenuItem from the given title and action.

Parameters:
title - the title of the new item.
action - the action to be associated with the item.
Returns:
JMenuItem the newly created menuitem

addToToolBarToggleButton

public javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar,
                                                          Command command,
                                                          java.lang.String iconurl,
                                                          java.lang.String iconurlToggled,
                                                          java.lang.Class resourceClass)
Deprecated. Please use SwingUtil instead!

The method addToToolBarToggleButton adds a new Button to the given toolar. The Button is created from the given command and will get the two images specified by iconurl and iconurltoggled.

Parameters:
toolbar - the JToolBar to add to.
command - the command to use to create a new Button from.
iconurl - the url of the icon of this button.
iconurlToggled - the url of the icon to use when toggled.
resourceClass - the class required to load the icons.
Returns:
the newly added ToggleButton.

addToToolBarToggleButton

public javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar,
                                                          Command command,
                                                          java.lang.String iconurl,
                                                          java.lang.String iconurlToggled,
                                                          int index,
                                                          java.lang.Class resourceClass)
Deprecated. Please use SwingUtil instead!

The method addToToolBarToggleButton adds a new Button to the given toolar. The Button is created from the given command and will get the two images specified by iconurl and iconurltoggled.

Parameters:
toolbar - the JToolBar to add to.
command - the command to use to create a new Button from.
iconurl - the url of the icon of this button.
iconurlToggled - the url of the icon to use when toggled.
index - Position where the button is added
resourceClass - the class required to load the icons.
Returns:
the newly added ToggleButton.

addToToolBarToggleButton

public javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar,
                                                          Command command,
                                                          int index,
                                                          java.util.HashMap uiMap,
                                                          UIManager uiManager)
Deprecated. Please use SwingUtil instead!

Adds a ToggleButton to the given toolbar. Note: the resulting element of the toolbar will not have an icon or such.

Parameters:
toolbar - the ToolBar to add the toggle button to.
command - the command to associate with the toggle.
index - the position where to add the toggle.
uiMap - the uiMap to add the resulting control to.
uiManager - the uiManager to retrieve strings from.
Returns:
the newly added ToggleButton.

addToToolBarToggleButton

public javax.swing.JToggleButton addToToolBarToggleButton(SwingToolBar toolbar,
                                                          Command command,
                                                          int index,
                                                          java.util.HashMap uiMap,
                                                          UIManager uiManager,
                                                          java.lang.String displayTextId)
Deprecated. Please use SwingUtil instead!

Adds a ToggleButton to the given toolbar. If the text to display differs from the command's title, you can pass a separate id of a text ressource to this method. Note: the resulting element of the toolbar will not have an icon or such.

Parameters:
toolbar - the toolbar to add to.
command - the command to use.
index - the position within the toolbar.
uiMap - the uiMap to add the resulting component,id-pair to.
uiManager - UIManager to retrieve localized strings.
displayTextId - the alternative text resource.
Returns:
the newly added ToggleButton.

addToToolBar

public javax.swing.JButton addToToolBar(SwingToolBar toolbar,
                                        Command command,
                                        java.lang.String iconurl,
                                        int index,
                                        java.lang.Class resourceClass)
Deprecated. Please use SwingUtil instead!

The method addToToolBar adds a new Button to the given SwingToolBar. The Button is created from the given command and an icon is assigned.

Parameters:
toolbar - The JToolBar to add to.
command - the Command to create the button from.
iconurl - the url of the icon.
index - position where to add the button to.
resourceClass - the Class to laod the icon with.
Returns:
JButton the resulting button of the toolbar.

addToToolBar

public javax.swing.JButton addToToolBar(SwingToolBar toolbar,
                                        Command command,
                                        int index,
                                        java.util.HashMap uiMap,
                                        UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToToolBar adds a new Button to the given SwingToolBar. The Button is created from the given command. Note: The resulting element for the toolbar will not have an icon or such, rather will display the title of the given command.

Parameters:
toolbar - The JToolBar to add to.
command - the Command to create the button from.
index - position where to add the button to.
uiMap - the uiMap to add the new item to.
uiManager - the UIManager which helps to retrieve the current text.
Returns:
JButton the resulting button of the toolbar.

addToToolBar

public javax.swing.JButton addToToolBar(SwingToolBar toolbar,
                                        Command command,
                                        int index,
                                        java.util.HashMap uiMap,
                                        UIManager uiManager,
                                        java.lang.String displayTextId)
Deprecated. Please use SwingUtil instead!

The method addToToolBar adds a new Button to the given SwingToolBar. The Button is created from the given command.

Parameters:
toolbar - The JToolBar to add to.
command - the Command to create the button from.
index - position where to add the button to.
uiMap - the uiMap to add the new item to.
uiManager - the UIManager which helps to retrieve the current text.
displayTextId - Id of the text resource to use for the resulting control.
Returns:
JButton the resulting button of the toolbar.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given menu by using the Action associated to the given id.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the menu.add call.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       javax.swing.KeyStroke ks,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given menu by using the Action associated to the given id. The given KeyStroke will be associated with the resulting MenuItem.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
ks - the KeyStroke to be associated with this item.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the menu.add call.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       javax.swing.KeyStroke ks,
                                       java.lang.String iconurl,
                                       java.lang.Class resourceClass,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given menu by using the Action associated to the given id. The given KeyStroke will be associated with the resulting MenuItem. If the iconurl parameter is not null, the icon will be loaded an set as Icon for the resulting MenuItem.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
ks - the KeyStroke to be associated with this item.
iconurl - the url of the icon to use.
resourceClass - the class to load the icon with.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the menu.add call.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       java.lang.String iconurl,
                                       java.lang.Class resourceClass,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given menu by using the Action associated to the given id. If the iconurl parameter is not null, the icon will be loaded an set as Icon for the resulting MenuItem.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
iconurl - the url of the icon to use.
resourceClass - the class to load the icon with.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the menu.add call.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given popupmenu by using the Action associated to the given id.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the popupmenu.add call.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       java.lang.String iconurl,
                                       java.lang.Class resourceClass,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given popupmenu by using the Action associated to the given id. If the iconurl parameter is not null, the icon will be loaded and set.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
iconurl - the url of the icon.
resourceClass - the class to load the icon with.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the popupmenu.add call.

addToMenu

public javax.swing.JMenuItem addToMenu(javax.swing.JPopupMenu menu,
                                       java.util.HashMap uiMap,
                                       java.lang.String id,
                                       javax.swing.KeyStroke ks,
                                       java.lang.String iconurl,
                                       java.lang.Class resourceClass,
                                       UIManager uiManager)
Deprecated. Please use SwingUtil instead!

The method addToMenu adds a new JMenuItem to the given popupmenu by using the Action associated to the given id. If the iconurl parameter is not null, the icon will be loaded and set.

Parameters:
menu - the menu to add to.
uiMap - the uiMap to add the new item to.
id - the id to fetch the Action with.
ks - the KeyStroke to associate the item with.
iconurl - the url of the icon.
resourceClass - the class to load the icon with.
uiManager - the UIManager which helps to retrieve the current title.
Returns:
JMenuItem the result JMenuItem from the popupmenu.add call.

getAction

public javax.swing.Action getAction(java.lang.String id)
The method getAction returns the action instance for a given command id. If no action is found, the action is created by using the commandToAction method and returned.

Parameters:
id - the id of the command of which you want to retrieve the Action from.
Returns:
Action the action associated to the given id.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.