com.sptci.echo2
Class Utilities

java.lang.Object
  extended by com.sptci.echo2.Utilities

public final class Utilities
extends Object

A utility class that provides methods to create and initialise standard UI components.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: Utilities.java 3115 2007-04-23 14:07:53Z rakesh $
Author:
Rakesh Vidyadharan 2006-01-15

Constructor Summary
private Utilities()
          Default constructor.
 
Method Summary
static Button createButton(String view, String name)
          Create the button identified by the specified name.
static Button createButton(String view, String name, ActionListener actionListener)
          Create the button identified by the specified name.
static Button createButton(String view, String name, ActionListener actionListener, Object viewObject)
          Create the button identified by the specified name.
static Button createButton(String view, String name, ImageReference image, ActionListener actionListener)
          Create the button identified by the specified name.
static Button createButton(String view, String name, String styleName)
          Create the button identified by the specified name.
static Button createButton(String view, String name, String styleName, ActionListener actionListener)
          Create the button identified by the specified name.
static Button createButton(String view, String name, String styleName, ActionListener actionListener, Object viewObject)
          Create the button identified by the specified name.
private static Column createColumn()
          Create a column and set its style name to Default.Column.
private static Column createColumn(String style)
          Create a column and set its style name to the specified value.
static Label createLabel(String view, String name)
          Create a label using the specified name property.
static Label createLabel(String view, String name, Object viewObject)
          Create a label using the specified name property and add it to the specified component.
static Label createLabel(String view, String name, String styleName)
          Create a label using the specified name property and style name.
static Label createLabel(String view, String name, String styleName, Object viewObject)
          Create a label using the specified name property and style name and add to the specified viewObject.
static Menu createMenu(String view, String name)
          Create the Menu identified by the specified name.
static MenuItem createMenuItem(String view, String name)
          Create the MenuItem identified by the specified name.
static MenuItem createMenuItem(String view, String name, ActionListener actionListener)
          Create the menuItem identified by the specified name.
static MenuItem createMenuItem(String view, String name, ActionListener actionListener, Object viewObject)
          Create the menuItem identified by the specified name.
static PushButton createPushButton(String view, String name)
          Create the button identified by the specified name.
static PushButton createPushButton(String view, String name, ActionListener actionListener)
          Create the button identified by the specified name.
static PushButton createPushButton(String view, String name, ActionListener actionListener, Object viewObject)
          Create the button identified by the specified name.
static RichTextArea createRichTextArea(String view, String name)
          Create the rich text area identified by the name specified.
static RichTextArea createRichTextArea(String view, String name, Object viewObject)
          Create the text field identified by the name specified.
private static Row createRow()
          Create a row and set its style name to Default.Row.
private static Row createRow(String style)
          Create a row and set its style name to the specified value.
static TextArea createTextArea(String view, String name)
          Create the text area identified by the name specified.
static TextArea createTextArea(String view, String name, Object viewObject)
          Create the text area identified by the name specified.
static TextArea createTextArea(String view, String name, String style)
          Create the text area identified by the name specified.
static TextArea createTextArea(String view, String name, String style, Object viewObject)
          Create the text area identified by the name specified.
static TextField createTextField(String view, String name)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, ActionListener actionListener)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, ActionListener actionListener, Object viewObject)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, Object viewObject)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, String styleName)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, String styleName, ActionListener listener)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, String styleName, ActionListener listener, Object viewObject)
          Create the text field identified by the name specified.
static TextField createTextField(String view, String name, String styleName, Object viewObject)
          Create the text field identified by the name specified.
private static String processStyleName(String view, String styleName, String identifier)
          Apply some logical rules to the styleName parameter specified.
private static void setField(String name, Object viewObject, Component value)
          Set the field identified by the name specified in the object specified with the value specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

private Utilities()
Default constructor. Cannot be initialised.

Method Detail

createButton

public static final Button createButton(String view,
                                        String name)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
Returns:
Button The new button that was created.

createButton

public static final Button createButton(String view,
                                        String name,
                                        ActionListener actionListener)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
actionListener - The ActionListener to register for the newly created button.
Returns:
Button The new button that was created.
See Also:
createButton( String, String )

createButton

public static final Button createButton(String view,
                                        String name,
                                        ActionListener actionListener,
                                        Object viewObject)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
actionListener - The ActionListener to register for the newly created button.
viewObject - The object whose identically named field is to be set with the newly created component.
Returns:
Button The new button that was created.
See Also:
createButton( String, String, ActionListener ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createButton

public static final Button createButton(String view,
                                        String name,
                                        ImageReference image,
                                        ActionListener actionListener)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
image - The image that is to be displayed as the button.
actionListener - The ActionListener to register for the newly created button.
Returns:
Button The new button that was created.

createButton

public static final Button createButton(String view,
                                        String name,
                                        String styleName)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".Button" will be applied.
Returns:
Button The new button that was created.

createButton

public static final Button createButton(String view,
                                        String name,
                                        String styleName,
                                        ActionListener actionListener)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".Button" will be applied.
actionListener - The ActionListener to register for the newly created button.
Returns:
Button The new button that was created.
See Also:
createButton( String, String, String )

createButton

public static final Button createButton(String view,
                                        String name,
                                        String styleName,
                                        ActionListener actionListener,
                                        Object viewObject)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".Button" will be applied.
actionListener - The ActionListener to register for the newly created button.
viewObject - The object whose identically named field is to be set with the newly created component.
Returns:
Button The new button that was created.
See Also:
createButton( String, String, String, ActionListener ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createPushButton

public static final PushButton createPushButton(String view,
                                                String name)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
Returns:
PushButton The new button that was created.

createPushButton

public static final PushButton createPushButton(String view,
                                                String name,
                                                ActionListener actionListener)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
actionListener - The ActionListener to register for the newly created button.
Returns:
PushButton The new button that was created.
See Also:
createPushButton( String, String )

createPushButton

public static final PushButton createPushButton(String view,
                                                String name,
                                                ActionListener actionListener,
                                                Object viewObject)
Create the button identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the button to create. The name must match the name of the appropriate button. The same name must be configured in the configuration file for the properties and resources.
actionListener - The ActionListener to register for the newly created button.
viewObject - The object whose identically named field is to be set with the newly created component.
Returns:
PushButton The new button that was created.
See Also:
createPushButton( String, String, ActionListener ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createColumn

private static final Column createColumn()
Create a column and set its style name to Default.Column.

Returns:
Column The newly created column component.
See Also:
createColumn( String )

createColumn

private static final Column createColumn(String style)
Create a column and set its style name to the specified value.

Parameters:
style - The name of the style configuration to apply to the component.
Returns:
Column The newly created column component.

createLabel

public static final Label createLabel(String view,
                                      String name)
Create a label using the specified name property.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the label to create. The same name must be configured in the configuration file for the properties and resources.
Returns:
Label The newly created label.

createLabel

public static final Label createLabel(String view,
                                      String name,
                                      Object viewObject)
Create a label using the specified name property and add it to the specified component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the label to create. The same name must be configured in the configuration file for the properties and resources.
viewObject - The object in which a Label field is defined with name as the field name.
Returns:
Label The newly created label.
See Also:
createLabel( String, String ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createLabel

public static final Label createLabel(String view,
                                      String name,
                                      String styleName)
Create a label using the specified name property and style name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the label to create. The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".Label" will be applied.
Returns:
Label The newly created label.
See Also:
createLabel( String, String )

createLabel

public static final Label createLabel(String view,
                                      String name,
                                      String styleName,
                                      Object viewObject)
Create a label using the specified name property and style name and add to the specified viewObject.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the label to create. The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".Label" will be applied.
viewObject - The object in which a Label field is defined with name.
Returns:
Label The newly created label.
See Also:
createLabel( String, String, String )

createMenu

public static final Menu createMenu(String view,
                                    String name)
Create the Menu identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the menu to create. The name must match the name of the appropriate menu. The same name must be configured in the configuration file for the properties and resources.
Returns:
Menu The new menu that was created.

createMenuItem

public static final MenuItem createMenuItem(String view,
                                            String name)
Create the MenuItem identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the menuItem to create. The name must match the name of the appropriate menuItem. The same name must be configured in the configuration file for the properties and resources.
Returns:
MenuItem The new menuItem that was created.

createMenuItem

public static final MenuItem createMenuItem(String view,
                                            String name,
                                            ActionListener actionListener)
Create the menuItem identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the menuItem to create. The name must match the name of the appropriate menuItem. The same name must be configured in the configuration file for the properties and resources.
actionListener - The ActionListener to register for the newly created menuItem.
Returns:
MenuItem The new menuItem that was created.
See Also:
createMenuItem( String, String )

createMenuItem

public static final MenuItem createMenuItem(String view,
                                            String name,
                                            ActionListener actionListener,
                                            Object viewObject)
Create the menuItem identified by the specified name.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the menuItem to create. The name must match the name of the appropriate menuItem. The same name must be configured in the configuration file for the properties and resources.
actionListener - The ActionListener to register for the newly created menuItem.
viewObject - The object whose identically named field is to be set with the newly created component.
Returns:
MenuItem The new menuItem that was created.
See Also:
createMenuItem( String, String, ActionListener ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createRow

private static final Row createRow()
Create a row and set its style name to Default.Row.

Returns:
Row The newly created row component.
See Also:
createRow( String )

createRow

private static final Row createRow(String style)
Create a row and set its style name to the specified value.

Parameters:
style - The name of the style configuration to apply to the component.
Returns:
Row The newly created row component.

createTextArea

public static final TextArea createTextArea(String view,
                                            String name)
Create the text area identified by the name specified.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text area to create. The name must match the name of the appropriate field without the Area suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
Returns:
TextArea The new textArea component.

createTextArea

public static final TextArea createTextArea(String view,
                                            String name,
                                            Object viewObject)
Create the text area identified by the name specified. Sets the identically named Area in the viewClass with the newly created component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Area suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
viewObject - The object whose field is to be updated with the newly created component
Returns:
TextArea The new textArea component.
See Also:
createTextArea( String, String ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createTextArea

public static final TextArea createTextArea(String view,
                                            String name,
                                            String style)
Create the text area identified by the name specified. Set the style name of the newly created text area to the style specified.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Area suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
style - The name of the style to apply to the component.
Returns:
TextArea The new textArea component.
See Also:
createTextArea( String, String )

createTextArea

public static final TextArea createTextArea(String view,
                                            String name,
                                            String style,
                                            Object viewObject)
Create the text area identified by the name specified. Set the style name of the newly created text area to the style specified. Set the field identified by name in the view with the newly created object.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Area suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
style - The name of the style to apply to the component.
viewObject - The object whose field is to be updated with the newly created component
Returns:
TextArea The new textArea component.
See Also:
createTextArea( String, String )

createTextField

public static final TextField createTextField(String view,
                                              String name)
Create the text field identified by the name specified. If the name is password, then a PasswordField is returned instead of a regular TextField.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
Returns:
TextField The new textField component.

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              ActionListener actionListener)
Create the text field identified by the name specified. Sets the identically named Field in the viewClass with the newly created component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
actionListener - The action listener to add to the component.
Returns:
TextField The new textField component.
See Also:
createTextField( String, String )

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              Object viewObject)
Create the text field identified by the name specified. Sets the identically named Field in the viewClass with the newly created component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
viewObject - The object whose field is to be updated with the newly created component
Returns:
TextField The new textField component.
See Also:
createTextField( String, String ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              ActionListener actionListener,
                                              Object viewObject)
Create the text field identified by the name specified. Sets the identically named Field in the viewClass with the newly created component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
actionListener - The action listener to add to the component.
viewObject - The object whose field is to be updated with the newly created component
Returns:
TextField The new textField component.
See Also:
createTextField( String, String, Object )

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              String styleName)
Create the text field identified by the name specified. If the name is password, then a PasswordField is returned instead of a regular TextField.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".TextComponent" will be applied.
Returns:
TextField The new textField component.

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              String styleName,
                                              ActionListener listener)
Create the text field identified by the name specified. Sets the action handler for the text field to the specified handler.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".TextComponent" will be applied.
listener - The action listener to asscociated with the text field.
Returns:
TextField The new textField component.
See Also:
createTextField( String, String, String )

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              String styleName,
                                              Object viewObject)
Create the text field identified by the name specified. Sets the identically named Field in the viewClass with the newly created component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".TextComponent" will be applied.
viewObject - The object whose field is to be updated with the newly created component
Returns:
TextField The new textField component.
See Also:
createTextField( String, String, String ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createTextField

public static final TextField createTextField(String view,
                                              String name,
                                              String styleName,
                                              ActionListener listener,
                                              Object viewObject)
Create the text field identified by the name specified. Sets the identically named Field in the viewClass with the newly created component. Add the specified action listener as a registered event handler for the text field.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Field suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the default ".TextComponent" will be applied.
listener - The action listener to asscociated with the text field.
viewObject - The object whose field is to be updated with the newly created component
Returns:
TextField The new textField component.
See Also:
createTextField( String, String, String, ActionListener ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

createRichTextArea

public static final RichTextArea createRichTextArea(String view,
                                                    String name)
Create the rich text area identified by the name specified.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text area to create. The name must match the name of the appropriate field without the Area suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
Returns:
RichTextArea The new textArea component.

createRichTextArea

public static final RichTextArea createRichTextArea(String view,
                                                    String name,
                                                    Object viewObject)
Create the text field identified by the name specified. Sets the identically named Area in the viewClass with the newly created component.

Parameters:
view - The name of the view to which the component is to be added. This must match the name of the configuration setting.
name - The name used to identify the text field to create. The name must match the name of the appropriate field without the Area suffix (eg. userName, salary, ...). The same name must be configured in the configuration file for the properties and resources.
viewObject - The object whose field is to be updated with the newly created component
Returns:
RichTextArea The new textArea component.
See Also:
createRichTextArea( String, String ), setField(java.lang.String, java.lang.Object, nextapp.echo2.app.Component)

processStyleName

private static final String processStyleName(String view,
                                             String styleName,
                                             String identifier)
Apply some logical rules to the styleName parameter specified.

Parameters:
view - The view component to which the style name is being applied. Usually the fully qualified class name.
styleName - The name of the style to apply to the button. This need only be the sub-part of the fully qualified style name. The name of the view and the identifier will be applied.
identifier - The identifier for the component. All style names end with an identifier.
Returns:
String The modified style name.

setField

private static void setField(String name,
                             Object viewObject,
                             Component value)
Set the field identified by the name specified in the object specified with the value specified.

Parameters:
name - The field name.
viewObject - The object in which the field is defined.
value - The value of the field to set.