Source Code Cross Referenced for Theme.java in  » Portal » Open-Portal » com » sun » portal » providers » context » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.providers.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.providers.context;
006:
007:        import com.sun.portal.log.common.PortalLogger;
008:
009:        import java.util.Map;
010:        import java.util.HashMap;
011:        import java.util.Collection;
012:        import java.util.ArrayList;
013:        import java.util.Iterator;
014:        import java.util.logging.Logger;
015:        import java.util.logging.Level;
016:
017:        /**
018:         * A Theme is a collection of visual elements to be used when displaying a
019:         * desktop.  For example, channel background color, font face etc.
020:         * Theme is a global setting (independent of channels) which a user can
021:         * select from a preset list or customizing to his/her perference.
022:         * The global preset list of themes is configured by the administrator and
023:         * it cannot be changed using this API.  The custom theme is the theme
024:         * that each user can manipulate according to his/her perference.  The
025:         * constant CUSTOM_THEME defined in this class is to refer to the custom theme.
026:         * <p>
027:         * Themes are stored as properties accessed through <code>ProviderContext
028:         * </code>.  This class serves as a wrapper over <code>ProviderContext</code>
029:         * to encapsulate the implementation details of theme.
030:         * <p>
031:         * For details of the theme design and steps to configure the global
032:         * preset themes, please refer to the Desktop Customization Guide and the
033:         * Administrator's Guide.
034:         *
035:         @see com.sun.portal.providers.context.ProviderContext
036:         **/
037:
038:        public class Theme {
039:            private static Logger logger = PortalLogger.getLogger(Theme.class);
040:
041:            static private final String USER_THEME = "UserTheme";
042:            static private final String GLOBAL_THEMES = "GlobalThemes";
043:
044:            /**
045:             * Constant refering to the custom theme.
046:             **/
047:            static public final String CUSTOM_THEME = "CustomTheme";
048:
049:            /**
050:             * Gets the theme name to be used for displaying desktop.
051:             *
052:             * The theme can be one from the global preset theme list
053:             * or CUSTOM_THEME for the custom built theme.
054:             *
055:             * @param ProviderContext
056:             * @return the name of the selected theme name as a String.
057:             * @exception  ProviderContextException if an error occurs in getting the
058:             * selected theme name.
059:             **/
060:
061:            static public String getSelectedName(String channel,
062:                    ProviderContext pc) throws ProviderContextException {
063:                return pc.getStringProperty(channel, USER_THEME);
064:            }
065:
066:            /**
067:             * Gets the global list of preset theme that is available.
068:             *
069:             * The list is configured by Portal admin.  The list as well as the
070:             * attributes in those preset themes cannot be changed using this API.
071:             *
072:             * @param ProviderContext
073:             * @return the list of globally defined preset theme as a collection.
074:             * @exception  ProviderContextException if an error occurs in getting the
075:             * global theme names.
076:             **/
077:
078:            static public Collection getGlobal(String channel,
079:                    ProviderContext pc) throws ProviderContextException {
080:                return pc.getCollectionProperty(channel, GLOBAL_THEMES, true)
081:                        .keySet();
082:            }
083:
084:            /**
085:             * Gets the attributes of a theme as a map.
086:             *
087:             * The returned map has the attribute names as the keys and the theme
088:             * values as the values.
089:             *
090:             * @param ProviderContext
091:             * @param theme Theme name, either one from the preset list or <code>
092:             * CUSTOM_THEME</code> for the custom theme.
093:             * @return The map that maps attribute names to attribute values of the theme.
094:             * @exception  ProviderContextException if an error occurs in getting the
095:             * attributes of the theme.
096:             **/
097:
098:            static public Map getMap(String channel, ProviderContext pc,
099:                    String theme) throws ProviderContextException {
100:
101:                Map themeMap = null;
102:                Map themesMap = pc.getCollectionProperty(channel,
103:                        GLOBAL_THEMES, true);
104:                if (theme.equals(CUSTOM_THEME)) {
105:                    themeMap = pc.getCollectionProperty(channel, theme);
106:                } else {
107:                    themeMap = (Map) themesMap.get(theme);
108:                }
109:                if (themeMap == null) {
110:                    logger.fine("PSDT_CSPPCT0001");
111:                    for (Iterator i = themesMap.keySet().iterator(); i
112:                            .hasNext();) {
113:                        String key = (String) i.next();
114:                        themeMap = (Map) themesMap.get(key);
115:                        setSelectedName(channel, pc, key);
116:                        return themeMap;
117:                    }
118:                }
119:                return themeMap;
120:            }
121:
122:            /**
123:             * Gets an attribute value of a theme.
124:             *
125:             *
126:             * @param ProviderContext
127:             * @param theme Theme name, either one from the preset list or <code>
128:             * CUSTOM_THEME</code> for the custom theme.
129:             * @param name Attribute name
130:             * @return the attribute value as a String.
131:             * @exception ProviderContextException if an error occurs getting the attribute, or
132:             * the theme is not <code>CUSTOM_THEME</code> or one in the preset list.
133:             **/
134:
135:            static public String getAttribute(String channel,
136:                    ProviderContext pc, String theme, String name)
137:                    throws ProviderContextException {
138:                return (String) getMap(channel, pc, theme).get(name);
139:            }
140:
141:            /**
142:             * Gets an attribute value of a theme, if the attribute is not
143:             * defined, and a default value is given, then returns the default value.
144:             *
145:             *
146:             * @param ProviderContext
147:             * @param theme Theme name, either one from the preset list or <code>
148:             * CUSTOM_THEME</code> for the custom theme.
149:             * @param name Attribute name
150:             * @param def the default value
151:             * @return the attribute value as a String.
152:             * @exception ProviderContextException if an error occurs getting the attribute, or
153:             * the theme is not <code>CUSTOM_THEME</code> or one in the preset list.
154:             **/
155:
156:            static public String getAttribute(String channel,
157:                    ProviderContext pc, String theme, String name, String def)
158:                    throws ProviderContextException {
159:                String val = (String) getMap(channel, pc, theme).get(name);
160:                if (val == null && def != null) {
161:                    val = def;
162:                }
163:                return val;
164:            }
165:
166:            /**
167:             * Gets an attribute value of the selected theme.
168:             *
169:             *
170:             * @param ProviderContext
171:             * @param name Attribute name
172:             * @return the attribute value as a String
173:             * @exception ProviderContextException if an error occurs getting the attribute.
174:             **/
175:
176:            static public String getAttribute(String channel,
177:                    ProviderContext pc, String name)
178:                    throws ProviderContextException {
179:                return (String) getMap(channel, pc,
180:                        getSelectedName(channel, pc)).get(name);
181:            }
182:
183:            /**
184:             * Sets an attribute value of the custom theme.
185:             *
186:             * This sets a value for the theme named <code>CUSTOM_THEME</code>
187:             *
188:             * @param ProviderContext
189:             * @param name Attribute name
190:             * @param value Attribute value
191:             **/
192:
193:            static public void setCustomAttribute(String channel,
194:                    ProviderContext pc, String name, String value) {
195:                try {
196:                    Map customThemeMap = pc.getCollectionProperty(channel,
197:                            CUSTOM_THEME);
198:                    customThemeMap.put(name, value);
199:                    pc.setCollectionProperty(channel, CUSTOM_THEME,
200:                            customThemeMap);
201:                    pc.allContentChanged();
202:                } catch (ProviderContextException pce) {
203:                    logger.log(Level.INFO, "PSDT_CSPPCT0002", pce);
204:                }
205:            }
206:
207:            /**
208:             * Sets the theme to be used for displaying desktop.
209:             *
210:             * @param ProviderContext
211:             * @param name Theme name, either one from the preset list or <code>
212:             * CUSTOM_THEME</code> for the custom theme.
213:             * @exception  ProviderContextException if an error occurs in setting the
214:             * selected theme name.
215:             **/
216:
217:            static public void setSelectedName(String channel,
218:                    ProviderContext pc, String name)
219:                    throws ProviderContextException {
220:                pc.setStringProperty(channel, USER_THEME, name);
221:                pc.allContentChanged();
222:            }
223:
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.