Source Code Cross Referenced for LnFManager.java in  » Database-Client » SQL-Workbench » workbench » gui » lnf » 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 » SQL Workbench » workbench.gui.lnf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * LnFManager.java
003:         *
004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005:         *
006:         * Copyright 2002-2008, Thomas Kellerer
007:         * No part of this code maybe reused without the permission of the author
008:         *
009:         * To contact the author please send an email to: support@sql-workbench.net
010:         *
011:         */
012:        package workbench.gui.lnf;
013:
014:        import java.util.ArrayList;
015:        import java.util.Collections;
016:        import java.util.Comparator;
017:        import java.util.List;
018:        import javax.swing.LookAndFeel;
019:        import javax.swing.UIManager;
020:        import javax.swing.UIManager.LookAndFeelInfo;
021:        import workbench.resource.Settings;
022:        import workbench.util.StringUtil;
023:
024:        /**
025:         * Retrieve and store LnF definitions in the the Settings object
026:         * @author support@sql-workbench.net
027:         */
028:        public class LnFManager {
029:            private List<LnFDefinition> lnfList = new ArrayList<LnFDefinition>();
030:
031:            public LnFManager() {
032:                Settings set = Settings.getInstance();
033:
034:                int count = set.getIntProperty("workbench.lnf.count", 0);
035:                for (int i = 0; i < count; i++) {
036:                    String clz = set.getProperty("workbench.lnf." + i
037:                            + ".class", null);
038:                    String name = set.getProperty("workbench.lnf." + i
039:                            + ".name", clz);
040:                    String libs = set.getProperty("workbench.lnf." + i
041:                            + ".classpath", null);
042:                    libs = StringUtil.replace(libs,
043:                            LnFDefinition.LNF_PATH_SEPARATOR, StringUtil
044:                                    .getPathSeparator());
045:                    if (clz != null && libs != null) {
046:                        LnFDefinition lnf = new LnFDefinition(name, clz, libs);
047:                        lnfList.add(lnf);
048:                    }
049:                }
050:
051:                // The Liquid Look & Feel "installs" itself as a System L&F and if 
052:                // activated is returned in getInstalledLookAndFeels(). To avoid 
053:                // a duplicate entry we check this before adding a "system" look and feel
054:                LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
055:
056:                for (int i = 0; i < info.length; i++) {
057:                    LnFDefinition lnf = new LnFDefinition(info[i].getName(),
058:                            info[i].getClassName());
059:                    if (!lnfList.contains(lnf)) {
060:                        lnfList.add(lnf);
061:                    }
062:                }
063:                Comparator<LnFDefinition> nameComp = new Comparator<LnFDefinition>() {
064:                    public int compare(LnFDefinition first, LnFDefinition second) {
065:                        return StringUtil.compareStrings(first.getName(),
066:                                second.getName(), true);
067:                    }
068:                };
069:                Collections.sort(lnfList, nameComp);
070:            }
071:
072:            public void removeDefinition(LnFDefinition lnf) {
073:                if (lnf == null)
074:                    return;
075:                if (!lnf.isBuiltInLnF()) {
076:                    this .lnfList.remove(lnf);
077:                }
078:            }
079:
080:            public LnFDefinition getCurrentLnF() {
081:                LookAndFeel lnf = UIManager.getLookAndFeel();
082:                String lnfClass = lnf.getClass().getName();
083:                return findLookAndFeel(lnfClass);
084:            }
085:
086:            public int addDefinition(LnFDefinition lnf) {
087:                this .lnfList.add(lnf);
088:                return lnfList.size() - 1;
089:            }
090:
091:            public void saveLookAndFeelDefinitions() {
092:                Settings set = Settings.getInstance();
093:                removeLnFEntries();
094:                int count = this .lnfList.size();
095:                int lnfCount = 0;
096:                for (LnFDefinition lnf : lnfList) {
097:                    if (!lnf.isBuiltInLnF()) {
098:                        String libs = lnf.getLibrary();
099:                        libs = StringUtil.replace(libs, StringUtil
100:                                .getPathSeparator(),
101:                                LnFDefinition.LNF_PATH_SEPARATOR);
102:                        set.setProperty("workbench.lnf." + lnfCount
103:                                + ".classpath", libs);
104:                        set.setProperty("workbench.lnf." + lnfCount + ".class",
105:                                lnf.getClassName());
106:                        set.setProperty("workbench.lnf." + lnfCount + ".name",
107:                                lnf.getName());
108:                        lnfCount++;
109:                    }
110:                }
111:                set.setProperty("workbench.lnf.count", lnfCount);
112:            }
113:
114:            private void removeLnFEntries() {
115:                Settings set = Settings.getInstance();
116:                int count = set.getIntProperty("workbench.lnf.count", 0);
117:                for (int i = 0; i < count; i++) {
118:                    set.removeProperty("workbench.lnf." + i + ".classpath");
119:                    set.removeProperty("workbench.lnf." + i + ".class");
120:                    set.removeProperty("workbench.lnf." + i + ".name");
121:                }
122:            }
123:
124:            /**
125:             * returns all LnFs defined in the system. This is 
126:             * a combined list of built-in LnFs and user-defined
127:             * LnFs
128:             * 
129:             * @return all available Look and Feels
130:             * @see workbench.gui.lnf.LnFDefinition#isBuiltInLnF()
131:             */
132:            public List<LnFDefinition> getAvailableLookAndFeels() {
133:                return Collections.unmodifiableList(lnfList);
134:            }
135:
136:            public LnFDefinition findLookAndFeel(String className) {
137:                if (className == null)
138:                    return null;
139:
140:                for (LnFDefinition lnf : lnfList) {
141:                    if (lnf.getClassName().equals(className)) {
142:                        return lnf;
143:                    }
144:                }
145:                return null;
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.