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
|
|
15 import dwtx.jface.internal.text.link.contentassist.IProposalListener; // packageimport
|
|
16 import dwtx.jface.internal.text.link.contentassist.LineBreakingReader; // packageimport
|
|
17 import dwtx.jface.internal.text.link.contentassist.CompletionProposalPopup2; // packageimport
|
|
18 import dwtx.jface.internal.text.link.contentassist.ContextInformationPopup2; // packageimport
|
|
19 import dwtx.jface.internal.text.link.contentassist.Helper2; // packageimport
|
|
20 import dwtx.jface.internal.text.link.contentassist.PopupCloser2; // packageimport
|
|
21 import dwtx.jface.internal.text.link.contentassist.IContentAssistListener2; // packageimport
|
|
22 import dwtx.jface.internal.text.link.contentassist.ContentAssistant2; // packageimport
|
|
23 import dwtx.jface.internal.text.link.contentassist.AdditionalInfoController2; // packageimport
|
|
24
|
129
|
25 module dwtx.jface.internal.text.link.contentassist.ContentAssistMessages;
|
|
26
|
|
27 import dwt.dwthelper.utils;
|
|
28
|
|
29 import java.util.MissingResourceException;
|
|
30 import java.util.ResourceBundle;
|
|
31
|
|
32 import com.ibm.icu.text.MessageFormat;
|
|
33
|
|
34
|
|
35 /**
|
|
36 * Helper class to get NLSed messages.
|
|
37 *
|
|
38 * @since 3.0
|
|
39 */
|
|
40 class ContentAssistMessages {
|
|
41
|
|
42 private static final String RESOURCE_BUNDLE= ContentAssistMessages.class.getName();
|
|
43
|
|
44 private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
|
45
|
|
46 private ContentAssistMessages() {
|
|
47 }
|
|
48
|
|
49 /**
|
|
50 * Gets a string from the resource bundle.
|
|
51 *
|
|
52 * @param key the string used to get the bundle value, must not be null
|
|
53 * @return the string from the resource bundle
|
|
54 */
|
|
55 public static String getString(String key) {
|
|
56 try {
|
|
57 return fgResourceBundle.getString(key);
|
|
58 } catch (MissingResourceException e) {
|
|
59 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
|
60 }
|
|
61 }
|
|
62
|
|
63 /**
|
|
64 * Gets a string from the resource bundle and formats it with the given arguments.
|
|
65 *
|
|
66 * @param key the string used to get the bundle value, must not be null
|
|
67 * @param args the arguments used to format the string
|
|
68 * @return the formatted string
|
|
69 */
|
|
70 public static String getFormattedString(String key, Object[] args) {
|
|
71 String format= null;
|
|
72 try {
|
|
73 format= fgResourceBundle.getString(key);
|
|
74 } catch (MissingResourceException e) {
|
|
75 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
|
76 }
|
|
77 return MessageFormat.format(format, args);
|
|
78 }
|
|
79
|
|
80 /**
|
|
81 * Gets a string from the resource bundle and formats it with the given argument.
|
|
82 *
|
|
83 * @param key the string used to get the bundle value, must not be null
|
|
84 * @param arg the argument used to format the string
|
|
85 * @return the formatted string
|
|
86 */
|
|
87 public static String getFormattedString(String key, Object arg) {
|
|
88 String format= null;
|
|
89 try {
|
|
90 format= fgResourceBundle.getString(key);
|
|
91 } catch (MissingResourceException e) {
|
|
92 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
|
93 }
|
|
94 if (arg is null)
|
|
95 arg= ""; //$NON-NLS-1$
|
|
96 return MessageFormat.format(format, new Object[] { arg });
|
|
97 }
|
|
98 }
|