SPT Core API

com.sptci.echo
Class Utilities

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

public 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 4699 2009-02-24 19:08:55Z rakesh $
Author:
Rakesh Vidyadharan 2006-01-15

Constructor Summary
protected 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, Object viewObject)
          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.
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 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.
protected static String processStyleName(String view, String styleName, String identifier)
          Apply some logical rules to the styleName parameter specified.
protected 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

protected Utilities()
Default constructor. Cannot be initialised.

Method Detail

createButton

public static Button createButton(String view,
                                  String name)
Create the button identified by the specified name. The button will be assigned a style name Default.Button.

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.
See Also:
createButton( String, String, String )

createButton

public static 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. If this is null then no listener is associated.
Returns:
Button The new button that was created.
See Also:
createButton( String, String )

createButton

public static Button createButton(String view,
                                  String name,
                                  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.
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 ), setField(java.lang.String, java.lang.Object, nextapp.echo.app.Component)

createButton

public static 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.echo.app.Component)

createButton

public static 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 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. Specify null to avoid setting a style name altogether.
Returns:
Button The new button that was created.

createButton

public static 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. Specify null to avoid setting style.
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 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. Specify null to avoid setting style.
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.echo.app.Component)

createLabel

public static Label createLabel(String view,
                                String name)
Create a label using the specified name property. The label will be assigned a style name Default.Label

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.
See Also:
createLabel( String, String, String )

createLabel

public static 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.echo.app.Component)

createLabel

public static 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. Specify null to avoid setting style.
Returns:
Label The newly created label.

createLabel

public 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.

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. Specify null to avoid setting style.
viewObject - The object in which a Label field is defined with name.
Returns:
Label The newly created label.
See Also:
createLabel( String, String, String )

createTextArea

public static TextArea createTextArea(String view,
                                      String name)
Create the text area identified by the name specified. The component will be assigned a style name Default.TextComponent.

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.
See Also:
createTextArea( String, String, String )

createTextArea

public static 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.echo.app.Component)

createTextArea

public static 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. Specify null to avoid setting style.
Returns:
TextArea The new textArea component.

createTextArea

public static 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. Specify null to avoid setting style.
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 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. Returns a component with the style name set to Default.TextComponent.

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.
See Also:
createTextField( String, String, String )

createTextField

public static 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. If this is null no listener is added.
Returns:
TextField The new textField component.
See Also:
createTextField( String, String )

createTextField

public static 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.echo.app.Component)

createTextField

public static 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. This may be null.
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 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 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 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.echo.app.Component)

createTextField

public static 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.echo.app.Component)

processStyleName

protected static 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

protected 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.

SPT Core API