Source Code Cross Referenced for OyoahaLookAndFeelController.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.awt.GridBagConstraints;
022:        import java.awt.GridBagLayout;
023:        import java.awt.Insets;
024:        import java.io.File;
025:        import java.io.IOException;
026:        import java.lang.reflect.Method;
027:        import java.util.Iterator;
028:
029:        import javax.swing.JLabel;
030:        import javax.swing.LookAndFeel;
031:        import javax.swing.SwingConstants;
032:
033:        import net.sourceforge.squirrel_sql.fw.gui.DirectoryListComboBox;
034:        import net.sourceforge.squirrel_sql.fw.gui.OutputLabel;
035:        import net.sourceforge.squirrel_sql.fw.id.IHasIdentifier;
036:        import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
037:        import net.sourceforge.squirrel_sql.fw.id.IntegerIdentifier;
038:        import net.sourceforge.squirrel_sql.fw.util.DuplicateObjectException;
039:        import net.sourceforge.squirrel_sql.fw.util.FileExtensionFilter;
040:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
041:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
042:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
043:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
044:        import net.sourceforge.squirrel_sql.fw.xml.XMLObjectCache;
045:
046:        /**
047:         * Behaviour for the Oyoaha Look and Feel.
048:         *
049:         * @author  <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
050:         */
051:        public class OyoahaLookAndFeelController extends
052:                DefaultLookAndFeelController {
053:            private static final StringManager s_stringMgr = StringManagerFactory
054:                    .getStringManager(OyoahaLookAndFeelController.class);
055:
056:            /** Logger for this class. */
057:            private static ILogger s_log = LoggerController
058:                    .createLogger(OyoahaLookAndFeelController.class);
059:
060:            /** Class name of the Oyoaha Look and Feel. */
061:            public static final String OA_LAF_CLASS_NAME = "com.oyoaha.swing.plaf.oyoaha.OyoahaLookAndFeel";
062:
063:            /** Preferences for this LAF. */
064:            private OyoahaPreferences _prefs;
065:
066:            /**
067:             * Ctor specifying the Look and Feel plugin.
068:             * 
069:             * @param	plugin	The plugin that this controller is a part of.
070:             */
071:            OyoahaLookAndFeelController(LAFPlugin plugin) throws IOException {
072:                super ();
073:
074:                XMLObjectCache cache = plugin.getSettingsCache();
075:                Iterator<?> it = cache.getAllForClass(OyoahaPreferences.class);
076:                if (it.hasNext()) {
077:                    _prefs = (OyoahaPreferences) it.next();
078:                } else {
079:                    _prefs = new OyoahaPreferences();
080:                    try {
081:                        cache.add(_prefs);
082:                    } catch (DuplicateObjectException ex) {
083:                        s_log
084:                                .error(
085:                                        "OyoahaPreferences object already in XMLObjectCache",
086:                                        ex);
087:                    }
088:                }
089:
090:                // Folder that stores themepacks for this LAF.
091:                File themePackDir = new File(plugin
092:                        .getPluginAppSettingsFolder(), "oyoaha-theme-packs");
093:                _prefs.setThemePackDirectory(themePackDir.getAbsolutePath());
094:                if (!themePackDir.exists()) {
095:                    themePackDir.mkdirs();
096:                }
097:            }
098:
099:            /**
100:             * This Look and Feel is about to be installed. Load the selected
101:             * themepack.
102:             */
103:            public void aboutToBeInstalled(LAFRegister lafRegister,
104:                    LookAndFeel laf) {
105:                try {
106:                    final String dir = _prefs.getThemePackDirectory();
107:                    final String name = _prefs.getThemePackName();
108:                    if (dir != null && name != null) {
109:                        File themePackFile = new File(dir, name);
110:                        if (themePackFile.exists()) {
111:                            ClassLoader cl = lafRegister
112:                                    .getLookAndFeelClassLoader();
113:                            Class<?> oyLafClass = Class.forName(
114:                                    OA_LAF_CLASS_NAME, false, cl);
115:                            Method setTheme = oyLafClass.getMethod(
116:                                    "setOyoahaTheme",
117:                                    new Class[] { File.class });
118:                            Object[] parms = new Object[] { themePackFile };
119:                            setTheme.invoke(laf, parms);
120:                        }
121:                    }
122:                } catch (Throwable th) {
123:                    s_log.error("Error loading an Oyoaha theme", th);
124:                }
125:
126:            }
127:
128:            /**
129:             * This Look and Feel has just been installed.
130:             */
131:            public void hasBeenInstalled(LAFRegister lafRegister,
132:                    LookAndFeel laf) {
133:            }
134:
135:            /**
136:             * @see ILookAndFeelController#getPreferencesComponent()
137:             */
138:            public BaseLAFPreferencesPanelComponent getPreferencesComponent() {
139:                return new OyoahaPrefsPanel(this );
140:            }
141:
142:            private static final class OyoahaPrefsPanel extends
143:                    BaseLAFPreferencesPanelComponent {
144:                private static final long serialVersionUID = 1L;
145:
146:                /**
147:                 * This interface defines locale specific strings. This should be
148:                 * replaced with a property file.
149:                 */
150:                interface OyoahaPrefsPanelI18n {
151:                    // i18n[laf.themePack=Theme Pack:]
152:                    String THEME_PACK = s_stringMgr.getString("laf.themePack");
153:                    // i18n[laf.themePacLoc=Theme Pack Directory:]
154:                    String THEMEPACK_LOC = s_stringMgr
155:                            .getString("laf.themePacLoc");
156:                }
157:
158:                private OyoahaLookAndFeelController _ctrl;
159:                private DirectoryListComboBox _themePackCmb = new DirectoryListComboBox();
160:
161:                OyoahaPrefsPanel(OyoahaLookAndFeelController ctrl) {
162:                    super (new GridBagLayout());
163:                    _ctrl = ctrl;
164:                    createUserInterface();
165:                }
166:
167:                private void createUserInterface() {
168:                    final GridBagConstraints gbc = new GridBagConstraints();
169:                    gbc.anchor = GridBagConstraints.WEST;
170:                    gbc.fill = GridBagConstraints.HORIZONTAL;
171:                    gbc.insets = new Insets(4, 4, 4, 4);
172:
173:                    gbc.gridx = 0;
174:                    gbc.gridy = 0;
175:                    add(new JLabel(OyoahaPrefsPanelI18n.THEME_PACK,
176:                            SwingConstants.RIGHT), gbc);
177:
178:                    ++gbc.gridx;
179:                    add(_themePackCmb, gbc);
180:
181:                    gbc.gridx = 0;
182:                    ++gbc.gridy;
183:                    add(new JLabel(OyoahaPrefsPanelI18n.THEMEPACK_LOC,
184:                            SwingConstants.RIGHT), gbc);
185:
186:                    ++gbc.gridx;
187:                    final String themePackDir = _ctrl._prefs
188:                            .getThemePackDirectory();
189:                    add(new OutputLabel(themePackDir), gbc);
190:                }
191:
192:                /**
193:                 * @see BaseLAFPreferencesPanelComponent#loadPreferencesPanel()
194:                 */
195:                public void loadPreferencesPanel() {
196:                    super .loadPreferencesPanel();
197:                    final String themePackDir = _ctrl._prefs
198:                            .getThemePackDirectory();
199:                    // i18n[laf.otmFiles=OTM files]
200:                    final FileExtensionFilter filter = new FileExtensionFilter(
201:                            s_stringMgr.getString("laf.otmFiles"),
202:                            new String[] { ".otm" });
203:                    _themePackCmb.load(new File(themePackDir), filter);
204:                    _themePackCmb.setSelectedItem(_ctrl._prefs
205:                            .getThemePackName());
206:                    if (_themePackCmb.getSelectedIndex() == -1
207:                            && _themePackCmb.getModel().getSize() > 0) {
208:                        _themePackCmb.setSelectedIndex(0);
209:                    }
210:                }
211:
212:                /**
213:                 * @see BaseLAFPreferencesPanelComponent#applyChanges()
214:                 */
215:                public boolean applyChanges() {
216:                    super .applyChanges();
217:                    _ctrl._prefs.setThemePackName((String) _themePackCmb
218:                            .getSelectedItem());
219:                    return false;
220:                }
221:            }
222:
223:            public static final class OyoahaPreferences implements 
224:                    IHasIdentifier {
225:                private String _themePackDir;
226:                private String _themePackName;
227:                private IntegerIdentifier _id = new IntegerIdentifier(1);
228:
229:                public String getThemePackDirectory() {
230:                    return _themePackDir;
231:                }
232:
233:                public void setThemePackDirectory(String value) {
234:                    _themePackDir = value;
235:                }
236:
237:                public String getThemePackName() {
238:                    return _themePackName;
239:                }
240:
241:                public void setThemePackName(String value) {
242:                    _themePackName = value;
243:                }
244:
245:                /**
246:                 * @return		The unique identifier for this object.
247:                 */
248:                public IIdentifier getIdentifier() {
249:                    return _id;
250:                }
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.