Skip to content

Commit feacc2d

Browse files
committed
Use more modern NLS mechanism
This change uses consistent and modern NLS mechanism. This makes it easier to handle refactoring code and applying the same change to multiple classes like recently done in #575 Part 1: In commit 485c41b the code was refactored in a such a way that prevented the externalize string tooling in Eclipse from working properly. This change provides the messages classes with a way that the tooling in Eclipse works, enabling Ctrl-Click and hovering on the externalized strings to work as expected and allows the externalize strings wizard to find the correct Messages class to add new strings to. Part 2: Using fields instead of getString provides compile time verification that the key is correct. This is extra helpful when copying code around as it is immediately apparent that the a message is missing from the Messages.java class. In fact when I refactored the code to use the static way I found a handful of messages that were missing. Disadvantage: There is one downside to the above changes. All the message keys that were not already Java identifiers needed modifying. For example, DebuggerTab.doStartGdbServer_Text needed changing to DebuggerTab_doStartGdbServer_Text. For embed-cdt itself this isn't a problem. But for any translations that have been done for messages.properties they will have to update the keys as well to change the . to _ Other advantage: The other advantage is if a entry is missing from the messages.properties class, it is logged when any message in the Messages class is loaded rather than when the missing one is loaded. A missing entry shows up like this: ``` Warning: NLS missing message: ProjectToolchainsPathsPropertiesPage_description in: org.eclipse.embedcdt.internal.managedbuild.cross.arm.ui.messages ``` This significantly increases the changes of spotting missing messages during development because not every single code path needs to be visited.
1 parent 413c0a3 commit feacc2d

File tree

26 files changed

+1994
-1554
lines changed

26 files changed

+1994
-1554
lines changed

plugins/org.eclipse.embedcdt.codered.ui/src/org/eclipse/embedcdt/internal/codered/ui/Messages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class Messages extends NLS {
2020

21-
private static final String MESSAGES = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
21+
private static final String MESSAGES = "org.eclipse.embedcdt.internal.codered.ui.messages"; //$NON-NLS-1$
2222

2323
// public static String MyMessage_text;
2424

plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabDebugger.java

Lines changed: 76 additions & 81 deletions
Large diffs are not rendered by default.

plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/debug/gdbjtag/jlink/ui/TabStartup.java

Lines changed: 85 additions & 87 deletions
Large diffs are not rendered by default.

plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/src/org/eclipse/embedcdt/internal/debug/gdbjtag/jlink/ui/Messages.java

Lines changed: 206 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,228 @@
1616

1717
package org.eclipse.embedcdt.internal.debug.gdbjtag.jlink.ui;
1818

19-
import java.util.MissingResourceException;
20-
import java.util.ResourceBundle;
21-
2219
import org.eclipse.osgi.util.NLS;
2320

2421
public class Messages {
2522

2623
// ------------------------------------------------------------------------
2724

28-
private static final String MESSAGES = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
25+
private static final String MESSAGES = "org.eclipse.embedcdt.internal.debug.gdbjtag.jlink.ui.messages"; //$NON-NLS-1$
2926

30-
public static String ProjectMcuPagePropertyPage_description;
31-
public static String WorkspaceMcuPagePropertyPage_description;
27+
public static String DebuggerTab_connectionAfter_Text;
28+
public static String DebuggerTab_connectionTcp_Text;
29+
public static String DebuggerTab_connectionUsb_Text;
30+
public static String DebuggerTab_deviceGroup_Text;
31+
public static String DebuggerTab_deviceName_Label;
32+
public static String DebuggerTab_deviceName_Link;
33+
public static String DebuggerTab_deviceName_ToolTipText;
34+
public static String DebuggerTab_doStartGdbServer_Text;
35+
public static String DebuggerTab_doStartGdbServer_ToolTipText;
36+
public static String DebuggerTab_endianness_Label;
37+
public static String DebuggerTab_endianness_ToolTipText;
38+
public static String DebuggerTab_endiannessBig_Text;
39+
public static String DebuggerTab_endiannesslittle_Text;
40+
public static String DebuggerTab_gdbCommand_Label;
41+
public static String DebuggerTab_gdbCommand_ToolTipText;
42+
public static String DebuggerTab_gdbCommandActualPath_Label;
43+
public static String DebuggerTab_gdbCommandBrowse_Title;
44+
public static String DebuggerTab_gdbCommandBrowse;
45+
public static String DebuggerTab_gdbCommandVariable;
46+
public static String DebuggerTab_gdbOtherCommands_Label;
47+
public static String DebuggerTab_gdbOtherCommands_ToolTipText;
48+
public static String DebuggerTab_gdbOtherOptions_Label;
49+
public static String DebuggerTab_gdbOtherOptions_ToolTipText;
50+
public static String DebuggerTab_gdbServerActualPath_Label;
51+
public static String DebuggerTab_gdbServerActualPath_link;
52+
public static String DebuggerTab_gdbServerAllocateConsole_Label;
53+
public static String DebuggerTab_gdbServerAllocateConsole_ToolTipText;
54+
public static String DebuggerTab_gdbServerAllocateSemihostingConsole_Label;
55+
public static String DebuggerTab_gdbServerAllocateSemihostingConsole_ToolTipText;
56+
public static String DebuggerTab_gdbServerConnection_Label;
57+
public static String DebuggerTab_gdbServerConnection_ToolTipText;
58+
public static String DebuggerTab_gdbServerExecutable_Label;
59+
public static String DebuggerTab_gdbServerExecutable_ToolTipText;
60+
public static String DebuggerTab_gdbServerExecutableBrowse_Title;
61+
public static String DebuggerTab_gdbServerExecutableBrowse;
62+
public static String DebuggerTab_gdbServerExecutableVariable;
63+
public static String DebuggerTab_gdbServerGdbPort_Label;
64+
public static String DebuggerTab_gdbServerGdbPort_ToolTipText;
65+
public static String DebuggerTab_gdbServerGroup_Text;
66+
public static String DebuggerTab_gdbServerInitRegs_Label;
67+
public static String DebuggerTab_gdbServerInitRegs_ToolTipText;
68+
public static String DebuggerTab_gdbServerLocalOnly_Label;
69+
public static String DebuggerTab_gdbServerLocalOnly_ToolTipText;
70+
public static String DebuggerTab_gdbServerLog_Label;
71+
public static String DebuggerTab_gdbServerLogBrowse_Button;
72+
public static String DebuggerTab_gdbServerLogBrowse_Title;
73+
public static String DebuggerTab_gdbServerOther_Label;
74+
public static String DebuggerTab_gdbServerSilent_Label;
75+
public static String DebuggerTab_gdbServerSilent_ToolTipText;
76+
public static String DebuggerTab_gdbServerSpeed_Label;
77+
public static String DebuggerTab_gdbServerSpeed_ToolTipText;
78+
public static String DebuggerTab_gdbServerSpeedAdaptive_Text;
79+
public static String DebuggerTab_gdbServerSpeedAuto_Text;
80+
public static String DebuggerTab_gdbServerSpeedFixed_Text;
81+
public static String DebuggerTab_gdbServerSpeedFixedUnit_Text;
82+
public static String DebuggerTab_gdbServerSwoPort_Label;
83+
public static String DebuggerTab_gdbServerSwoPort_ToolTipText;
84+
public static String DebuggerTab_gdbServerTelnetPort_Label;
85+
public static String DebuggerTab_gdbServerTelnetPort_ToolTipText;
86+
public static String DebuggerTab_gdbServerVerifyDownload_Label;
87+
public static String DebuggerTab_gdbServerVerifyDownload_ToolTipText;
88+
public static String DebuggerTab_gdbSetupGroup_Text;
89+
public static String DebuggerTab_interface_Label;
90+
public static String DebuggerTab_interface_ToolTipText;
91+
public static String DebuggerTab_interfaceGroup_Text;
92+
public static String DebuggerTab_interfaceJtag_Text;
93+
public static String DebuggerTab_interfaceSWD_Text;
94+
public static String DebuggerTab_ipAddressLabel;
95+
public static String DebuggerTab_ipAddressWarningDecoration;
96+
public static String DebuggerTab_noReset_Text;
97+
public static String DebuggerTab_noReset_ToolTipText;
98+
public static String DebuggerTab_portNumberLabel;
99+
public static String DebuggerTab_portNumberWarningDecoration;
100+
public static String DebuggerTab_remoteGroup_Text;
101+
public static String DebuggerTab_restoreDefaults_Link;
102+
public static String DebuggerTab_restoreDefaults_ToolTipText;
103+
public static String DebuggerTab_update_thread_list_on_suspend_Text;
104+
public static String DebuggerTab_update_thread_list_on_suspend_ToolTipText;
105+
public static String GDBJtagDebuggerTab_commandFactoryLabel;
106+
public static String GDBJtagDebuggerTab_connectionLabel;
107+
public static String GDBJtagDebuggerTab_gdbCommandBrowse_Title;
108+
public static String GDBJtagDebuggerTab_gdbCommandBrowse;
109+
public static String GDBJtagDebuggerTab_gdbCommandLabel;
110+
public static String GDBJtagDebuggerTab_gdbCommandVariable;
111+
public static String GDBJtagDebuggerTab_gdbSetupGroup_Text;
112+
public static String GDBJtagDebuggerTab_ipAddressLabel;
113+
public static String GDBJtagDebuggerTab_jtagDeviceLabel;
114+
public static String GDBJtagDebuggerTab_miProtocolLabel;
115+
public static String GDBJtagDebuggerTab_portNumberLabel;
116+
public static String GDBJtagDebuggerTab_remoteGroup_Text;
117+
public static String GDBJtagDebuggerTab_update_thread_list_on_suspend;
118+
public static String GDBJtagDebuggerTab_useRemote_Text;
119+
public static String GDBJtagDebuggerTab_verboseModeLabel;
120+
public static String GDBJtagStartupTab_doHalt_Text;
121+
public static String GDBJtagStartupTab_doReset_Text;
122+
public static String GDBJtagStartupTab_FileBrowse_Label;
123+
public static String GDBJtagStartupTab_FileBrowse_Message;
124+
public static String GDBJtagStartupTab_FileBrowseWs_Label;
125+
public static String GDBJtagStartupTab_FileBrowseWs_Message;
126+
public static String GDBJtagStartupTab_imageFileBrowse_Title;
127+
public static String GDBJtagStartupTab_imageFileBrowseWs_Title;
128+
public static String GDBJtagStartupTab_imageFileName_does_not_exist;
129+
public static String GDBJtagStartupTab_imageFileName_not_specified;
130+
public static String GDBJtagStartupTab_imageLabel_Text;
131+
public static String GDBJtagStartupTab_imageOffset_not_specified;
132+
public static String GDBJtagStartupTab_imageOffsetLabel_Text;
133+
public static String GDBJtagStartupTab_initGroup_Text;
134+
public static String GDBJtagStartupTab_loadGroup_Text;
135+
public static String GDBJtagStartupTab_loadImage_Text;
136+
public static String GDBJtagStartupTab_loadSymbols_Text;
137+
public static String GDBJtagStartupTab_pcRegister_not_specified;
138+
public static String GDBJtagStartupTab_runGroup_Text;
139+
public static String GDBJtagStartupTab_runOptionGroup_Text;
140+
public static String GDBJtagStartupTab_setPcRegister_Text;
141+
public static String GDBJtagStartupTab_setResume_Text;
142+
public static String GDBJtagStartupTab_setStopAt_Text;
143+
public static String GDBJtagStartupTab_stopAt_not_specified;
144+
public static String GDBJtagStartupTab_symbolsFileBrowse_Title;
145+
public static String GDBJtagStartupTab_symbolsFileBrowseWs_Title;
146+
public static String GDBJtagStartupTab_symbolsFileName_does_not_exist;
147+
public static String GDBJtagStartupTab_symbolsFileName_not_specified;
148+
public static String GDBJtagStartupTab_symbolsLabel_Text;
149+
public static String GDBJtagStartupTab_symbolsOffset_not_specified;
150+
public static String GDBJtagStartupTab_symbolsOffsetLabel_Text;
151+
public static String GDBJtagStartupTab_useFile_Label;
152+
public static String GDBJtagStartupTab_useProjectBinary_Label;
153+
public static String GDBJtagStartupTab_useProjectBinary_ToolTip;
32154
public static String GlobalMcuPagePropertyPage_description;
33-
34-
public static String McuPage_executable_label;
35155
public static String McuPage_executable_folder;
36-
156+
public static String McuPage_executable_label;
157+
public static String ProjectMcuPagePropertyPage_description;
158+
public static String StartupTab_doContinue_Text;
159+
public static String StartupTab_doContinue_ToolTipText;
160+
public static String StartupTab_doDebugInRam_Text;
161+
public static String StartupTab_doDebugInRam_ToolTipText;
162+
public static String StartupTab_doFirstReset_Text;
163+
public static String StartupTab_doFirstReset_ToolTipText;
164+
public static String StartupTab_doSecondReset_Text;
165+
public static String StartupTab_doSecondReset_ToolTipText;
166+
public static String StartupTab_enableFlashBreakpoints_Text;
167+
public static String StartupTab_enableFlashBreakpoints_ToolTipText;
168+
public static String StartupTab_enableSemihosting_Text;
169+
public static String StartupTab_enableSemihosting_ToolTipText;
170+
public static String StartupTab_enableSemihostingRouted_Text;
171+
public static String StartupTab_enableSemihostingRouted_ToolTipText;
172+
public static String StartupTab_enableSwo_Text;
173+
public static String StartupTab_enableSwo_ToolTipText;
174+
public static String StartupTab_FileBrowse_Label;
175+
public static String StartupTab_FileBrowseWs_Label;
176+
public static String StartupTab_FileBrowseWs_Message;
177+
public static String StartupTab_firstResetSpeed_Text;
178+
public static String StartupTab_firstResetSpeed_ToolTipText;
179+
public static String StartupTab_firstResetSpeedUnit_Text;
180+
public static String StartupTab_firstResetType_Text;
181+
public static String StartupTab_firstResetType_ToolTipText;
182+
public static String StartupTab_imageFileBrowse_Title;
183+
public static String StartupTab_imageFileBrowseWs_Title;
184+
public static String StartupTab_imageFileName_does_not_exist;
185+
public static String StartupTab_imageFileName_not_specified;
186+
public static String StartupTab_imageOffset_not_specified;
187+
public static String StartupTab_imageOffsetLabel_Text;
188+
public static String StartupTab_initCommands_ToolTipText;
189+
public static String StartupTab_initGroup_Text;
190+
public static String StartupTab_interfaceSpeed_Label;
191+
public static String StartupTab_interfaceSpeed_ToolTipText;
192+
public static String StartupTab_interfaceSpeedAdaptive_Text;
193+
public static String StartupTab_interfaceSpeedAuto_Text;
194+
public static String StartupTab_interfaceSpeedFixed_Text;
195+
public static String StartupTab_interfaceSpeedFixedUnit_Text;
196+
public static String StartupTab_loadGroup_Text;
197+
public static String StartupTab_loadImage_Text;
198+
public static String StartupTab_loadSymbols_Text;
199+
public static String StartupTab_pcRegister_not_specified;
200+
public static String StartupTab_pcRegister_ToolTipText;
201+
public static String StartupTab_runCommands_ToolTipText;
202+
public static String StartupTab_runGroup_Text;
203+
public static String StartupTab_runOptionGroup_Text;
204+
public static String StartupTab_secondResetType_Text;
205+
public static String StartupTab_secondResetWarning_Text;
206+
public static String StartupTab_semihostingGdbClient_Text;
207+
public static String StartupTab_semihostingGdbClient_ToolTipText;
208+
public static String StartupTab_semihostingTelnet_Text;
209+
public static String StartupTab_semihostingTelnet_ToolTipText;
210+
public static String StartupTab_setPcRegister_Text;
211+
public static String StartupTab_setPcRegister_ToolTipText;
212+
public static String StartupTab_setResume_Text;
213+
public static String StartupTab_setStopAt_Text;
214+
public static String StartupTab_setStopAt_ToolTipText;
215+
public static String StartupTab_stopAt_not_specified;
216+
public static String StartupTab_swoEnableTargetCpuFreq_Text;
217+
public static String StartupTab_swoEnableTargetCpuFreq_ToolTipText;
218+
public static String StartupTab_swoEnableTargetCpuFreqUnit_Text;
219+
public static String StartupTab_swoEnableTargetPortMask_Text;
220+
public static String StartupTab_swoEnableTargetPortMask_ToolTipText;
221+
public static String StartupTab_swoEnableTargetSwoFreq_Text;
222+
public static String StartupTab_swoEnableTargetSwoFreq_ToolTipText;
223+
public static String StartupTab_swoEnableTargetSwoFreqUnit_Text;
224+
public static String StartupTab_symbolsFileBrowse_Title;
225+
public static String StartupTab_symbolsFileBrowseWs_Title;
226+
public static String StartupTab_symbolsFileName_does_not_exist;
227+
public static String StartupTab_symbolsFileName_not_specified;
228+
public static String StartupTab_symbolsOffset_not_specified;
229+
public static String StartupTab_symbolsOffsetLabel_Text;
230+
public static String StartupTab_useFile_Label;
231+
public static String StartupTab_useProjectBinary_Label;
232+
public static String StartupTab_useProjectBinary_ToolTipText;
233+
public static String WorkspaceMcuPagePropertyPage_description;
37234
// ------------------------------------------------------------------------
38235

39236
static {
40237
// initialise resource bundle
41238
NLS.initializeMessages(MESSAGES, Messages.class);
42239
}
43240

44-
private static ResourceBundle RESOURCE_BUNDLE;
45-
static {
46-
try {
47-
RESOURCE_BUNDLE = ResourceBundle.getBundle(MESSAGES);
48-
} catch (MissingResourceException e) {
49-
Activator.log(e);
50-
}
51-
}
52-
53241
private Messages() {
54242
}
55-
56-
public static String getString(String key) {
57-
try {
58-
return RESOURCE_BUNDLE.getString(key);
59-
} catch (MissingResourceException e) {
60-
return '!' + key + '!';
61-
}
62-
}
63-
64-
public static ResourceBundle getResourceBundle() {
65-
return RESOURCE_BUNDLE;
66-
}
67-
68-
// ------------------------------------------------------------------------
69243
}

0 commit comments

Comments
 (0)