You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/05/07 17:48:01 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/pull/util UIManager.java

henning     2003/05/07 08:48:01

  Modified:    src/java/org/apache/turbine/services/pull/util
                        UIManager.java
  Log:
  Clean this code up to work with ServerData and DataURI.
  
  Revision  Changes    Path
  1.8       +43 -39    jakarta-turbine-2/src/java/org/apache/turbine/services/pull/util/UIManager.java
  
  Index: UIManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/pull/util/UIManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UIManager.java	4 Apr 2003 14:59:29 -0000	1.7
  +++ UIManager.java	7 May 2003 15:48:01 -0000	1.8
  @@ -66,8 +66,9 @@
   import org.apache.turbine.services.pull.ApplicationTool;
   import org.apache.turbine.services.pull.TurbinePull;
   import org.apache.turbine.services.servlet.TurbineServlet;
  -import org.apache.turbine.util.ContentURI;
   import org.apache.turbine.util.RunData;
  +import org.apache.turbine.util.ServerData;
  +import org.apache.turbine.util.uri.DataURI;
   
   /**
    * UIManager.java
  @@ -102,6 +103,11 @@
    * <p>
    * How to specify skins, how to deal with images,
    * how could this be handled with a web app.
  + * <p>
  + *
  + * This is an application pull tool for the template system. You should <b>not</b>
  + * use it in a normal application!
  + *
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:james_coltman@majorband.co.uk">James Coltman</a>
  @@ -143,7 +149,7 @@
        * Attribute name of skinName value in User's temp hashmap.
        */
       private static final String SKIN_ATTRIBUTE =
  -            "org.apache.turbine.services.pull.util.UIManager.skin";
  +        UIManager.class.getName()+ ".skin";
   
       /**
        * The actual skin being used for the webapp.
  @@ -247,7 +253,7 @@
       /**
        * Retrieve the URL for an image that is part
        * of a skin. The images are stored in the
  -     * WEBAPP/resources/ui/skins/<SKIN>/images
  +     * WEBAPP/resources/ui/skins/&lt;SKIN&gt;/images
        * directory.
        *
        * Use this if for some reason your server name,
  @@ -260,7 +266,8 @@
        */
       public String image(String imageId, RunData data)
       {
  -        ContentURI cu = new ContentURI(data);
  +        DataURI du = new DataURI(data);
  +
           StringBuffer sb = new StringBuffer();
   
           sb.append(resourcesDirectory).
  @@ -271,40 +278,39 @@
                   append("/").
                   append(imageId);
   
  -        return cu.getURI(sb.toString());
  +        du.setScriptName(sb.toString());
  +        return du.getAbsoluteLink();
       }
   
       /**
        * Retrieve the URL for an image that is part
        * of a skin. The images are stored in the
  -     * WEBAPP/resources/ui/skins/<SKIN>/images
  +     * WEBAPP/resources/ui/skins/&lt;SKIN&gt;/images
        * directory.
        */
       public String image(String imageId)
       {
  +        ServerData sd = Turbine.getDefaultServerData();
  +        DataURI du = new DataURI(sd);
  +
           StringBuffer sb = new StringBuffer();
   
  -        sb.append(TurbineServlet.getServerScheme()).
  -                append("://").
  -                append(TurbineServlet.getServerName()).
  -                append(":").
  -                append(TurbineServlet.getServerPort()).
  -                append(TurbineServlet.getContextPath()).
  -                append(resourcesDirectory).
  -                append(SKINS_DIRECTORY).
  -                append("/").
  -                append(getSkin()).
  -                append(IMAGES_DIRECTORY).
  -                append("/").
  -                append(imageId);
  +        sb.append(resourcesDirectory).
  +           append(SKINS_DIRECTORY).
  +           append("/").
  +           append(getSkin()).
  +           append(IMAGES_DIRECTORY).
  +           append("/").
  +           append(imageId);
   
  -        return sb.toString();
  +        du.setScriptName(sb.toString());
  +        return du.getAbsoluteLink();
       }
   
       /**
        * Retrieve the URL for the style sheet that is part
        * of a skin. The style is stored in the
  -     * WEBAPP/resources/ui/skins/<SKIN> directory with the
  +     * WEBAPP/resources/ui/skins/&lt;SKIN&gt; directory with the
        * filename skin.css
        *
        * Use this if for some reason your server name,
  @@ -317,7 +323,7 @@
        */
       public String getStylecss(RunData data)
       {
  -        ContentURI cu = new ContentURI(data);
  +        DataURI du = new DataURI(data);
           StringBuffer sb = new StringBuffer();
   
           sb.append(resourcesDirectory).
  @@ -327,34 +333,32 @@
                   append("/").
                   append(SKIN_CSS_FILE);
   
  -        return cu.getURI(sb.toString());
  +        du.setScriptName(sb.toString());
  +        return du.getAbsoluteLink();
       }
   
       /**
        * Retrieve the URL for the style sheet that is part
        * of a skin. The style is stored in the
  -     * WEBAPP/resources/ui/skins/<SKIN> directory with the
  +     * WEBAPP/resources/ui/skins/&lt;SKIN&gt; directory with the
        * filename skin.css
        */
       public String getStylecss()
       {
  +        ServerData sd = Turbine.getDefaultServerData();
  +        DataURI du = new DataURI(sd);
  +
           StringBuffer sb = new StringBuffer();
   
  -        sb.append(TurbineServlet.getServerScheme()).
  -                append("://").
  -                append(TurbineServlet.getServerName()).
  -                append(":").
  -                append(TurbineServlet.getServerPort()).
  -                append(TurbineServlet.getContextPath()).
  -                append("/").
  -                append(resourcesDirectory).
  -                append(SKINS_DIRECTORY).
  -                append("/").
  -                append(getSkin()).
  -                append("/").
  -                append(SKIN_CSS_FILE);
  +        sb.append(resourcesDirectory).
  +           append(SKINS_DIRECTORY).
  +           append("/").
  +           append(getSkin()).
  +           append("/").
  +           append(SKIN_CSS_FILE);
   
  -        return sb.toString();
  +        du.setScriptName(sb.toString());
  +        return du.getAbsoluteLink();
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org