Source Code Cross Referenced for PlasticLookAndFeelController.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-2006 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:
023:        import javax.swing.LookAndFeel;
024:        import javax.swing.plaf.metal.MetalLookAndFeel;
025:        import javax.swing.plaf.metal.MetalTheme;
026:
027:        import net.sourceforge.squirrel_sql.fw.util.BaseException;
028:        import net.sourceforge.squirrel_sql.fw.util.DuplicateObjectException;
029:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
030:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
031:        import net.sourceforge.squirrel_sql.fw.xml.XMLObjectCache;
032:
033:        /**
034:         * Behaviour for the jGoodies Plastic Look and Feel.
035:         *
036:         * @author  <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
037:         */
038:        class PlasticLookAndFeelController extends AbstractPlasticController {
039:            /** Logger for this class. */
040:            private static ILogger s_log = LoggerController
041:                    .createLogger(PlasticLookAndFeelController.class);
042:
043:            /**
044:             * Look and Feel class names that this controller is responsible for.
045:             */
046:            static final String[] LAF_CLASS_NAMES = new String[] {
047:                    "com.jgoodies.looks.plastic.PlasticLookAndFeel",
048:                    "com.jgoodies.looks.plastic.Plastic3DLookAndFeel",
049:                    "com.jgoodies.looks.plastic.PlasticXPLookAndFeel", };
050:
051:            public static final String DEFAULT_LOOK_AND_FEEL_CLASS_NAME = LAF_CLASS_NAMES[1];
052:
053:            /** Base class for all Plastic themes. */
054:            private static final String THEME_BASE_CLASS = "com.jgoodies.looks.plastic.PlasticTheme";
055:
056:            /** Preferences for this LAF. */
057:            private PlasticThemePreferences _prefs;
058:
059:            /**
060:             * Ctor specifying the Look and Feel plugin and register.
061:             * 
062:             * @param	plugin	The plugin that this controller is a part of.
063:             * @param	lafRegister	LAF register.
064:             */
065:            PlasticLookAndFeelController(LAFPlugin plugin,
066:                    LAFRegister lafRegister) {
067:                super (plugin, lafRegister);
068:                try {
069:
070:                    XMLObjectCache cache = plugin.getSettingsCache();
071:                    Iterator<?> it = cache
072:                            .getAllForClass(PlasticThemePreferences.class);
073:                    if (it.hasNext()) {
074:                        _prefs = (PlasticThemePreferences) it.next();
075:                    } else {
076:                        _prefs = new PlasticThemePreferences();
077:
078:                        ClassLoader cl = getLAFRegister()
079:                                .getLookAndFeelClassLoader();
080:                        Class<?> clazz = Class
081:                                .forName(
082:                                        AbstractPlasticController.DEFAULT_PLASTIC_THEME_CLASS_NAME,
083:                                        false, cl);
084:                        MetalTheme theme = (MetalTheme) clazz.newInstance();
085:                        _prefs.setThemeName(theme.getName());
086:
087:                        try {
088:                            cache.add(_prefs);
089:                        } catch (DuplicateObjectException ex) {
090:                            s_log
091:                                    .error(
092:                                            "PlasticThemePreferences object already in XMLObjectCache",
093:                                            ex);
094:                        }
095:                    }
096:                } catch (Exception e) {
097:                    throw new RuntimeException(e);
098:                }
099:            }
100:
101:            /**
102:             * Retrieve the name of the current theme.
103:             * 
104:             * @return	Name of the current theme.
105:             */
106:            String getCurrentThemeName() {
107:                return _prefs.getThemeName();
108:            }
109:
110:            /**
111:             * Set the current theme name.
112:             * 
113:             * @param name		name of the current theme.
114:             */
115:            void setCurrentThemeName(String name) {
116:                _prefs.setThemeName(name);
117:            }
118:
119:            void installCurrentTheme(LookAndFeel laf, MetalTheme theme)
120:                    throws BaseException {
121:                try {
122:                    ClassLoader cl = getLAFRegister()
123:                            .getLookAndFeelClassLoader();
124:                    Class<?> themeBaseClass;
125:                    try {
126:                        themeBaseClass = Class.forName(THEME_BASE_CLASS, false,
127:                                cl);
128:                    } catch (Throwable th) {
129:                        s_log.error("Error loading theme base class "
130:                                + THEME_BASE_CLASS, th);
131:                        throw new BaseException(th);
132:                    }
133:
134:                    // Ensure that this is a Plastic Theme.
135:                    if (!themeBaseClass.isAssignableFrom(theme.getClass())) {
136:                        throw new BaseException("NonPlastic Theme passed in");
137:                    }
138:
139:                    // Note: which jar is used is specified in LAFPluginResources.properties
140:                    //         try
141:                    //         {
142:                    //            // This works for the old looks-1.3.1.jar
143:                    //            Method method = laf.getClass().getMethod("setMyCurrentTheme", new Class[] { themeBaseClass });
144:                    //            Object[] parms = new Object[] { theme };
145:                    //            method.invoke(laf, parms);
146:                    //         }
147:                    //         catch (NoSuchMethodException e)
148:                    //         {
149:                    //            // This works for the newer looks.jar
150:                    //            MetalLookAndFeel.setCurrentTheme(theme);
151:                    //         }
152:                    MetalLookAndFeel.setCurrentTheme(theme);
153:                } catch (Throwable th) {
154:                    throw new BaseException(th);
155:                }
156:            }
157:
158:            /**
159:             * Preferences for the Plastic LAFs. Subclassed purely to give it a
160:             * different data type when stored in the plugin preferences so that it
161:             * doesn't get mixed up with preferences for other subclasses of
162:             * AbstractPlasticController
163:             */
164:            public static final class PlasticThemePreferences extends
165:                    AbstractPlasticController.ThemePreferences {
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.