001: /**
002: * $Id: ProviderUtility.java,v 1.3 2005/09/21 11:28:43 dg154973 Exp $
003: * Copyright 2003 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms andx1
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wireless.providers.util;
014:
015: import java.util.*;
016: import java.util.logging.Level;
017: import java.util.logging.Logger;
018:
019: import com.sun.portal.providers.*;
020: import com.sun.portal.providers.util.ProviderProperties;
021: import com.sun.portal.providers.context.*;
022: import com.sun.portal.log.common.PortalLogger;
023:
024: /**
025: * Provides access to common methods for use by the providers.
026: */
027: public class ProviderUtility {
028:
029: private static Logger logger = PortalLogger
030: .getLogger(ProviderUtility.class);
031:
032: /**
033: * This method sets default presentation values based on a providers theme.
034: * @param tagTable The tagTable that you want to set default values in
035: * @return The hashtable with the following values set
036: * bgColor Background Color
037: * borderWidth Border width for a table
038: * titleBarColor Color for a table section
039: * titleFontColor Color for a font
040: * borderColor Color for a table border
041: * fontFace Font style
042: * fontColor Font color
043: */
044:
045: public static Hashtable setDefaultPresentation(String provName,
046: ProviderContext pc, Hashtable tagTable)
047: throws ProviderContextException {
048: String attr = "";
049: attr = Theme.getAttribute(provName, pc,
050: ProviderProperties.BG_COLOR);
051: if (logger.isLoggable(Level.FINEST)) {
052: String[] param = { "bgcolor", attr };
053: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
054: }
055:
056: if (!((attr == null) || (attr.equals("")))) {
057: tagTable.put("bgColor", attr);
058: } else {
059: tagTable.put("bgColor", "#FFFFFF");
060: }
061:
062: attr = Theme.getAttribute(provName, pc,
063: ProviderProperties.BORDER_WIDTH);
064: if (logger.isLoggable(Level.FINEST)) {
065: String[] param = { "borderWidth", attr };
066: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
067: }
068:
069: if (!((attr == null) || (attr.equals("")))) {
070: tagTable.put("borderWidth", attr);
071: } else {
072: tagTable.put("borderWidth", "0");
073: }
074:
075: attr = Theme.getAttribute(provName, pc,
076: ProviderProperties.FONT_FACE);
077: if (logger.isLoggable(Level.FINEST)) {
078: String[] param = { "fontFace", attr };
079: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
080: }
081: if (!((attr == null) || (attr.equals("")))) {
082: tagTable.put("fontFace", attr);
083:
084: } else {
085: tagTable.put("fontFace", "Sans-serif");
086: }
087:
088: attr = Theme.getAttribute(provName, pc,
089: ProviderProperties.TITLE_BAR_COLOR);
090: if (logger.isLoggable(Level.FINEST)) {
091: String[] param = { "titleBarColor", attr };
092: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
093: }
094: if (!((attr == null) || (attr.equals("")))) {
095: tagTable.put("titleBarColor", attr);
096: } else {
097: tagTable.put("titleBarColor", "#666699");
098: }
099:
100: attr = Theme.getAttribute(provName, pc,
101: ProviderProperties.TITLE_FONT_COLOR);
102: if (logger.isLoggable(Level.FINEST)) {
103: String[] param = { "titleFontColor", attr };
104: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
105: }
106: if (!((attr == null) || (attr.equals("")))) {
107: tagTable.put("titleFontColor", attr);
108: } else {
109: tagTable.put("titleFontColor", "#FFFFFF");
110: }
111:
112: attr = Theme.getAttribute(provName, pc,
113: ProviderProperties.BORDER_COLOR);
114: if (logger.isLoggable(Level.FINEST)) {
115: String[] param = { "borderColor", attr };
116: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
117: }
118:
119: if (!((attr == null) || (attr.equals("")))) {
120: tagTable.put("borderColor", attr);
121: } else {
122: tagTable.put("borderColor", "#666699");
123: }
124:
125: attr = Theme.getAttribute(provName, pc,
126: ProviderProperties.FONT_COLOR);
127:
128: if (logger.isLoggable(Level.FINEST)) {
129: String[] param = { "fontColor", attr };
130: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
131: }
132:
133: if (!((attr == null) || (attr.equals("")))) {
134: tagTable.put("fontColor", attr);
135: } else {
136: tagTable.put("fontColor", "#000000");
137: }
138:
139: attr = Theme.getAttribute(provName, pc,
140: ProviderProperties.CHANNELS_BACKGROUND_COLOR);
141: if (logger.isLoggable(Level.FINEST)) {
142: String[] param = { "channelBgColor", attr };
143: logger.log(Level.FINEST, "PSMA_CSPWPU0001", param);
144: }
145: if (!((attr == null) || (attr.equals("")))) {
146: tagTable.put("channelBgColor", attr);
147: } else {
148: tagTable.put("channelBgColor", "#FFFFFF");
149: }
150: return tagTable;
151: }
152: }
|