Source Code Cross Referenced for ResourceManager.java in  » Workflow-Engines » shark » org » enhydra » shark » swingclient » 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 » Workflow Engines » shark » org.enhydra.shark.swingclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ResourceManager.java
002:         *
003:         * Authors:
004:         * Stefanovic Nenad  chupo@iis.ns.ac.yu
005:         * Bojanic Sasa      sasaboy@neobee.net
006:         * Puskas Vladimir   vpuskas@eunet.yu
007:         * Pilipovic Goran   zboniek@uns.ac.yu
008:         *
009:         */
010:
011:        package org.enhydra.shark.swingclient;
012:
013:        import java.net.*;
014:        import java.util.*;
015:
016:        /**
017:         * Implements the static methods that are used to implement
018:         * multilanguage support, and to create some resources as
019:         * menubar, toolbars and button panels.
020:         */
021:        public class ResourceManager {
022:            private static final String resourcePath = "org.enhydra.shark.swingclient.resources.SharkClient";
023:
024:            public static Locale defaultLocale;
025:            public static ResourceBundle defaultResource;
026:            public static Locale choosenLocale;
027:            public static ResourceBundle choosenResource;
028:
029:            static {
030:                try {
031:                    // default is english
032:                    defaultLocale = new Locale("en");
033:                    defaultResource = ResourceBundle.getBundle(resourcePath,
034:                            new Locale(""));
035:
036:                    // chose the default system settings at the start
037:                    choosenLocale = Locale.getDefault();
038:                    choosenResource = ResourceBundle.getBundle(resourcePath,
039:                            choosenLocale);
040:                } catch (MissingResourceException mre) {
041:                    System.err.println(resourcePath + ".properties not found");
042:                    System.exit(1);
043:                }
044:            }
045:
046:            /**
047:             * Gets a resource string from the resource bundle.<p> Resource bundle
048:             * represents the <i>property file</i>. For example, if property file
049:             * contains something like this:<BR><CENTER>menubar=file edit help</CENTER>
050:             * method call getResourceString("menubar") will give the string
051:             * <i>file edit help</i> as a result. <BR> This method reads information
052:             * from property file. If can't find desired resource, returns <b>null</b>.
053:             * @param nm name of the resource to fetch.
054:             * @return String value of named resource.
055:             */
056:            public static String getLanguageDependentString(String nm) {
057:                String str;
058:                try {
059:                    str = choosenResource.getString(nm);
060:                } catch (MissingResourceException mre) {
061:                    try {
062:                        str = defaultResource.getString(nm);
063:                    } catch (MissingResourceException mre1) {
064:                        str = null;
065:                    }
066:                }
067:                return str;
068:            }
069:
070:            /**
071:             * Gets the url from a resource string.
072:             * @param key the string key to the url in the resource bundle.
073:             * @return the resource location.
074:             * @see java.lang.Class#getResource
075:             */
076:            public static URL getResource(String key) {
077:                String name = getLanguageDependentString(key);
078:                if (name != null) {
079:                    URL url = ResourceManager.class.getClassLoader()
080:                            .getResource(name);
081:                    return url;
082:                }
083:                return null;
084:            }
085:
086:            public static void setDefault() {
087:                choosenResource = defaultResource;
088:                choosenLocale = defaultLocale;
089:            }
090:
091:            /** Returns the default resource bundle.
092:             *
093:             */
094:            public static ResourceBundle getDefaultResource() {
095:                return defaultResource;
096:            }
097:
098:            /** Returns the current locale.
099:             *
100:             */
101:            public static ResourceBundle getChoosenResource() {
102:                return choosenResource;
103:            }
104:
105:            /** Returns the default locale.
106:             *
107:             */
108:            public static Locale getDefaultLocale() {
109:                return defaultLocale;
110:            }
111:
112:            /** Returns the current locale.
113:             *
114:             */
115:            public static Locale getChoosenLocale() {
116:                return choosenLocale;
117:            }
118:
119:            /**
120:             * Sets the new resource and locale to be used.
121:             */
122:            public static void setChoosen(String language)
123:                    throws MissingResourceException {
124:                choosenLocale = new Locale(language);
125:                String bundle = resourcePath + "_" + language;
126:                choosenResource = ResourceBundle.getBundle(bundle);
127:            }
128:
129:            /**
130:             * Sets the new resource and locale to be used.
131:             */
132:            public static void setChoosen(String language, String country)
133:                    throws MissingResourceException {
134:                choosenLocale = new Locale(language, country);
135:                String bundle = resourcePath + "_" + language + "_" + country;
136:                choosenResource = ResourceBundle.getBundle(bundle);
137:            }
138:
139:            /**
140:             * Sets the new resource and locale to be used.
141:             */
142:            public static void setChoosen(String language, String country,
143:                    String variant) throws MissingResourceException {
144:                choosenLocale = new Locale(language, country, variant);
145:                String bundle = resourcePath + "_" + language + "_" + country
146:                        + "_" + variant;
147:                choosenResource = ResourceBundle.getBundle(bundle);
148:            }
149:
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.