de.tubs.macs.util.misc
Class Resource

java.lang.Object
  |
  +--de.tubs.macs.util.misc.Resource

public class Resource
extends java.lang.Object

An utility class to ease to construction of graphical user interfaces for the macs project. More information on how to use is soon to follow.

Author:
Werner Mahalek

Field Summary
static java.lang.String actionClassSuffix
          Suffix applied to the key used in resource file lookups for the implementing class of an action.
static java.lang.String actionSuffix
          Suffix applied to the key used in resource file lookups for an action.
static java.lang.String classSuffix
          Suffix for classname definition lookups for the classname of an application
static java.lang.String imageSuffix
          Suffix applied to the key used in resource file lookups for an image.
static java.lang.String labelSuffix
          Suffix applied to the key used in resource file lookups for a label.
static java.lang.String menubarSuffix
          Suffix applied to the key used in resource file lookups for a menubar.
static java.lang.String popupSuffix
          Suffix applied to the key used in resource file lookups for an popup.
 PropertiesModel properties
          PropertiesModel
static java.lang.String stateSuffix
          Suffix applied to a JCheckBox or JCheckBoxMenuItem lookups for the initial-state of the item State may be 'true' or 'false'
static java.lang.String tipSuffix
          Suffix applied to the key used in resource file lookups for tooltip text.
static java.lang.String toolbarSuffix
          Suffix applied to the key used in resource file lookups for a toolbar.
 
Constructor Summary
Resource(java.lang.String systemFileName)
          Constructs an instance of Resource.
Resource(java.lang.String systemFileName, java.lang.String userFileName)
          Constructs an instance of Resource.
 
Method Summary
(package private) static void ()
           
 void addRadioButtonGroupToToolBar(javax.swing.ButtonGroup group, javax.swing.JToolBar toolbar)
          Add a radiobutton-group to be added to a JToolBar
 java.beans.PropertyChangeListener createActionChangeListener(javax.swing.JButton b)
           
 javax.swing.JMenu createCheckBoxMenu(java.lang.String key, java.util.Hashtable cmds)
          Create a menu of checkboxes for the application.
protected  javax.swing.JCheckBoxMenuItem createCheckBoxMenuItem(java.lang.String key, java.util.Hashtable cmds)
          This is the hook through which all menu itmes are created.
 javax.swing.JComboBox createComboBox(java.lang.String key, java.util.Hashtable cmds)
          create a combo-box to be added anywhere you want it
protected  javax.swing.JMenu createMenu(java.lang.String key, java.util.Hashtable cmds)
          Create a menu for the application.
 javax.swing.JMenuBar createMenuBar(java.lang.String key, java.util.Hashtable cmds)
          Create the menubar for the application.
protected  javax.swing.JMenuItem createMenuItem(java.lang.String key, java.util.Hashtable cmds)
          This is the hook through which all menu itmes are created.
 javax.swing.JPopupMenu createPopupMenu(java.lang.String key, java.util.Hashtable cmds)
          Create the popup menu for the application.
 javax.swing.JPopupMenu createPopupMenu(java.lang.String key, java.lang.String[] itemKeys, java.util.Hashtable cmds)
           
 javax.swing.JRadioButton createRadioButton(java.lang.String key, java.util.Hashtable cmds)
          Create a radiobutton that may go inside a button group
 javax.swing.ButtonGroup createRadioButtonGroup(java.lang.String key, java.util.Hashtable cmds)
          Create a group of radio buttons which may be added to a toolbar or anything
 javax.swing.JToolBar createToolBar(java.lang.String[] toolKeys, java.util.Hashtable cmds)
           
 javax.swing.JToolBar createToolBar(java.lang.String key, java.util.Hashtable cmds)
          Create the toolbar.
 javax.swing.JButton createToolBarButton(java.lang.String key, java.util.Hashtable cmds)
          Create a button to go inside of the toolbar.
 boolean getBool(java.lang.String key)
          Returns boolean value associated with key.
 javax.swing.JComponent getComponent(java.lang.String key)
          Returns the component associated with key
 java.awt.Image getImage(java.lang.String key)
           
 javax.swing.ImageIcon getImageIcon(java.lang.String key)
          Create an ImageIcon.
 int getInt(java.lang.String key)
          Returns the integer value associated with key.
 long getLong(java.lang.String key)
          Returns the integer value associated with key.
 PropertiesModel getPropertiesModel()
          Return the PropertiesModel object of this Resource
 java.net.URL getResource(java.lang.String key)
          Fetch the url of an image associated with the key key out of the resource file.
 java.lang.String getResourceString(java.lang.String key)
          Read a string associated with the key out of the resource file.
 java.util.Vector getResourceVector(java.lang.String key)
          Read a string associated with the key out of the resource file.
 boolean getState(java.lang.String key)
          Read a string associated with the key out of the resource file.
 java.lang.String getString(java.lang.String key)
          Read a string associated with the key out of the resource file.
 void putImageIcon(java.lang.String key, javax.swing.ImageIcon icon)
          Insert an ImageIcon into the IconServer database.
 void setProperty(java.lang.String key, java.lang.String value)
          Store a key-value pair into the actual Properties
 java.lang.String[] tokenize(java.lang.String key)
          The string associated with key is chopped up into a series of strings on whitespace boundaries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

labelSuffix

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

imageSuffix

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

tipSuffix

public static final java.lang.String tipSuffix
Suffix applied to the key used in resource file lookups for tooltip text.

actionSuffix

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

actionClassSuffix

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

stateSuffix

public static final java.lang.String stateSuffix
Suffix applied to a JCheckBox or JCheckBoxMenuItem lookups for the initial-state of the item State may be 'true' or 'false'

classSuffix

public static final java.lang.String classSuffix
Suffix for classname definition lookups for the classname of an application

popupSuffix

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

menubarSuffix

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

toolbarSuffix

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

properties

public PropertiesModel properties
PropertiesModel
Constructor Detail

Resource

public Resource(java.lang.String systemFileName)
         throws java.io.IOException
Constructs an instance of Resource.

Resource

public Resource(java.lang.String systemFileName,
                java.lang.String userFileName)
         throws java.io.IOException
Constructs an instance of Resource.
Method Detail

static void ()

getPropertiesModel

public PropertiesModel getPropertiesModel()
Return the PropertiesModel object of this Resource

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Store a key-value pair into the actual Properties

getResourceString

public java.lang.String getResourceString(java.lang.String key)
Read a string associated with the key out of the resource file.

getResourceVector

public java.util.Vector getResourceVector(java.lang.String key)
Read a string associated with the key out of the resource file. returns a vector that contains the whitespace-seperated parts of the string as elements

getString

public java.lang.String getString(java.lang.String key)
Read a string associated with the key out of the resource file.

getState

public boolean getState(java.lang.String key)
Read a string associated with the key out of the resource file.

getResource

public java.net.URL getResource(java.lang.String key)
Fetch the url of an image associated with the key key out of the resource file.

getImage

public java.awt.Image getImage(java.lang.String key)

getImageIcon

public javax.swing.ImageIcon getImageIcon(java.lang.String key)
Create an ImageIcon. This pulls the name and location of the image from the associated resource file acording to the key key.
Parameters:
key - The key in the resource file to serve as the basis of lookups.

putImageIcon

public void putImageIcon(java.lang.String key,
                         javax.swing.ImageIcon icon)
Insert an ImageIcon into the IconServer database.
Parameters:
key - the name of the ImageIcon
icon - the ImageIcon

getInt

public int getInt(java.lang.String key)
Returns the integer value associated with key.

getLong

public long getLong(java.lang.String key)
Returns the integer value associated with key.

getBool

public boolean getBool(java.lang.String key)
Returns boolean value associated with key.

getComponent

public javax.swing.JComponent getComponent(java.lang.String key)
Returns the component associated with key

tokenize

public java.lang.String[] tokenize(java.lang.String key)
The string associated with key is chopped up into a series of strings on whitespace boundaries. This is useful for trying to get an array of strings out of the resource file.

createMenuBar

public javax.swing.JMenuBar createMenuBar(java.lang.String key,
                                          java.util.Hashtable cmds)
Create the menubar for the application. This pulls the definition of the menu from the associated resource file.

createMenu

protected javax.swing.JMenu createMenu(java.lang.String key,
                                       java.util.Hashtable cmds)
Create a menu for the application. By default this pulls the definition of the menu from the associated resource file.

createMenuItem

protected javax.swing.JMenuItem createMenuItem(java.lang.String key,
                                               java.util.Hashtable cmds)
This is the hook through which all menu itmes are created.

createCheckBoxMenu

public javax.swing.JMenu createCheckBoxMenu(java.lang.String key,
                                            java.util.Hashtable cmds)
Create a menu of checkboxes for the application. By default this pulls the definition of the menu from the associated resource file.

createCheckBoxMenuItem

protected javax.swing.JCheckBoxMenuItem createCheckBoxMenuItem(java.lang.String key,
                                                               java.util.Hashtable cmds)
This is the hook through which all menu itmes are created.

createPopupMenu

public javax.swing.JPopupMenu createPopupMenu(java.lang.String key,
                                              java.util.Hashtable cmds)
Create the popup menu for the application. This pulls the definition of the menu from the associated resource file.

createPopupMenu

public javax.swing.JPopupMenu createPopupMenu(java.lang.String key,
                                              java.lang.String[] itemKeys,
                                              java.util.Hashtable cmds)

createToolBar

public javax.swing.JToolBar createToolBar(java.lang.String key,
                                          java.util.Hashtable cmds)
Create the toolbar. By default this reads the resource file for the definition of the toolbar.

createToolBar

public javax.swing.JToolBar createToolBar(java.lang.String[] toolKeys,
                                          java.util.Hashtable cmds)

createToolBarButton

public javax.swing.JButton createToolBarButton(java.lang.String key,
                                               java.util.Hashtable cmds)
Create a button to go inside of the toolbar. By default this will load an image resource. The image filename is relative to the classpath (including the '.' directory if its a part of the classpath), and may either be in a JAR file or a separate file.
Parameters:
key - The key in the resource file to serve as the basis of lookups.

createActionChangeListener

public java.beans.PropertyChangeListener createActionChangeListener(javax.swing.JButton b)

createRadioButtonGroup

public javax.swing.ButtonGroup createRadioButtonGroup(java.lang.String key,
                                                      java.util.Hashtable cmds)
Create a group of radio buttons which may be added to a toolbar or anything
Parameters:
key - The key in the resource file to serve as the basis of lookups.

createRadioButton

public javax.swing.JRadioButton createRadioButton(java.lang.String key,
                                                  java.util.Hashtable cmds)
Create a radiobutton that may go inside a button group
Parameters:
key - The key in the resource file to serve as the basis of lookups.

addRadioButtonGroupToToolBar

public void addRadioButtonGroupToToolBar(javax.swing.ButtonGroup group,
                                         javax.swing.JToolBar toolbar)
Add a radiobutton-group to be added to a JToolBar
Parameters:
group - A radiobutton-group to be added to the toolbar
toolbar - The toolbar, where 'group' will be added to.

createComboBox

public javax.swing.JComboBox createComboBox(java.lang.String key,
                                            java.util.Hashtable cmds)
create a combo-box to be added anywhere you want it
Parameters:
key - The key in the resource file to serve as the basis of lookups.