001    package com.sptci.echo2;
002    
003    import java.io.InputStream;
004    
005    import nextapp.echo2.app.ImageReference;
006    import nextapp.echo2.app.ResourceImageReference;
007    import nextapp.echo2.app.StyleSheet;
008    import nextapp.echo2.app.componentxml.ComponentXmlException;
009    import nextapp.echo2.app.componentxml.StyleSheetLoader;
010    
011    /**
012     * Utility class to load the application style XML file.  This class
013     * assumes that the style file will be available as
014     * <code>/META-INF/resource/style/Default.stylesheet</code>.
015     *
016     * <p>Copyright 2006 Sans Pareil Technologies, Inc.</p>
017     * @author Rakesh Vidyadharan 2006-01-21
018     * @version $Id: Styles.java,v 1.1 2006/02/06 00:32:23 rakesh Exp $
019     */
020    public class Styles 
021    {
022      /**
023       * The location of the application images.
024       *
025       * {@value}
026       */
027      public static final String IMAGE_PATH = 
028        "/META-INF/resource/image/";
029    
030      /**
031       * The location of the XML style sheet.
032       *
033       * {@value}
034       */
035      public static final String STYLE_PATH = 
036        "/META-INF/resource/style/";
037      
038      /**
039       * Default application style sheet.
040       */
041      public static final StyleSheet DEFAULT_STYLE_SHEET;
042    
043      /**
044       * Initialise the default style sheet.
045       */
046      static 
047      {
048        try 
049        {
050          DEFAULT_STYLE_SHEET = 
051            StyleSheetLoader.load( 
052                getStyleInputStream( "Default.stylesheet" ), 
053                Thread.currentThread().getContextClassLoader() );
054        } 
055        catch ( ComponentXmlException ex )
056        {
057          throw new BindingException( ex );
058        }
059      }
060    
061      /**
062       * Open the {@link #STYLE_PATH} as a resource stream and return
063       * the <code>InputStream</code> to it.
064       *
065       * @param file The name of the style sheet to open
066       * @return InputStream The InputStream for the style sheet.
067       */
068      protected static InputStream getStyleInputStream( String file )
069      {
070        Class cls = com.sptci.echo2.Styles.class;
071        return cls.getResourceAsStream( STYLE_PATH + file );
072      }
073    }