-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathDialogsRes.java
More file actions
142 lines (131 loc) · 5.3 KB
/
DialogsRes.java
File metadata and controls
142 lines (131 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Open Source Physics software is free software as described near the bottom of this code file.
*
* For additional information and documentation on Open Source Physics please see:
* <http://www.opensourcephysics.org/>
*/
package org.opensourcephysics.display.dialogs;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.opensourcephysics.display.OSPRuntime;
/**
* String constants for Dialogs.
*
* @author Wolfgang Christian
* @version 1.0
*/
public class DialogsRes {
public static String AUTOSCALE_AUTOSCALE;
public static String AUTOSCALE_AUTO;
public static String AUTOSCALE_OK;
public static String AUTOSCALE_ZOOM_WARNING;
public static String SCALE_SCALE;
public static String SCALE_MIN;
public static String SCALE_MAX;
public static String SCALE_AUTO;
public static String SCALE_CANCEL;
public static String SCALE_OK;
public static String SCALE_HORIZONTAL;
public static String SCALE_VERTICAL;
public static String LOG_SCALE;
public static String LOG_X;
public static String LOG_Y;
public static String LOG_OK;
public static String LOG_WARNING;
// static fields
static final String BUNDLE_NAME = "org.opensourcephysics.resources.display.dialogs_res"; //$NON-NLS-1$
static Locale resourceLocale = Locale.ENGLISH;
static ResourceBundle res;
static {
String language = Locale.getDefault().getLanguage();
resourceLocale = Locale.ENGLISH;
for(Locale locale : OSPRuntime.getInstalledLocales()) {
if(locale.getLanguage().equals(language)) {
resourceLocale = locale;
break;
}
}
res = ResourceBundle.getBundle(BUNDLE_NAME, resourceLocale);
setLocalStrings();
}
private DialogsRes() {}
/**
* Gets a localized resource string.
*
* @param bundle ResourceBundle
* @param key String
* @return String
*/
private static String getString(final ResourceBundle bundle, final String key) {
try {
return bundle.getString(key);
} catch(final MissingResourceException ex) {
// assert(false) : ex.getMessage();
return '|'+key+'|';
}
}
/**
* Sets the locale.
*
* @param loc the locale
*/
public static void setLocale(Locale loc) {
if(resourceLocale==loc) {
return;
}
resourceLocale = loc;
// get the new resource bundle
res = ResourceBundle.getBundle(BUNDLE_NAME, resourceLocale);
setLocalStrings();
}
/**
* Gets the local strings.
*
* Static strings are used for speed to avoid having to call the resource object. This may no longer be necessary on fast machines.
*/
private static void setLocalStrings() {
AUTOSCALE_AUTOSCALE = getString(res, "AUTOSCALE_AUTOSCALE"); //$NON-NLS-1$
AUTOSCALE_AUTO = getString(res, "AUTOSCALE_AUTO"); //$NON-NLS-1$
AUTOSCALE_OK = getString(res, "AUTOSCALE_OK"); //$NON-NLS-1$
AUTOSCALE_ZOOM_WARNING = getString(res, "AUTOSCALE_ZOOM_WARNING"); //$NON-NLS-1$
SCALE_SCALE = getString(res, "SCALE_SCALE"); //$NON-NLS-1$
SCALE_MIN = getString(res, "SCALE_MIN"); //$NON-NLS-1$
SCALE_MAX = getString(res, "SCALE_MAX"); //$NON-NLS-1$
SCALE_AUTO = getString(res, "SCALE_AUTO"); //$NON-NLS-1$
SCALE_CANCEL = getString(res, "SCALE_CANCEL"); //$NON-NLS-1$
SCALE_OK = getString(res, "SCALE_OK"); //$NON-NLS-1$
SCALE_HORIZONTAL = getString(res, "SCALE_HORIZONTAL"); //$NON-NLS-1$
SCALE_VERTICAL = getString(res, "SCALE_VERTICAL"); //$NON-NLS-1$
LOG_SCALE = getString(res, "LOG_SCALE"); //$NON-NLS-1$
LOG_X = getString(res, "LOG_X"); //$NON-NLS-1$
LOG_Y = getString(res, "LOG_Y"); //$NON-NLS-1$
LOG_OK = getString(res, "LOG_OK"); //$NON-NLS-1$
LOG_WARNING = getString(res, "LOG_WARNING"); //$NON-NLS-1$
}
static {
setLocalStrings();
}
}
/*
* Open Source Physics software is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License (GPL) as
* published by the Free Software Foundation; either version 2 of the License,
* or(at your option) any later version.
* Code that uses any portion of the code in the org.opensourcephysics package
* or any subpackage (subdirectory) of this package must must also be be released
* under the GNU GPL license.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA
* or view the license online at http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2007 The Open Source Physics project
* http://www.opensourcephysics.org
*/