com.metamatrix.console.ui.util.property
Class GuiComponentFactory

java.lang.Object
  extended by com.metamatrix.console.ui.util.property.GuiComponentFactory

public class GuiComponentFactory
extends java.lang.Object

The GuiComponentFactory creates JComponents and sets their properties. All JavaBean properties can be set using this class. For example, to create a JButton, the properties file entries could look like this:

     btn=javax.swing.JButton.class
     btn.background=Color.red
     btn.text="Red Button"
     btn.mnemonic='R'
     btn.toolTipText="This is a red button"
 
After the component identifier, in the above example "btn", and after the period separator, the property name is identified starting with a lowercase letter. A PropertyProvider identifies which properties files are searched.

Version:
1.0
Author:
Dan Florian

Field Summary
static java.lang.String SEPARATOR
          The separator used between component ID and property when composing a properties file key.
static java.lang.String TYPE_DEFS_PROP
          The default properties file used in the createTextField(String) method.
static java.lang.String TYPE_PREFIX
          The prefix used to denote data types in property files.
 
Method Summary
static javax.swing.JComponent createComponent(java.lang.String theKey, PropertyProvider thePropProvider)
          Creates a JComponent and initializes it's properties using properties file(s).
static javax.swing.JPasswordField createPasswordField(java.lang.String theType)
          Creates a JPasswordField and initializes it by using the given type.
static javax.swing.JPasswordField createPasswordField(java.lang.String theType, PropertyProvider thePropProvider)
          Creates a JPasswordField and initializes it by using the given type.
static TextFieldWidget createTextField(java.lang.String theType)
          Creates a TextFieldWidget and initializes it by using the given type.
static TextFieldWidget createTextField(java.lang.String theType, PropertyProvider thePropProvider)
          Creates a TextFieldWidget and initializes by using the given type.
static TextFieldWidget createTextField(java.lang.String theType, java.lang.String theKey, PropertyProvider thePropProvider)
          Creates a TextFieldWidget and initializes by using the given type.
static void setProperties(java.lang.String theKey, javax.swing.JComponent theComponent, PropertyProvider thePropProvider)
          Sets the JavaBean properties of a component based on entries in one or more properties files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final java.lang.String SEPARATOR
The separator used between component ID and property when composing a properties file key. Currently only a period is used.

See Also:
Constant Field Values

TYPE_DEFS_PROP

public static final java.lang.String TYPE_DEFS_PROP
The default properties file used in the createTextField(String) method.

See Also:
Constant Field Values

TYPE_PREFIX

public static final java.lang.String TYPE_PREFIX
The prefix used to denote data types in property files.

See Also:
Constant Field Values
Method Detail

createComponent

public static javax.swing.JComponent createComponent(java.lang.String theKey,
                                                     PropertyProvider thePropProvider)
Creates a JComponent and initializes it's properties using properties file(s).

Parameters:
theKey - the properties file key
thePropProvider - the provider that determines the file(s) to look at
Returns:
the newly created component
Throws:
java.lang.IllegalArgumentException - if either input parameter is null, the key cannot be found, the value is not a String object, the value is not a class name, or the class is not an instanceof JComponent. .

createPasswordField

public static javax.swing.JPasswordField createPasswordField(java.lang.String theType)
Creates a JPasswordField and initializes it by using the given type. If the type is not found by the provider, a default field is returned. The default provider is used.

Parameters:
theType - the data type key
Returns:
the newly created JPasswordField
Throws:
java.lang.IllegalArgumentException - if input parameter is null
See Also:
createTextField(String, PropertyProvider)

createPasswordField

public static javax.swing.JPasswordField createPasswordField(java.lang.String theType,
                                                             PropertyProvider thePropProvider)
Creates a JPasswordField and initializes it by using the given type. If the type is not found by the provider, a default field is returned.

Parameters:
theType - the data type key
thePropProvider - the provider that determines the file(s) to look at for properties
Returns:
the newly created JPasswordField
Throws:
java.lang.IllegalArgumentException - if either input parameter is null
See Also:
createTextField(String, PropertyProvider)

createTextField

public static TextFieldWidget createTextField(java.lang.String theType)
Creates a TextFieldWidget and initializes it by using the given type. If the type is not found by the provider, a default textfield is returned. The default provider is used.

Parameters:
theType - the data type key
Returns:
the newly created TextFieldWidget
Throws:
java.lang.IllegalArgumentException - if input parameter is null
See Also:
createTextField(String, PropertyProvider)

createTextField

public static TextFieldWidget createTextField(java.lang.String theType,
                                              PropertyProvider thePropProvider)
Creates a TextFieldWidget and initializes by using the given type. If the type is not found by the provider, a default textfield is returned. A typical type entry in a properties file would like like this:
     type.heapsize.length.min="1"
     type.heapsize.length.max="4"
     type.heapsize.cols=get("type.heapsize.length.max")
     type.heapsize.required="true"
     type.heapsize.validchars="0-9"
     #type.heapsize.invalidchars=""
 

Parameters:
theType - the data type key
thePropProvider - the provider that determines the file(s) to look at for properties
Returns:
the newly created TextFieldWidget
Throws:
java.lang.IllegalArgumentException - if either input parameter is null

createTextField

public static TextFieldWidget createTextField(java.lang.String theType,
                                              java.lang.String theKey,
                                              PropertyProvider thePropProvider)
Creates a TextFieldWidget and initializes by using the given type. Also, properties are set based on the given key. If the type is not found by the provider, a default textfield is returned.

Parameters:
theType - the data type key
theKey - the properties key to use to set JavaBean properties
thePropProvider - the provider that determines the file(s) to look at for properties
Returns:
the newly created TextFieldWidget
Throws:
java.lang.IllegalArgumentException - if any input parameter is null
See Also:
createTextField(String, PropertyProvider), setProperties(String, JComponent, PropertyProvider)

setProperties

public static void setProperties(java.lang.String theKey,
                                 javax.swing.JComponent theComponent,
                                 PropertyProvider thePropProvider)
Sets the JavaBean properties of a component based on entries in one or more properties files.

Parameters:
theKey - the properties key to used as a prefix to set JavaBean properties
theComponent - the component whose properties are being set
thePropProvider - the provider that determines the file(s) to look at for properties
Throws:
java.lang.IllegalArgumentException - if any input parameter is null


Copyright © 2009. All Rights Reserved.