com.bowstreet.webapp
Class Theme

java.lang.Object
  extended by com.bowstreet.webapp.Theme
All Implemented Interfaces:
PropertyAccess

public class Theme
extends java.lang.Object
implements PropertyAccess

Utility class used to access WebApp Theme property values.
This class is typically used by Builders developers that want to use the Theme property information to influence their UI.
The following are the typical steps:
1) Add a "UseTheme" boolean builder input to give the user the option of using the theme vs. directly setting the builder inputs.
2) In the builder regen code check the UseTheme status to determine if a theme property should be used or the original builder input.
3) If "UseTheme" is enabled then call the Theme.getString(..) method to fetch the property value from the theme.
4) If the builder wants to provide override properties for a given instance of the builder, then it should publish the property name(s) using the Theme.addThemeOverride(..) method.

See Also:
getString(WebApp, String, String, String)

Field Summary
static java.lang.String BOWSTREET_THEME_OVERRIDES
           
static java.lang.String THEME_FILE_KEY
           
static java.lang.String WEBAPP_THEME_PROPERTY
           
 
Method Summary
static void addThemeOverride(WebApp webApp, java.lang.String overridePrefix, java.lang.String key)
          Adds the specified theme property name to the list of overrides on the WebApp.
static boolean getBoolean(WebApp webApp, java.lang.String overridePrefix, java.lang.String key, boolean defaultValue)
          Gets the theme property value from the current WebApp theme.
 java.util.List getNames()
          Gets a list of the property names.
 java.lang.String getString(java.lang.String key)
          Gets the String value of the specified property key.
static java.lang.String getString(WebApp webApp, java.lang.String key)
          Gets the theme property value from the current WebApp theme.
static java.lang.String getString(WebApp webApp, java.lang.String key, java.lang.String defaultValue)
          Gets the theme property value from the current WebApp theme.
static java.lang.String getString(WebApp webApp, java.lang.String overridePrefix, java.lang.String key, java.lang.String defaultValue)
          Gets the theme property value from the current WebApp theme.
 boolean isDefault()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOWSTREET_THEME_OVERRIDES

public static final java.lang.String BOWSTREET_THEME_OVERRIDES
See Also:
Constant Field Values

THEME_FILE_KEY

public static final java.lang.String THEME_FILE_KEY
See Also:
Constant Field Values

WEBAPP_THEME_PROPERTY

public static final java.lang.String WEBAPP_THEME_PROPERTY
See Also:
Constant Field Values
Method Detail

addThemeOverride

public static void addThemeOverride(WebApp webApp,
                                    java.lang.String overridePrefix,
                                    java.lang.String key)
Adds the specified theme property name to the list of overrides on the WebApp.
This is a utility method that builders supporting the "Use Theme" functionality use.
A Theme enabled builder can use this method to add override property names that will then show up in the Theme builder's Override drop down list.

Parameters:
webApp - The WebApp to add the override to.
overridePrefix - The name of the override prefix (e.g. orders).
key - The theme property (e.g. ViewAndForm_InputPageBase).

getBoolean

public static boolean getBoolean(WebApp webApp,
                                 java.lang.String overridePrefix,
                                 java.lang.String key,
                                 boolean defaultValue)
Gets the theme property value from the current WebApp theme. This will first build an override key using overridePrefix + "_" + key, if that is not found then the key itself will be used for the lookup.

Parameters:
webApp - The current WebApp or null to access global theme.
overridePrefix - A prefix used to build override key(e.g. orders)..
key - The property name (e.g. ViewAndForm_InputPageBase).
defaultValue - the value to use if there is no Theme property found.
Returns:
The override value if found, else just the key value if found, or the specified default value.

getNames

public java.util.List getNames()
Description copied from interface: PropertyAccess
Gets a list of the property names.

Specified by:
getNames in interface PropertyAccess
Returns:
A list of the property names.

getString

public java.lang.String getString(java.lang.String key)
Description copied from interface: PropertyAccess
Gets the String value of the specified property key.

Specified by:
getString in interface PropertyAccess
Parameters:
key - The key to get the property for.
Returns:
The String property value of null if not found.

getString

public static java.lang.String getString(WebApp webApp,
                                         java.lang.String key)
Gets the theme property value from the current WebApp theme.

Parameters:
webApp - The current WebApp or null to access global theme.
key - The property name (e.g. ViewAndForm_InputPageBase).
Returns:
The result value if available or null.

getString

public static java.lang.String getString(WebApp webApp,
                                         java.lang.String key,
                                         java.lang.String defaultValue)
Gets the theme property value from the current WebApp theme.

Parameters:
webApp - The current WebApp or null to access global theme.
key - The property name (e.g. ViewAndForm_InputPageBase).
defaultValue - The value to use if there is no Theme property found.
Returns:
The result if available or the default value.

getString

public static java.lang.String getString(WebApp webApp,
                                         java.lang.String overridePrefix,
                                         java.lang.String key,
                                         java.lang.String defaultValue)
Gets the theme property value from the current WebApp theme. This will first build an override key using overridePrefix + "_" + key, if that is not found then the key itself will be used for the lookup.

Parameters:
webApp - The current WebApp or null to access global theme.
overridePrefix - A prefix used to build override key(e.g. orders)..
key - The property name (e.g. ViewAndForm_InputPageBase).
defaultValue - the value to use if there is no Theme property found.
Returns:
The override value if found, else just the key value if found, or the specified default value. The example below is showing how to Theme enable the InputPageURL input of the builder call. It is also publishing an override name so that an individual instance of the builder can have a theme property set (Using Theme builder).
In this example the Theme property name "MySampleBuilder_PageBase" is used to specify a value for the builder's InputPageURL.
This is also allowing for a unique version of the "MySampleBuilder_PageBase" to be specified by using the builder call name as a prefix. For example if the builder call name was "addOrder" then the unique name will be "addOrder_MySampleBuilder_PageBase".
Example:
public static final String MY_SAMPLE_BUILDER_FORM_BASE = "MySampleBuilder_PageBase"; 

   public void doBuilderCall(GenContext genContext, WebApp webApp, BuilderCall builderCall, BuilderInputs builderInputs)
   {
       .....
       String name = builderInputs.getString(Constants.Name, null);
       String inputPageURL = builderInputs.getString(Constants.InputPageURL, null);
       boolean useTheme = builderInputs.getBoolean(Constants.UseTheme, false);
       
       .....
       .....
       
       // if theme is enabled then override input value with the ones from the Theme
       if(useTheme)
       {
           inputPageURL = Theme.getString(webApp, name, MY_SAMPLE_BUILDER_FORM_BASE, inputPageURL);   
           
           // publish the names for use at designtime in the Theme builder
           if(genContext.isDesignTime())
           {
               Theme.addThemeOverride(webApp, name, MY_SAMPLE_BUILDER_FORM_BASE); 
           }
       }
       .....    
       .....   
   }

isDefault

public boolean isDefault()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009 IBM. All Rights Reserved.