Source Code Cross Referenced for StyleBean.java in  » Content-Management-System » contineo » org » contineo » web » 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 » Content Management System » contineo » org.contineo.web 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.contineo.web;
002:
003:        import net.sf.opentranquera.xkins.core.Path;
004:        import net.sf.opentranquera.xkins.core.Skin;
005:        import net.sf.opentranquera.xkins.core.Xkins;
006:
007:        import org.contineo.web.util.Constants;
008:
009:        import java.util.ArrayList;
010:        import java.util.HashMap;
011:        import java.util.Iterator;
012:        import java.util.List;
013:        import java.util.Map;
014:
015:        import javax.faces.context.FacesContext;
016:        import javax.faces.model.SelectItem;
017:
018:        /**
019:         * <p>
020:         * The StyleBean class is the backing bean which manages the demonstrations'
021:         * active theme. There are currently two themes supported by the bean; XP and
022:         * Royale.
023:         * </p>
024:         * <p/>
025:         * <p>
026:         * The webpages' style attributes are modified by changing link in the header of
027:         * the HTML document. The selectInputDate and tree components' styles are
028:         * changed by changing the location of their image src directories.
029:         * </p>
030:         *
031:         * @since 0.3.0
032:         */
033:        public class StyleBean {
034:            // folder icons for the respective themes
035:            public static final String XP_BRANCH_EXPANDED_ICON = "xmlhttp/css/xp/css-images/tree_folder_open.gif";
036:            public static final String XP_BRANCH_CONTRACTED_ICON = "xmlhttp/css/xp/css-images/tree_folder_close.gif";
037:            public static final String XP_SPACER_ICON = "xmlhttp/css/xp/css-images/spacer.gif";
038:
039:            // possible theme choices
040:            private final String XP = "xp";
041:            private final String ROYALE = "royale";
042:
043:            // default theme
044:            private String currentStyle = XP;
045:            private String tempStyle = XP;
046:
047:            // available style list
048:            private ArrayList styleList;
049:
050:            // default theme image directory for selectinputdate and theme.
051:            private String imageDirectory = "./xmlhttp/css/xp/css-images/";
052:
053:            /**
054:             * Creates a new instance of the StyleBean.
055:             */
056:            public StyleBean() {
057:                // initialize the style list
058:                styleList = new ArrayList();
059:                styleList.add(new SelectItem(XP, XP));
060:                styleList.add(new SelectItem(ROYALE, ROYALE));
061:            }
062:
063:            /**
064:             * Gets the current style.
065:             *
066:             * @return current style
067:             */
068:            public String getCurrentStyle() {
069:                return currentStyle;
070:            }
071:
072:            /**
073:             * Sets the current style of the application to one of the predetermined
074:             * themes.
075:             *
076:             * @param currentStyle
077:             */
078:            public void setCurrentStyle(String currentStyle) {
079:                this .tempStyle = currentStyle;
080:            }
081:
082:            /**
083:             * Gets the html needed to insert a valid css link tag.
084:             *
085:             * @return the tag information needed for a valid css link tag
086:             */
087:            public String getStyle() {
088:                String contextPath = FacesContext.getCurrentInstance()
089:                        .getExternalContext().getRequestContextPath();
090:
091:                return "<link rel=\"stylesheet\" type=\"text/css\" href=\""
092:                        + contextPath + "/xmlhttp/css/" + currentStyle + "/"
093:                        + currentStyle + ".css" + "\"></link>";
094:            }
095:
096:            /**
097:             * Gets the image directory to use for the selectinputdate and tree theming.
098:             *
099:             * @return image directory used for theming
100:             */
101:            public String getImageDirectory() {
102:                return imageDirectory;
103:            }
104:
105:            /**
106:             * Applies temp style to to the current style and image directory and
107:             * manually refreshes the icons in the navigation tree. The page will reload
108:             * based on navigation rules to ensure the theme is applied; this is
109:             * necessary because of difficulties encountered by updating the stylesheet
110:             * reference within the <HEAD> of the document.
111:             *
112:             * @return the reload navigation attribute
113:             */
114:            public String changeStyle() {
115:                currentStyle = tempStyle;
116:                imageDirectory = "./xmlhttp/css/" + currentStyle
117:                        + "/css-images/";
118:
119:                return "reload";
120:            }
121:
122:            /**
123:             * Gets a list of available theme names that can be applied.
124:             *
125:             * @return available theme list
126:             */
127:            public List getStyleList() {
128:                return styleList;
129:            }
130:
131:            public static String getPath(String name) {
132:                FacesContext facesContext = FacesContext.getCurrentInstance();
133:                Map application = facesContext.getExternalContext()
134:                        .getApplicationMap();
135:                Xkins xs = (Xkins) application.get(Xkins.ATTR_SKINS);
136:                Skin skin = xs.getSkin(facesContext.getExternalContext()
137:                        .getInitParameter(Constants.SKIN));
138:
139:                return skin.getUrl() + skin.getPath(name).getUrl();
140:            }
141:
142:            public Map getPaths() {
143:                FacesContext facesContext = FacesContext.getCurrentInstance();
144:                Map application = facesContext.getExternalContext()
145:                        .getApplicationMap();
146:                Xkins xs = (Xkins) application.get(Xkins.ATTR_SKINS);
147:                Skin skin = xs.getSkin(facesContext.getExternalContext()
148:                        .getInitParameter(Constants.SKIN));
149:                Map<String, Path> paths = (Map<String, Path>) skin.getPaths();
150:                Map<String, String> fullPaths = new HashMap<String, String>();
151:
152:                for (Iterator iter = paths.keySet().iterator(); iter.hasNext();) {
153:                    String name = (String) iter.next();
154:                    fullPaths.put(name, skin.getUrl()
155:                            + paths.get(name).getUrl());
156:                }
157:
158:                return fullPaths;
159:            }
160:
161:            public String getImagesPath() {
162:                return StyleBean.getPath("images");
163:            }
164:
165:            public String getCssPath() {
166:                return StyleBean.getPath("css");
167:            }
168:
169:            public static String getImagePath(String imageName) {
170:                return StyleBean.getPath("images").substring(1) + "/"
171:                        + imageName;
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.