2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.eclipse
.ui
.specific
;
18 import org
.eclipse
.osgi
.util
.NLS
;
19 import org
.eclipse
.rap
.rwt
.RWT
;
21 /** NLS attached to a given thread */
22 public class ThreadNLS
<T
extends NLS
> extends InheritableThreadLocal
<T
> {
23 public final static String DEFAULT_BUNDLE_LOCATION
= "/properties/plugin";
25 private final String bundleLocation
;
27 private Class
<T
> type
;
28 private Boolean utf8
= false;
30 public ThreadNLS(String bundleLocation
, Class
<T
> type
, Boolean utf8
) {
31 this.bundleLocation
= bundleLocation
;
36 public ThreadNLS(Class
<T
> type
) {
37 this(DEFAULT_BUNDLE_LOCATION
, type
, false);
40 @SuppressWarnings("unchecked")
42 protected T
initialValue() {
44 return (T
) RWT
.NLS
.getUTF8Encoded(bundleLocation
, type
);
46 return (T
) RWT
.NLS
.getISO8859_1Encoded(bundleLocation
, type
);