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


001:        /*
002:         * ResourceMgr.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.resource;
013:
014:        import java.awt.event.KeyEvent;
015:        import java.io.File;
016:        import java.io.InputStream;
017:        import java.net.URL;
018:        import java.text.MessageFormat;
019:        import java.text.SimpleDateFormat;
020:        import java.util.Locale;
021:        import java.util.MissingResourceException;
022:        import java.util.ResourceBundle;
023:
024:        import javax.swing.ImageIcon;
025:
026:        import workbench.log.LogMgr;
027:        import workbench.util.NumberStringCache;
028:        import workbench.util.StringUtil;
029:        import workbench.util.VersionNumber;
030:
031:        /**
032:         * @author support@sql-workbench.net.kellerer
033:         */
034:        public class ResourceMgr {
035:            public static final String TXT_PRODUCT_NAME = "SQL Workbench/J";
036:
037:            public static final String TXT_OK = "LblOK";
038:            public static final String TXT_CANCEL = "LblCancel";
039:
040:            public static final String IMG_SAVE = "Save";
041:
042:            public static final String MNU_TXT_WORKSPACE = "MnuTxtWorkspace";
043:            public static final String MNU_TXT_FILE = "MnuTxtFile";
044:            public static final String MNU_TXT_MACRO = "MnuTxtMacro";
045:            public static final String MNU_TXT_SQL = "MnuTxtSQL";
046:            public static final String MNU_TXT_EDIT = "MnuTxtEdit";
047:            public static final String MNU_TXT_DATA = "MnuTxtData";
048:            public static final String MNU_TXT_COPY_SELECTED = "MnuTxtCopySelected";
049:
050:            public static final String MNU_TXT_VIEW = "MnuTxtView";
051:            public static final String MNU_TXT_TOOLS = "MnuTxtTools";
052:            public static final String MNU_TXT_HELP = "MnuTxtHelp";
053:            public static final String MNU_TXT_OPTIONS = "MnuTxtOptions";
054:            private static ResourceBundle resources;
055:
056:            private ResourceMgr() {
057:            }
058:
059:            public static String getBuildInfo() {
060:                return getString("TxtBuild") + " "
061:                        + getBuildNumber().toString() + " ("
062:                        + getString("TxtBuildDate") + ")";
063:            }
064:
065:            public static String replaceModifierText(String msg) {
066:                msg = StringUtil.replace(msg, "%shift%", KeyEvent
067:                        .getKeyModifiersText(KeyEvent.SHIFT_MASK));
068:                msg = StringUtil.replace(msg, "%control%", KeyEvent
069:                        .getKeyModifiersText(KeyEvent.CTRL_MASK));
070:                return msg;
071:            }
072:
073:            public static java.util.Date getBuildDate() {
074:                String builddate = getString("TxtBuildDate");
075:                // running from the dev environment --> build date is now!
076:                if ("@BUILD_DATE@".equals(builddate))
077:                    return new java.util.Date();
078:                SimpleDateFormat format = new SimpleDateFormat(
079:                        "yyyy-MM-dd HH:mm");
080:                java.util.Date result = null;
081:                try {
082:                    result = format.parse(builddate);
083:                } catch (Exception e) {
084:                    LogMgr.logError("ResourceMgr.getBuildDate()",
085:                            "Err when parsing build date!", e);
086:                    result = new java.util.Date();
087:                }
088:                return result;
089:            }
090:
091:            public static boolean isDevBuild() {
092:                String nr = getString("TxtBuildNumber");
093:                char c = nr.charAt(0);
094:                return (c == '[' || c == '@');
095:            }
096:
097:            public static VersionNumber getBuildNumber() {
098:                String nr = getString("TxtBuildNumber");
099:                return new VersionNumber(nr);
100:            }
101:
102:            public static String getDefaultTabLabel() {
103:                return getString("LblTabStatement");
104:            }
105:
106:            public static String getFormattedString(String key, int value1) {
107:                return MessageFormat.format(getString(key), NumberStringCache
108:                        .getNumberString(value1));
109:            }
110:
111:            public static String getFormattedString(String key, int value1,
112:                    int value2) {
113:                return MessageFormat.format(getString(key), NumberStringCache
114:                        .getNumberString(value1), NumberStringCache
115:                        .getNumberString(value2));
116:            }
117:
118:            public static String getFormattedString(String key,
119:                    Object... values) {
120:                return MessageFormat.format(getString(key), values);
121:            }
122:
123:            public static String getString(String aKey) {
124:                return getString(aKey, false);
125:            }
126:
127:            public static String getString(String aKey, boolean replaceModifiers) {
128:                try {
129:                    String value = getResources().getString(aKey);
130:                    if (replaceModifiers) {
131:                        return replaceModifierText(value);
132:                    }
133:                    return value;
134:                } catch (MissingResourceException e) {
135:                    LogMgr.logWarning("ResourceMgr", "String with key=" + aKey
136:                            + " not found in resource file!", e);
137:                    return aKey;
138:                }
139:            }
140:
141:            public static String getPlainString(String aKey) {
142:                String value = getString(aKey).replaceAll("\\&", "");
143:                return value;
144:            }
145:
146:            public static String getAcceleratorChar(String aKey) {
147:                try {
148:                    String label = getString(aKey);
149:                    int pos = label.indexOf('&');
150:                    if (pos == -1)
151:                        return null;
152:
153:                    char c = label.charAt(pos + 1);
154:                    StringBuilder b = new StringBuilder(1);
155:                    b.append(c);
156:                    return b.toString();
157:                } catch (MissingResourceException e) {
158:                    return null;
159:                } catch (Exception e) {
160:                    return null;
161:                }
162:            }
163:
164:            public static String getDescription(String aKey) {
165:                return getDescription(aKey, false);
166:            }
167:
168:            /**
169:             *    Returns the description associcate with the given key.
170:             *    This is used for Tooltips which are associated with a
171:             *    certain menu text etc.
172:             */
173:            public static String getDescription(String aKey,
174:                    boolean replaceModifiers) {
175:                String value = getString("d_" + aKey);
176:                if (replaceModifiers) {
177:                    value = replaceModifierText(value);
178:                }
179:                return value;
180:            }
181:
182:            public static InputStream getDefaultSettings() {
183:                InputStream in = ResourceMgr.class
184:                        .getResourceAsStream("default.properties");
185:
186:                return in;
187:            }
188:
189:            public static ImageIcon getBlankImage() {
190:                return retrieveImage("blank16", ".gif");
191:            }
192:
193:            public static ImageIcon getImage(String aKey) {
194:                return retrieveImage(aKey + "16", ".gif");
195:            }
196:
197:            public static ImageIcon getPicture(String aName) {
198:                return retrieveImage(aName, ".gif");
199:            }
200:
201:            public static ImageIcon getPng(String aName) {
202:                return retrieveImage(aName, ".png");
203:            }
204:
205:            private static ImageIcon retrieveImage(String filename,
206:                    String extension) {
207:                URL imageIconUrl = ResourceMgr.class.getClassLoader()
208:                        .getResource(
209:                                "workbench/resource/images/" + filename
210:                                        + extension);
211:                if (imageIconUrl != null) {
212:                    return new ImageIcon(imageIconUrl);
213:                } else {
214:                    imageIconUrl = ResourceMgr.class.getClassLoader()
215:                            .getResource(filename);
216:                    if (imageIconUrl != null) {
217:                        return new ImageIcon(imageIconUrl);
218:                    }
219:                }
220:                return null;
221:            }
222:
223:            /**
224:             * For testing purposes
225:             */
226:            static ResourceBundle getResourceBundle(Locale l) {
227:                return ResourceBundle.getBundle("language/wbstrings", l);
228:            }
229:
230:            public static ResourceBundle getResources() {
231:                if (resources == null) {
232:                    Locale l = Settings.getInstance().getLanguage();
233:                    resources = getResourceBundle(l);
234:                    boolean setDefaultLocale = Settings.getInstance()
235:                            .getBoolProperty("workbench.gui.setdefaultlocale",
236:                                    true);
237:                    if (setDefaultLocale) {
238:                        Locale.setDefault(l);
239:                    }
240:                }
241:                return resources;
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.