Mercurial > projects > dwt-addons
annotate dwtx/jface/text/source/JFaceTextMessages.d @ 200:eb3414669eb0 default tip
fix for dmd 1.041 and tango 0.99.8
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 28 Mar 2009 03:09:57 +0100 |
parents | c6d7b1ea700b |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 | |
131 | 14 |
151 | 15 module dwtx.jface.text.source.JFaceTextMessages; |
16 | |
129 | 17 import dwt.dwthelper.utils; |
18 | |
155
8442b6b2da2d
Fix import for ResourceBundle
Frank Benoit <benoit@tionex.de>
parents:
154
diff
changeset
|
19 import dwt.dwthelper.ResourceBundle; |
158 | 20 import dwtx.dwtxhelper.MessageFormat; |
129 | 21 |
22 /** | |
23 * Accessor for the <code>JFaceTextMessages.properties</code> file in | |
24 * package <code>dwtx.jface.text</code>. | |
25 * @since 2.0 | |
26 */ | |
27 class JFaceTextMessages { | |
28 | |
29 /** The resource bundle name. */ | |
159 | 30 // private static const String RESOURCE_BUNDLE= "dwtx.jface.text.JFaceTextMessages";//$NON-NLS-1$ |
129 | 31 |
32 /** The resource bundle. */ | |
174 | 33 private static ResourceBundle fgResourceBundle_;//= ResourceBundle.getBundle(RESOURCE_BUNDLE); |
159 | 34 |
174 | 35 private static ResourceBundle fgResourceBundle(){ |
36 if( fgResourceBundle_ is null ){ | |
37 synchronized(JFaceTextMessages.classinfo ){ | |
38 if( fgResourceBundle_ is null ){ | |
39 fgResourceBundle_ = ResourceBundle.getBundle( | |
159 | 40 getImportData!("dwtx.jface.text.JFaceTextMessages.properties")); |
174 | 41 } |
42 } | |
43 } | |
44 return fgResourceBundle_; | |
159 | 45 } |
129 | 46 |
47 /** | |
48 * Prohibits the creation of accessor objects. | |
49 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
50 private this() { |
129 | 51 } |
52 | |
53 /** | |
54 * Returns the string found in the resource bundle under the given key or a place holder string. | |
55 * | |
56 * @param key the look up key | |
57 * @return the value found under the given key | |
58 */ | |
59 public static String getString(String key) { | |
60 try { | |
61 return fgResourceBundle.getString(key); | |
62 } catch (MissingResourceException e) { | |
159 | 63 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$ |
129 | 64 } |
65 } | |
66 | |
67 /** | |
68 * Gets a string from the resource bundle and formats it with the argument | |
69 * | |
70 * @param key the string used to get the bundle value, must not be null | |
71 * @param args arguments used when formatting the string | |
72 * @return the formatted string | |
73 * @since 3.0 | |
74 */ | |
159 | 75 public static String getFormattedString(String key, Object[] args...) { |
129 | 76 String format= null; |
77 try { | |
78 format= fgResourceBundle.getString(key); | |
79 } catch (MissingResourceException e) { | |
159 | 80 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$ |
129 | 81 } |
82 return MessageFormat.format(format, args); | |
83 } | |
84 } |