Source Code Cross Referenced for MetalLookAndFeelController.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » laf » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.laf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.laf;
002:
003:        /*
004:         * Copyright (C) 2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:        import java.util.Iterator;
022:        import java.util.Vector;
023:
024:        import javax.swing.*;
025:        import javax.swing.plaf.metal.DefaultMetalTheme;
026:        import javax.swing.plaf.metal.MetalLookAndFeel;
027:        import javax.swing.plaf.metal.MetalTheme;
028:
029:        import net.sourceforge.squirrel_sql.fw.util.DuplicateObjectException;
030:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
031:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
032:        import net.sourceforge.squirrel_sql.fw.xml.XMLObjectCache;
033:        import net.sourceforge.squirrel_sql.client.Version;
034:
035:        /**
036:         * Behaviour for the jGoodies Plastic Look and Feel. It also takes
037:         * responsibility for the metal Look and Feel.
038:         *
039:         * @author  <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
040:         */
041:        class MetalLookAndFeelController extends AbstractPlasticController {
042:            /** Logger for this class. */
043:            private static ILogger s_log = LoggerController
044:                    .createLogger(MetalLookAndFeelController.class);
045:
046:            static final String METAL_LAF_CLASS_NAME = MetalLookAndFeel.class
047:                    .getName();
048:
049:            private String[] _extraThemeClassNames = new String[0];
050:
051:            /** Preferences for this LAF. */
052:            private MetalThemePreferences _prefs;
053:
054:            private MetalTheme _defaultMetalTheme;
055:
056:            /**
057:             * Ctor specifying the Look and Feel plugin and register.
058:             * 
059:             * @param	plugin		The plugin that this controller is a part of.
060:             * @param	lafRegister	LAF register.
061:             */
062:            MetalLookAndFeelController(LAFPlugin plugin, LAFRegister lafRegister) {
063:
064:                super (plugin, lafRegister);
065:                if (Version.isJDK14()) {
066:                    _extraThemeClassNames = new String[] {
067:                            ////////////////////////////////////////////////////////////////////
068:                            // These classes have no package see swingsetthemes.jar
069:                            "AquaTheme", "CharcoalTheme", "ContrastTheme",
070:                            "EmeraldTheme", "RubyTheme",
071:                            //
072:                            ///////////////////////////////////////////////////////////////////
073:
074:                            /////////////////////////////////////////////////////////////////////////////
075:                            // This theme was presented to SQuirreL by Karsten Lentzsch of jgoodies.com.
076:                            // It is SQuirreL's default theme if the LAF plugin is not used.
077:                            // Here we make the AllBluesBoldMetalTheme also available within the LAF plugin.
078:                            // Thanks a lot Karsten.
079:                            "net.sourceforge.squirrel_sql.client.gui.laf.AllBluesBoldMetalTheme"
080:                    //
081:                    ////////////////////////////////////////////////////////////////////////////
082:                    };
083:                } else {
084:                    _extraThemeClassNames = new String[] {
085:                            "javax.swing.plaf.metal.OceanTheme", // Only available with JDK 1.5
086:                            ////////////////////////////////////////////////////////////////////
087:                            // These classes have no package see swingsetthemes.jar
088:                            "AquaTheme", "CharcoalTheme", "ContrastTheme",
089:                            "EmeraldTheme", "RubyTheme",
090:                            //
091:                            ///////////////////////////////////////////////////////////////////
092:
093:                            /////////////////////////////////////////////////////////////////////////////
094:                            // This theme was presented to SQuirreL by Karsten Lentzsch of jgoodies.com.
095:                            // It is SQuirreL's default theme if the LAF plugin is not used.
096:                            // Here we make the AllBluesBoldMetalTheme also available within the LAF plugin.
097:                            // Thanks a lot Karsten.
098:                            "net.sourceforge.squirrel_sql.client.gui.laf.AllBluesBoldMetalTheme"
099:                    //
100:                    ////////////////////////////////////////////////////////////////////////////
101:
102:                    };
103:                }
104:
105:                _defaultMetalTheme = new DefaultMetalTheme();
106:
107:                XMLObjectCache cache = plugin.getSettingsCache();
108:                Iterator<?> it = cache
109:                        .getAllForClass(MetalThemePreferences.class);
110:                if (it.hasNext()) {
111:                    _prefs = (MetalThemePreferences) it.next();
112:                } else {
113:                    _prefs = new MetalThemePreferences();
114:                    try {
115:                        cache.add(_prefs);
116:                    } catch (DuplicateObjectException ex) {
117:                        s_log
118:                                .error(
119:                                        "MetalThemePreferences object already in XMLObjectCache",
120:                                        ex);
121:                    }
122:                }
123:            }
124:
125:            /**
126:             * Retrieve extra themes for this Look and Feel.
127:             * 
128:             * @return	The default metal theme. 
129:             */
130:            MetalTheme[] getExtraThemes() {
131:                ClassLoader cl = getLAFRegister().getLookAndFeelClassLoader();
132:
133:                Vector<MetalTheme> ret = new Vector<MetalTheme>();
134:
135:                boolean defaultThemeIsIncluded = false;
136:
137:                for (int i = 0; i < _extraThemeClassNames.length; ++i) {
138:                    try {
139:                        Class<?> clazz = Class.forName(
140:                                _extraThemeClassNames[i], false, cl);
141:                        ret.add((MetalTheme) clazz.newInstance());
142:
143:                        if (null != _defaultMetalTheme
144:                                && _extraThemeClassNames[i]
145:                                        .equals(_defaultMetalTheme.getClass()
146:                                                .getName())) {
147:                            defaultThemeIsIncluded = true;
148:                        }
149:                    } catch (Throwable th) {
150:                        s_log.error("Error loading theme "
151:                                + _extraThemeClassNames[i], th);
152:                    }
153:                }
154:
155:                if (false == defaultThemeIsIncluded) {
156:                    ret.add(_defaultMetalTheme);
157:                }
158:
159:                return ret.toArray(new MetalTheme[ret.size()]);
160:            }
161:
162:            void installCurrentTheme(LookAndFeel laf, MetalTheme theme) {
163:                // This works only on JDK 1.5
164:                // With JDK 1.4.x fonts will be bold for all SwingSet themes.
165:                // See also SwingSet2 demos in JDK 1.4 and JDK 1.5
166:                UIManager.put("swing.boldMetal", Boolean.FALSE);
167:
168:                MetalLookAndFeel.setCurrentTheme(theme);
169:            }
170:
171:            /**
172:             * Retrieve the name of the current theme.
173:             * 
174:             * @return	Name of the current theme.
175:             */
176:            String getCurrentThemeName() {
177:                return _prefs.getThemeName();
178:            }
179:
180:            /**
181:             * Set the current theme name.
182:             * 
183:             * @param name		name of the current theme.
184:             */
185:            void setCurrentThemeName(String name) {
186:                _prefs.setThemeName(name);
187:            }
188:
189:            /**
190:             * Preferences for the Metal LAF. Subclassed purely to give it a
191:             * different data type when stored in the plugin preferences so that it
192:             * doesn't get mixed up with preferences for other subclasses of
193:             * AbstractPlasticController
194:             */
195:            public static final class MetalThemePreferences extends
196:                    AbstractPlasticController.ThemePreferences {
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.