001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint.style.echo;
020
021 import nextapp.echo.app.MutableStyleSheet;
022 import nextapp.echo.app.WindowPane;
023 import nextapp.echo.app.button.AbstractButton;
024 import nextapp.echo.app.list.AbstractListComponent;
025 import nextapp.echo.app.text.TextComponent;
026
027 /**
028 * An extensible stylesheet that enforces a default look-and-feel for all
029 * Echo components. Can be used as the starting point for applications
030 * built using the framework. We hope this promotes an object-oriented
031 * management of styles for applications.
032 *
033 * <p>It is recommended that you extend from {@link echopoint.Servlet} (in
034 * the webcontainer area) since the base servlet takes care of initialising
035 * default style properties from init parameters.</p>
036 *
037 * <p>This class is based upon the
038 * <a href='http://sptci.com/docs/public/com/sptci/echo/style/StyleSheet.html'>StyleSheet</a>
039 * implementation that <a href='http://sptci.com/'>SPT</a> has used as the
040 * basis for building a number of Echo2/3 applications.</p>
041 *
042 * @author Rakesh Vidyadharan 2009-05-24
043 * @version $Id: EchoStyleSheet.java 208 2009-05-25 02:40:35Z sptrakesh $
044 */
045 public class EchoStyleSheet extends MutableStyleSheet
046 {
047 private static final long serialVersionUID = 1L;
048
049 /**
050 * Initialise the stylesheet.
051 *
052 * @see #init
053 */
054 public EchoStyleSheet()
055 {
056 init();
057 }
058
059 /**
060 * Initialises the default styles for the various components. Sub-classes
061 * should over-ride this method (while still invoking {@code super.init()})
062 * to add additional styles. Alternatively, sub-classes may over-ride the
063 * various component style setting methods as appropriate.
064 */
065 protected void init()
066 {
067 addButtonStyles();
068 addListStyles();
069 addTextComponentStyles();
070 addWindowPaneStyles();
071 }
072
073 /** Add default styles for {@link nextapp.echo.app.button.AbstractButton}s */
074 protected void addButtonStyles()
075 {
076 final AbstractButtonStyle style = new AbstractButtonStyle();
077 addStyle( AbstractButton.class, "", style );
078 addStyle( AbstractButton.class, "Default", style );
079 }
080
081 /** Add default styles for {@link nextapp.echo.app.list.AbstractListComponent}s */
082 protected void addListStyles()
083 {
084 final AbstractListComponentStyle style = new AbstractListComponentStyle();
085 addStyle( AbstractListComponent.class, "", style );
086 addStyle( AbstractListComponent.class, "Default", style );
087 }
088
089 /** Add default styles for {@link nextapp.echo.app.text.TextComponent}s */
090 protected void addTextComponentStyles()
091 {
092 final TextComponentStyle style = new TextComponentStyle();
093 addStyle( TextComponent.class, "", style );
094 addStyle( TextComponent.class, "Default", style );
095 }
096
097 /** Add default styles for {@link nextapp.echo.app.WindowPane}s. */
098 protected void addWindowPaneStyles()
099 {
100 final WindowPaneStyle style = new WindowPaneStyle();
101 addStyle( WindowPane.class, "", style );
102 addStyle( WindowPane.class, "Default", style );
103 }
104 }