01: package com.opensymphony.workflow.designer;
02:
03: import java.io.*;
04: import java.util.ResourceBundle;
05: import javax.swing.*;
06:
07: import com.opensymphony.workflow.designer.swing.EnhancedResourceBundle;
08:
09: public final class ResourceManager {
10: private static final ResourceManager INSTANCE = new ResourceManager();
11:
12: private EnhancedResourceBundle bundle;
13:
14: private ResourceManager() {
15: bundle = new EnhancedResourceBundle(
16: "com.opensymphony.workflow.designer.resources");
17: }
18:
19: public static ResourceBundle getBundle() {
20: return INSTANCE.bundle.getBundle();
21: }
22:
23: public static String getString(String key) {
24: return getString(key, key);
25: }
26:
27: public static String getString(String key, String defaultValue) {
28: return INSTANCE.bundle.getString(key, defaultValue);
29: }
30:
31: public static String getString(String key, Object args) {
32: return INSTANCE.bundle.getString(key, args);
33: }
34:
35: public static ImageIcon getIcon(String key) {
36: return INSTANCE.bundle.getIcon(key);
37: }
38:
39: public static InputStream getInputStream(String path) {
40: return INSTANCE.bundle.getInputStream(path);
41: }
42:
43: public static ImageIcon readImageIcon(String path) {
44: return INSTANCE.bundle.readImageIcon(path);
45: }
46:
47: public static String readTextFromFile(String path) {
48: InputStream in = getInputStream(path);
49: if (null == in)
50: return null;
51: BufferedReader reader = new BufferedReader(
52: new InputStreamReader(in));
53: StringBuffer result = new StringBuffer();
54: try {
55: String line = reader.readLine();
56: while (line != null) {
57: result.append(line);
58: line = reader.readLine();
59: if (line != null)
60: result.append('\n');
61: }
62: return result.toString();
63: } catch (IOException e) {
64: return null;
65: } finally {
66: try {
67: reader.close();
68: } catch (IOException e) {
69: }
70: }
71: }
72: }
|