Source Code Cross Referenced for DefaultLookAndFeelManager.java in  » Swing-Library » abeille-forms-designer » com » jeta » swingbuilder » gui » lookandfeel » 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 » Swing Library » abeille forms designer » com.jeta.swingbuilder.gui.lookandfeel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 Jeff Tassin
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:
019:        package com.jeta.swingbuilder.gui.lookandfeel;
020:
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:        import java.util.LinkedHashMap;
024:
025:        import javax.swing.LookAndFeel;
026:        import javax.swing.UIManager;
027:
028:        import com.jeta.forms.gui.common.URLClassLoaderHelper;
029:        import com.jeta.forms.logger.FormsLogger;
030:        import com.jeta.open.gui.utils.JETAToolbox;
031:        import com.jeta.open.i18n.I18N;
032:        import com.jeta.swingbuilder.interfaces.userprops.TSUserPropertiesUtils;
033:
034:        /**
035:         * The look and feel manager for the application.
036:         * 
037:         * @author Jeff Tassin
038:         */
039:        public class DefaultLookAndFeelManager {
040:            /**
041:             * The class loader for all look and feels.
042:             */
043:            private URLClassLoaderHelper m_loader;
044:
045:            /**
046:             * A list of default look and feels. (We use LookAndFeelInfo objects for
047:             * convenience here)
048:             */
049:            private LinkedHashMap m_lafs = new LinkedHashMap();
050:
051:            // public static final String ALLOY = AlloyLoader.class.getName();
052:            public static final String JGOODIES = JGoodiesLoader.class
053:                    .getName();
054:
055:            public static final String DEFAULT = DefaultLoader.class.getName();
056:
057:            public static final String COMPONENT_ID = "look.and.feel.manager";
058:
059:            public static final String CURRENT_LOOK_AND_FEEL = "current.look.and.feel";
060:
061:            /**
062:             * ctor
063:             */
064:            public DefaultLookAndFeelManager() {
065:                loadDefaults();
066:            }
067:
068:            private void createDefaultLookAndFeel(String lfLoader,
069:                    String lfClassName, String lfThemeName, String name) {
070:                LookAndFeelInfo lf = new LookAndFeelInfo(lfLoader, lfClassName,
071:                        lfThemeName, name, lfClassName + "," + lfThemeName);
072:                m_lafs.put(lf.getId(), lf);
073:            }
074:
075:            public LookAndFeelInfo findById(String id) {
076:                return (LookAndFeelInfo) m_lafs.get(id);
077:            }
078:
079:            /**
080:             * Locates a look and feel by the class name.
081:             */
082:            public LookAndFeelInfo findByClass(String className, String theme) {
083:                Iterator iter = m_lafs.values().iterator();
084:                while (iter.hasNext()) {
085:                    LookAndFeelInfo info = (LookAndFeelInfo) iter.next();
086:                    if (theme == null || theme.length() == 0) {
087:                        if (className.equals(info.getLookAndFeelClassName()))
088:                            return info;
089:                    } else {
090:                        if (className.equals(info.getLookAndFeelClassName())
091:                                && theme.equals(info.getTheme()))
092:                            return info;
093:                    }
094:                }
095:                return null;
096:            }
097:
098:            /**
099:             * @return the default look and feel for the application. The following OSes
100:             *         will have the given default look and feel: Linux Java Metal
101:             *         Windows Windows Apple Apple Other Java Metal
102:             */
103:            public LookAndFeelInfo getDefaultLookAndFeel() {
104:                String id = TSUserPropertiesUtils.getString(
105:                        CURRENT_LOOK_AND_FEEL, null);
106:                if (id != null) {
107:                    LookAndFeelInfo info = findById(id);
108:                    if (info != null)
109:                        return info;
110:                }
111:
112:                if (JETAToolbox.isOSX()) {
113:                    return findByClass(LookAndFeelNames.ID_AQUA_LF, null);
114:                } else {
115:                    return findByClass(
116:                            "com.jgoodies.looks.plastic.PlasticXPLookAndFeel",
117:                            "com.jgoodies.looks.plastic.theme.ExperienceBlue");
118:                }
119:            }
120:
121:            public Collection getDefaultLookAndFeels() {
122:                return m_lafs.values();
123:            }
124:
125:            /**
126:             * @return the look and feel
127:             */
128:            public LookAndFeel getLookAndFeel(String lfId) {
129:                try {
130:                    LookAndFeelInfo info = (LookAndFeelInfo) m_lafs.get(lfId);
131:                    if (info != null) {
132:                        return info.getLookAndFeel();
133:                    }
134:                } catch (Exception e) {
135:                    e.printStackTrace();
136:                    // ignore here. null is returned on error
137:                }
138:                return null;
139:            }
140:
141:            private void loadDefaults() {
142:                try {
143:                    /*
144:                     * implement later createDefaultLookAndFeel( ALLOY,
145:                     * "com.incors.plaf.alloy.AlloyLookAndFeel",
146:                     * "com.incors.plaf.alloy.DefaultAlloyTheme",
147:                     * I18N.getLocalizedMessage( "Alloy - Default" ) );
148:                     * createDefaultLookAndFeel( ALLOY,
149:                     * "com.incors.plaf.alloy.AlloyLookAndFeel",
150:                     * "com.incors.plaf.alloy.themes.glass.GlassTheme",
151:                     * I18N.getLocalizedMessage( "Alloy - Glass" ) );
152:                     * createDefaultLookAndFeel( ALLOY,
153:                     * "com.incors.plaf.alloy.AlloyLookAndFeel",
154:                     * "com.incors.plaf.alloy.themes.bedouin.BedouinTheme",
155:                     * I18N.getLocalizedMessage( "Alloy - Desert" ) );
156:                     * createDefaultLookAndFeel( ALLOY,
157:                     * "com.incors.plaf.alloy.AlloyLookAndFeel",
158:                     * "com.incors.plaf.alloy.themes.acid.AcidTheme",
159:                     * I18N.getLocalizedMessage( "Alloy - Acid" ) );
160:                     */
161:
162:                    createDefaultLookAndFeel(
163:                            JGOODIES,
164:                            "com.jgoodies.looks.plastic.PlasticXPLookAndFeel",
165:                            "com.jgoodies.looks.plastic.theme.ExperienceBlue",
166:                            I18N
167:                                    .getLocalizedMessage("PlasticXP - Experience Blue"));
168:
169:                    createDefaultLookAndFeel(
170:                            JGOODIES,
171:                            "com.jgoodies.looks.plastic.PlasticXPLookAndFeel",
172:                            "com.jgoodies.looks.plastic.theme.ExperienceGreen",
173:                            I18N
174:                                    .getLocalizedMessage("PlasticXP - Experience Green"));
175:
176:                    createDefaultLookAndFeel(JGOODIES,
177:                            "com.jgoodies.looks.plastic.PlasticXPLookAndFeel",
178:                            "com.jgoodies.looks.plastic.theme.SkyBlue",
179:                            I18N.getLocalizedMessage("PlasticXP - Sky Blue"));
180:
181:                    createDefaultLookAndFeel(DEFAULT,
182:                            "javax.swing.plaf.metal.MetalLookAndFeel", "", I18N
183:                                    .getLocalizedMessage("Metal"));
184:
185:                    createDefaultLookAndFeel(DEFAULT,
186:                            "org.jvnet.substance.SubstanceLookAndFeel", "",
187:                            I18N.getLocalizedMessage("Substance"));
188:
189:                    UIManager.LookAndFeelInfo[] lfinfo = UIManager
190:                            .getInstalledLookAndFeels();
191:                    if (lfinfo != null) {
192:                        for (int index = 0; index < lfinfo.length; index++) {
193:                            UIManager.LookAndFeelInfo lfi = lfinfo[index];
194:                            createDefaultLookAndFeel(DEFAULT, lfi
195:                                    .getClassName(), "", lfi.getName());
196:                        }
197:                    }
198:
199:                } catch (Exception e) {
200:
201:                }
202:            }
203:
204:            /** sets the look and feel for the given frame and look an feel class name */
205:            public static void setLookAndFeel(LookAndFeelInfo lfinfo) {
206:                try {
207:                    if (lfinfo != null) {
208:                        LookAndFeelLoader loader = lfinfo.getLoaderInstance();
209:                        if (loader != null) {
210:                            loader.setLookAndFeel(lfinfo);
211:                        }
212:                    }
213:                    TSUserPropertiesUtils.setString(CURRENT_LOOK_AND_FEEL,
214:                            lfinfo.getId());
215:                } catch (Exception e) {
216:                    FormsLogger.debug(e);
217:                }
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.