org.apache.turbine.services.pull.util
Class UIManager

java.lang.Object
  |
  +--org.apache.turbine.services.pull.util.UIManager
All Implemented Interfaces:
ApplicationTool

public class UIManager
extends java.lang.Object
implements ApplicationTool

UIManager.java
Manages all UI elements for a Turbine Application. Any UI element can be accessed in any template using the $ui handle (assuming you use the default PullService configuration). So, for example, you could access the background colour for your pages by using $ui.bgcolor

Questions:

What is the best way to allow an application to be skinned. And how to allow the flexible altering of a particular UI element in certain parts of the template hierarchy. For example on one section of your site you might like a certain bgcolor, on another part of your site you might want another. How can be let the designer specify these properties and still use the single $app.ui.bgcolor in all the templates.

It would also be very cool to use some form of inheritence for UI elements. Say a $ui.bgcolor is used in a template where the bgcolor is not set for that part of hierarch, it would be cool if it could find the setting for the bgcolor in the parent directory. So you could override a UI element where you wanted and the system would fall back to the parent when necessary.

How to specify skins, how to deal with images, how could this be handled with a web app.

Version:
$Id: UIManager.java,v 1.2 2001/10/10 13:36:39 jvanzyl Exp $
Author:
Jason van Zyl, James Coltman

Field Summary
private static java.lang.String IMAGES_DIRECTORY
          The name of the directory where images are stored for this skin.
private static java.lang.String resourcesDirectory
          This the resources directory relative to the webapp context.
private static java.lang.String SKIN_ATTRIBUTE
          Attribute name of skinName value in User's temp hashmap.
private static java.lang.String SKIN_CSS_FILE
          The file name for the skin style sheet.
private static java.lang.String SKIN_PROPERTY
          Property tag for the skin that is to be used for the web application.
private static java.lang.String SKIN_PROPERTY_DEFAULT
          Default skin name.
private static java.lang.String SKIN_PROPS_FILE
          The file within the skin directory that actually contains the name/value pairs for the skin.
private  java.lang.String skinName
          The actual skin being used for the webapp.
private static java.util.Properties skinProperties
          Properties to hold the name/value pairs for the skin.
private static java.lang.String SKINS_DIRECTORY
          The location of the skins within the application resources directory.
private static java.lang.String skinsDirectory
          The skins directory.
 
Constructor Summary
UIManager()
           
 
Method Summary
 java.lang.String get(java.lang.String key)
          Retrieve a property from the properties held within the properties file for this skin.
 java.lang.String getSkin()
          Retrieve the skin name.
 java.lang.String getStylecss()
          Retrieve the URL for the style sheet that is part of a skin.
 java.lang.String getStylecss(RunData data)
          Retrieve the URL for the style sheet that is part of a skin.
 java.lang.String image(java.lang.String imageId)
          Retrieve the URL for an image that is part of a skin.
 java.lang.String image(java.lang.String imageId, RunData data)
          Retrieve the URL for an image that is part of a skin.
 void init(java.lang.Object data)
          Initialize the UIManager object.
private  void loadSkin()
          Load the specified skin.
 void refresh()
          This lets the tool know that it should be refreshed.
 void setSkin()
          Set the skin name to the skin from the TR.props file.
protected  void setSkin(RunData data)
          Set the skin name when the tool is configured to be loaded on a per-request basis.
 void setSkin(java.lang.String skinName)
          Set the skin name to the specified skin.
protected  void setSkin(User user)
          Set the skin name when the tool is configured to be loaded on a per-session basis.
static void setSkin(User user, java.lang.String skin)
          Set the skin name user's temp hashmap for the current session.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SKINS_DIRECTORY

private static final java.lang.String SKINS_DIRECTORY
The location of the skins within the application resources directory.

IMAGES_DIRECTORY

private static final java.lang.String IMAGES_DIRECTORY
The name of the directory where images are stored for this skin.

SKIN_PROPERTY

private static final java.lang.String SKIN_PROPERTY
Property tag for the skin that is to be used for the web application.

SKIN_PROPERTY_DEFAULT

private static final java.lang.String SKIN_PROPERTY_DEFAULT
Default skin name. This name actually represents a directory in the WEBAPP/resources/ui/skins directory. There is a file called skin.props which actually contains the name/value pairs.

SKIN_ATTRIBUTE

private static final java.lang.String SKIN_ATTRIBUTE
Attribute name of skinName value in User's temp hashmap.

skinName

private java.lang.String skinName
The actual skin being used for the webapp.

skinsDirectory

private static java.lang.String skinsDirectory
The skins directory.

SKIN_PROPS_FILE

private static final java.lang.String SKIN_PROPS_FILE
The file within the skin directory that actually contains the name/value pairs for the skin.

SKIN_CSS_FILE

private static final java.lang.String SKIN_CSS_FILE
The file name for the skin style sheet.

resourcesDirectory

private static java.lang.String resourcesDirectory
This the resources directory relative to the webapp context. Used for constructing correct URIs for retrieving images in image().

skinProperties

private static java.util.Properties skinProperties
Properties to hold the name/value pairs for the skin.
Constructor Detail

UIManager

public UIManager()
Method Detail

init

public void init(java.lang.Object data)
Initialize the UIManager object.
Specified by:
init in interface ApplicationTool
Parameters:
data - This is null, RunData or User depending upon specified tool scope.

refresh

public void refresh()
This lets the tool know that it should be refreshed. The tool can perform whatever actions are necessary to refresh itself. This is necessary for sane development where you probably want the tools to refresh themselves on every request.
Specified by:
refresh in interface ApplicationTool

get

public java.lang.String get(java.lang.String key)
Retrieve a property from the properties held within the properties file for this skin.

getSkin

public java.lang.String getSkin()
Retrieve the skin name.

image

public java.lang.String image(java.lang.String imageId,
                              RunData data)
Retrieve the URL for an image that is part of a skin. The images are stored in the WEBAPP/resources/ui/skins//images directory. Use this if for some reason your server name, server scheme, or server port change on a per request basis. I'm not sure if this would happend in a load balanced situation. I think in most cases the image(String image) method would probably be enough, but I'm not absolutely positive.

image

public java.lang.String image(java.lang.String imageId)
Retrieve the URL for an image that is part of a skin. The images are stored in the WEBAPP/resources/ui/skins//images directory.

getStylecss

public java.lang.String getStylecss(RunData data)
Retrieve the URL for the style sheet that is part of a skin. The style is stored in the WEBAPP/resources/ui/skins/ directory with the filename skin.css Use this if for some reason your server name, server scheme, or server port change on a per request basis. I'm not sure if this would happend in a load balanced situation. I think in most cases the style() method would probably be enough, but I'm not absolutely positive.

getStylecss

public java.lang.String getStylecss()
Retrieve the URL for the style sheet that is part of a skin. The style is stored in the WEBAPP/resources/ui/skins/ directory with the filename skin.css

loadSkin

private void loadSkin()
Load the specified skin. In development mode this may occur frequently as the skin properties are being changed.

setSkin

public void setSkin()
Set the skin name to the skin from the TR.props file. If the property is not present use the default skin.

setSkin

public void setSkin(java.lang.String skinName)
Set the skin name to the specified skin.
Parameters:
skinName - the skin name to use.

setSkin

protected void setSkin(RunData data)
Set the skin name when the tool is configured to be loaded on a per-request basis. By default it calls getSkin to return the skin specified in TR.properties. Developers can write a subclass of UIManager that overrides this method to determine the skin to use based on information held in the request.
Parameters:
data - a RunData instance

setSkin

protected void setSkin(User user)
Set the skin name when the tool is configured to be loaded on a per-session basis. It the user's temp hashmap contains a value in the attribute specified by the String constant SKIN_ATTRIBUTE then that is returned. Otherwise it calls getSkin to return the skin specified in TR.properties.
Parameters:
user - a User instance

setSkin

public static void setSkin(User user,
                           java.lang.String skin)
Set the skin name user's temp hashmap for the current session.
Parameters:
user - a User instance
skin - the skin name for the session


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.