001: //WebOnSwing - Web Application Framework
002: //Copyright (C) 2004 Fernando Damian Petrola
003: //
004: //This library is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU Lesser General Public
006: //License as published by the Free Software Foundation; either
007: //version 2.1 of the License, or (at your option) any later version.
008: //
009: //This library is distributed in the hope that it will be useful,
010: //but WITHOUT ANY WARRANTY; without even the implied warranty of
011: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: //Lesser General Public License for more details.
013: //
014: //You should have received a copy of the GNU Lesser General Public
015: //License along with this library; if not, write to the Free Software
016: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: package net.ar.webonswing.managers.skins;
019:
020: import java.util.*;
021:
022: import net.ar.webonswing.*;
023: import net.ar.webonswing.render.templates.*;
024: import net.ar.webonswing.swing.layouts.*;
025:
026: import org.apache.commons.lang.*;
027:
028: public class Skin {
029: protected String name;
030: protected Hashtable aliases = new Hashtable();
031: protected String imagesPath;
032: protected String cssPath;
033: protected String defaultImageExtension;
034:
035: public Skin(String aName, String aPath,
036: String aDefaultImageExtension, String aCssPath) {
037: name = aName;
038: setImagesPath(aPath);
039: setCssPath(aCssPath);
040: defaultImageExtension = aDefaultImageExtension;
041: }
042:
043: public void addAlias(String anAlias, String aName) {
044: aliases.put(anAlias, aName);
045: }
046:
047: public String getName(String anAlias) {
048: String value = (String) aliases.get(anAlias);
049:
050: if (value == null) {
051: value = name + "-" + anAlias;
052:
053: for (Iterator i = aliases.keySet().iterator(); i.hasNext();) {
054: String key = (String) i.next();
055:
056: if (anAlias.startsWith(key))
057: value = StringUtils.replace(anAlias, key,
058: (String) aliases.get(key));
059: }
060: }
061:
062: return value;
063: }
064:
065: public boolean equals(Object aObj) {
066: if (aObj instanceof Skin) {
067: Skin otherSkin = (Skin) aObj;
068: return otherSkin.name.equals(name);
069: } else
070: return false;
071: }
072:
073: public KeyPositionTemplate getCurrentTemplateFor(String anAlias) {
074: return WosFramework
075: .getKeyPositionTemplateForName(getName(anAlias));
076: }
077:
078: public PropagateTemplateLayoutByName getCurrentPropagateTemplateFor(
079: String anAlias) {
080: return WosFramework
081: .getPropagateTemplateLayoutByNameFor(getName(anAlias));
082: }
083:
084: public void setImagesPath(String aPath) {
085: imagesPath = aPath;
086: }
087:
088: public String getImagesPath() {
089: return imagesPath;
090: }
091:
092: public String getDefaultImageExtension() {
093: return defaultImageExtension;
094: }
095:
096: public void setDefaultImageExtension(String aDefaultImageExtension) {
097: defaultImageExtension = aDefaultImageExtension;
098: }
099:
100: public Hashtable getAliases() {
101: return aliases;
102: }
103:
104: public void setAliases(Hashtable aAliases) {
105: aliases = aAliases;
106: }
107:
108: public String getCssPath() {
109: return cssPath;
110: }
111:
112: public void setCssPath(String aCssPath) {
113: cssPath = aCssPath;
114: }
115:
116: public String getName() {
117: return name;
118: }
119:
120: public void setName(String aName) {
121: name = aName;
122: }
123:
124: public String toString() {
125: return name;
126: }
127: }
|