Source Code Cross Referenced for AquaPreferences.java in  » Swing-Library » jide-common » com » jidesoft » plaf » aqua » 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 » jide common » com.jidesoft.plaf.aqua 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)Preferences.java  1.0  September 17, 2005
003:         *
004:         * Copyright (c) 2005 Werner Randelshofer
005:         * Staldenmattweg 2, Immensee, CH-6405, Switzerland.
006:         * All rights reserved.
007:         *
008:         * This software is the confidential and proprietary information of
009:         * Werner Randelshofer. ("Confidential Information").  You shall not
010:         * disclose such Confidential Information and shall use it only in
011:         * accordance with the terms of the license agreement you entered into
012:         * with Werner Randelshofer.
013:         */
014:
015:        package com.jidesoft.plaf.aqua;
016:
017:        import com.jidesoft.utils.SecurityUtils;
018:
019:        import java.io.File;
020:        import java.io.FileReader;
021:        import java.io.IOException;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:        import java.util.logging.Logger;
025:
026:        /**
027:         * Utility class for accessing Mac OS X System Preferences.
028:         *
029:         * @author Werner Randelshofer
030:         * @version 1.0 September 17, 2005 Created.
031:         */
032:        class AquaPreferences {
033:            private static final Logger LOGGER = Logger
034:                    .getLogger(AquaPreferences.class.getName());
035:
036:            private static HashMap prefs;
037:
038:            /**
039:             * Creates a new instance.
040:             */
041:            public AquaPreferences() {
042:            }
043:
044:            public static String getString(String key) {
045:                return (String) get(key);
046:            }
047:
048:            public static Object get(String key) {
049:                if (prefs == null) {
050:                    prefs = new HashMap();
051:                    loadGlobalPreferences();
052:                }
053:                //System.out.println("Preferences.get("+key+"):"+prefs.get(key));
054:                return prefs.get(key);
055:            }
056:
057:            private static void loadGlobalPreferences() {
058:                // Load Mac OS X global preferences
059:                // --------------------------------
060:
061:                // Fill preferences with default values, in case we fail to read them
062:
063:                // Appearance: "1"=Blue, "6"=Graphite
064:                prefs.put("AppleAquaColorVariant", "1");
065:                // Highlight Color: (RGB float values)
066:                prefs.put("AppleHighlightColor", "0.709800 0.835300 1.000000");
067:                // Collation order: (Language code)
068:                prefs.put("AppleCollationOrder", "en");
069:                // Place scroll arrows: "Single"=At top and bottom, "DoubleMax"=Together
070:                prefs.put("AppleScrollBarVariant", "DoubleMax");
071:                // Click in the scroll bar to: "true"=Jump to here, "false"=Jump to next page
072:                prefs.put("AppleScrollerPagingBehavior", "false");
073:
074:                File globalPrefsFile = new File(SecurityUtils.getProperty(
075:                        "user.home", "")
076:                        + "/Library/Preferences/.GlobalPreferences.plist");
077:                try {
078:                    XMLElement xml = readPList(globalPrefsFile);
079:                    for (Iterator i0 = xml.iterateChildren(); i0.hasNext();) {
080:                        XMLElement xml1 = (XMLElement) i0.next();
081:
082:                        String key = null;
083:                        for (Iterator i1 = xml1.iterateChildren(); i1.hasNext();) {
084:                            XMLElement xml2 = (XMLElement) i1.next();
085:                            if (xml2.getName().equals("key")) {
086:                                key = xml2.getContent();
087:                            } else {
088:                                if (key != null) {
089:                                    //System.out.println("Preferences "+key+"="+xml2.getContent());
090:                                    prefs.put(key, xml2.getContent());
091:                                }
092:                                key = null;
093:                            }
094:                        }
095:                    }
096:                } catch (IOException e) {
097:                    LOGGER
098:                            .warning("AquaPreferences failed to load Mac OS X global system preferences - "
099:                                    + e.getLocalizedMessage());
100:                } catch (Exception e) {
101:                    LOGGER
102:                            .warning("AquaPreferences failed to load Mac OS X global system preferences - "
103:                                    + e.getLocalizedMessage());
104:                }
105:            }
106:
107:            /**
108:             * Reads the specified PList file and returns it as an XMLElement.
109:             * This method can deal with XML encoded and binary encoded PList files.
110:             */
111:            private static XMLElement readPList(File plistFile)
112:                    throws IOException {
113:                FileReader reader = null;
114:                XMLElement xml = null;
115:                try {
116:                    reader = new FileReader(plistFile);
117:                    xml = new XMLElement(new HashMap(), false, false);
118:                    try {
119:                        xml.parseFromReader(reader);
120:                    } catch (XMLParseException e) {
121:                        xml = new BinaryPListParser().parse(plistFile);
122:                    }
123:                } finally {
124:                    if (reader != null) {
125:                        reader.close();
126:                    }
127:                }
128:                return xml;
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.