Class ToolBarLoader

java.lang.Object
  |
  +--ToolBarLoader

public class ToolBarLoader
extends java.lang.Object

Builds up a AWT toolbar by reading the settings from a resource file. A AWT toolbar is a simple Panel with Buttons, that can't get the focus. It's intended to use this class for loading toolbar's created with Magic Menu.


Field Summary
static java.lang.String ACTION_SUFFIX
          Suffix applied to the key used in resource file lookups for an action.
static java.lang.String LABEL_SUFFIX
          Suffix applied to the key used in resource file lookups for a label.
static char MNEMONIC_ESCAPE
          The escape character to identify a mnemonic in a label.
static java.lang.String STRUT_BLANKS
          The blanks for the label between separated AWT toolbar components.
 
Constructor Summary
ToolBarLoader(java.util.Properties properties)
          Create a new ToolBarLoader object.
ToolBarLoader(java.util.ResourceBundle resources)
          Create a new ToolBarLoader object.
 
Method Summary
protected  java.awt.Component createTool(java.lang.String key)
          Hook through which every toolbar item is created.
 java.awt.Panel createToolBar(java.lang.String key)
          Create the toolbar for the specified key.
protected  java.awt.Button createToolBarButton(java.lang.String key)
          Create a button to go inside of the toolbar.
protected  java.awt.event.ActionListener getAction(java.lang.String cmd)
          Return the default action listener.
 java.awt.event.ActionListener getDefaultActionListener()
          Returns the default action listener.
protected  java.lang.String getResourceString(java.lang.String key)
          Read a string from the resource file containing the toolbar definition.
protected  void reportError(java.lang.String text)
          This method will be called, if some errors occur.
 void setDefaultActionListener(java.awt.event.ActionListener al)
          Set the default action listener.
protected  java.lang.String[] tokenize(java.lang.String input)
          Take the given string and chop it up into a series of strings on whitespace boundries.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LABEL_SUFFIX

public static final java.lang.String LABEL_SUFFIX
Suffix applied to the key used in resource file lookups for a label.

ACTION_SUFFIX

public static final java.lang.String ACTION_SUFFIX
Suffix applied to the key used in resource file lookups for an action.

MNEMONIC_ESCAPE

public static final char MNEMONIC_ESCAPE
The escape character to identify a mnemonic in a label.

STRUT_BLANKS

public static final java.lang.String STRUT_BLANKS
The blanks for the label between separated AWT toolbar components.
Constructor Detail

ToolBarLoader

public ToolBarLoader(java.util.ResourceBundle resources)
Create a new ToolBarLoader object.
Parameters:
resources - A resources bundle containing the toolbar settings.

ToolBarLoader

public ToolBarLoader(java.util.Properties properties)
Create a new ToolBarLoader object.
Parameters:
properties - Properties containing the menu settings.
Method Detail

getDefaultActionListener

public java.awt.event.ActionListener getDefaultActionListener()
Returns the default action listener. This ActionListener is registered at every toolbar item.

setDefaultActionListener

public void setDefaultActionListener(java.awt.event.ActionListener al)
Set the default action listener. This action listener is registered at every toolbar item. If a ActionListener is set, this should be done before the first call to createToolBar, createTool or createMenuItem.
See Also:
createToolBar(java.lang.String), createTool(java.lang.String), createToolBarButton(java.lang.String)

createToolBarButton

protected java.awt.Button createToolBarButton(java.lang.String key)
Create a button to go inside of the toolbar.
Parameters:
key - The key in the resource file to serve as the basis of lookups.

getAction

protected java.awt.event.ActionListener getAction(java.lang.String cmd)
Return the default action listener. This Method should be overwritten, if not all tollbar buttons should register the same action listener.
Parameters:
cmd - The action command of the associated toolbar button.

getResourceString

protected java.lang.String getResourceString(java.lang.String key)
Read a string from the resource file containing the toolbar definition.

tokenize

protected java.lang.String[] tokenize(java.lang.String input)
Take the given string and chop it up into a series of strings on whitespace boundries. This is useful for trying to get an array of strings out of the resource file.

createToolBar

public java.awt.Panel createToolBar(java.lang.String key)
Create the toolbar for the specified key. This pulls the definition of the toolbar from the associated resource bundle.

createTool

protected java.awt.Component createTool(java.lang.String key)
Hook through which every toolbar item is created. This method can be used to integrate custom gui elements into the toolbar.

reportError

protected void reportError(java.lang.String text)
This method will be called, if some errors occur. By default this will cause an output to stderr.