]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ThreadNLS.java
3bab4d99934caec0474eaffc038a27fd85afb248
[lgpl/argeo-commons.git] / ThreadNLS.java
1 package org.argeo.eclipse.ui.specific;
2
3 import org.eclipse.osgi.util.NLS;
4 import org.eclipse.rwt.RWT;
5
6 /** NLS attached to a given thread */
7 public class ThreadNLS<T extends NLS> extends InheritableThreadLocal<T> {
8 public final static String DEFAULT_BUNDLE_LOCATION = "/properties/plugin";
9
10 private final String bundleLocation;
11
12 private Class<T> type;
13 private Boolean utf8 = false;
14
15 public ThreadNLS(String bundleLocation, Class<T> type, Boolean utf8) {
16 this.bundleLocation = bundleLocation;
17 this.type = type;
18 this.utf8 = utf8;
19 }
20
21 public ThreadNLS(Class<T> type) {
22 this(DEFAULT_BUNDLE_LOCATION, type, false);
23 }
24
25 @SuppressWarnings("unchecked")
26 @Override
27 protected T initialValue() {
28 if (utf8)
29 return (T) RWT.NLS.getUTF8Encoded(bundleLocation, type);
30 else
31 return (T) RWT.NLS.getISO8859_1Encoded(bundleLocation, type);
32 }
33 }