Skip to content

Commit 267fe47

Browse files
committed
I18N for HeapViewer, part 2
1 parent d5314a3 commit 267fe47

File tree

12 files changed

+178
-96
lines changed

12 files changed

+178
-96
lines changed

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/options/HeapViewerOptionsPanel.java

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,25 @@
5757
import org.netbeans.modules.profiler.heapwalk.OQLSupport;
5858
import org.openide.awt.Mnemonics;
5959
import org.openide.util.ImageUtilities;
60+
import org.openide.util.NbBundle;
6061

6162
/**
6263
*
6364
* @author Jiri Sedlacek
6465
*/
66+
@NbBundle.Messages({
67+
"HeapViewerOptionsPanel_CustomScript=Custom Script",
68+
"HeapViewerOptionsPanel_CustomScripts=Custom OQL Scripts",
69+
"HeapViewerOptionsPanel_LoadingScripts=<loading scripts>",
70+
"HeapViewerOptionsPanel_NoSavedScripts=<no saved scripts>",
71+
"HeapViewerOptionsPanel_DeleteScriptTooltip=Delete selected script",
72+
"HeapViewerOptionsPanel_MoveScriptUpTooltip=Move selected script up",
73+
"HeapViewerOptionsPanel_MoveScriptDownTooltip=Move selected script down",
74+
"HeapViewerOptionsPanel_NameLabel=&Name:",
75+
"HeapViewerOptionsPanel_DescriptionLabel=&Description (optional):",
76+
"HeapViewerOptionsPanel_PreviewLabel=&Preview:",
77+
"HeapViewerOptionsPanel_HintLabel=To add custom script, use the Save OQL Script action in Heap Viewer | OQL Console."
78+
})
6579
final class HeapViewerOptionsPanel extends JPanel {
6680

6781
private boolean loaded;
@@ -137,11 +151,11 @@ private void refreshPreset(int index) {
137151

138152
internalChange = true;
139153

140-
nameField.setText(query == null ? "" : query.getName());
154+
nameField.setText(query == null ? "" : query.getName()); // NOI18N
141155
try { nameField.setCaretPosition(0); } catch (IllegalArgumentException e) {}
142-
descrArea.setText(query == null ? "" : query.getDescription());
156+
descrArea.setText(query == null ? "" : query.getDescription()); // NOI18N
143157
try { descrArea.setCaretPosition(0); } catch (IllegalArgumentException e) {}
144-
previewArea.setScript(query == null ? "" : query.getScript());
158+
previewArea.setScript(query == null ? "" : query.getScript()); // NOI18N
145159
internalChange = false;
146160

147161
presetsPanel.setEnabled(index != -1);
@@ -162,11 +176,11 @@ private void updatePreset() {
162176
}
163177

164178
private String uniqueName(String name, int index) {
165-
if (name.isEmpty()) name = "Custom Script";
179+
if (name.isEmpty()) name = Bundle.HeapViewerOptionsPanel_CustomScript();
166180
String baseName = name;
167181

168182
int nameExt = 0;
169-
while (containsQuery(name, index)) name = baseName + " " + ++nameExt;
183+
while (containsQuery(name, index)) name = baseName + " " + ++nameExt; // NOI18N
170184

171185
return name;
172186
}
@@ -185,7 +199,7 @@ private void initComponents() {
185199

186200
setLayout(new GridBagLayout());
187201

188-
SectionSeparator presetsSection = UISupport.createSectionSeparator("Custom OQL Scripts");
202+
SectionSeparator presetsSection = UISupport.createSectionSeparator(Bundle.HeapViewerOptionsPanel_CustomScripts());
189203
c = new GridBagConstraints();
190204
c.gridy = 0;
191205
c.gridwidth = GridBagConstraints.REMAINDER;
@@ -215,10 +229,10 @@ public void removeSelectionInterval(int i1, int i2) {}
215229
});
216230
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
217231
final Dimension oneDim = new Dimension(1, 1);
218-
final JLabel loadingScriptsLabel = new JLabel("<loading scripts>", JLabel.CENTER);
232+
final JLabel loadingScriptsLabel = new JLabel(Bundle.HeapViewerOptionsPanel_LoadingScripts(), JLabel.CENTER);
219233
loadingScriptsLabel.setEnabled(false);
220234
loadingScriptsLabel.setSize(loadingScriptsLabel.getPreferredSize());
221-
final JLabel noScriptsLabel = new JLabel("<no saved scripts>", JLabel.CENTER);
235+
final JLabel noScriptsLabel = new JLabel(Bundle.HeapViewerOptionsPanel_NoSavedScripts(), JLabel.CENTER);
222236
noScriptsLabel.setEnabled(false);
223237
noScriptsLabel.setSize(noScriptsLabel.getPreferredSize());
224238
JScrollPane listScroll = new JScrollPane(list) {
@@ -253,7 +267,7 @@ protected void fireActionPerformed(ActionEvent e) {
253267
int mar = nimbusLaF ? 0 : 8;
254268
margin.left = mar;
255269
margin.right = mar;
256-
removeButton.setToolTipText("Delete selected script");
270+
removeButton.setToolTipText(Bundle.HeapViewerOptionsPanel_DeleteScriptTooltip());
257271
removeButton.setMargin(margin);
258272
upButton = new JButton() {
259273
protected void fireActionPerformed(ActionEvent e) {
@@ -262,7 +276,7 @@ protected void fireActionPerformed(ActionEvent e) {
262276
};
263277
upButton.setIcon(new ImageIcon(ImageUtilities.loadImage(
264278
"com/sun/tools/visualvm/profiler/resources/up.png", true))); // NOI18N
265-
upButton.setToolTipText("Move selected script up"); // NOI18N
279+
upButton.setToolTipText(Bundle.HeapViewerOptionsPanel_MoveScriptUpTooltip()); // NOI18N
266280
upButton.setMargin(margin);
267281
downButton = new JButton() {
268282
protected void fireActionPerformed(ActionEvent e) {
@@ -271,7 +285,7 @@ protected void fireActionPerformed(ActionEvent e) {
271285
};
272286
downButton.setIcon(new ImageIcon(ImageUtilities.loadImage(
273287
"com/sun/tools/visualvm/profiler/resources/down.png", true))); // NOI18N
274-
downButton.setToolTipText("Move selected script down");
288+
downButton.setToolTipText(Bundle.HeapViewerOptionsPanel_MoveScriptDownTooltip());
275289
downButton.setMargin(margin);
276290

277291
JPanel controlsPanel = new JPanel(new GridLayout(1, 4, 5, 0)) {
@@ -306,7 +320,7 @@ public void setEnabled(boolean enabled) {
306320
add(presetsPanel, c);
307321

308322
JLabel nameLabel = new JLabel();
309-
Mnemonics.setLocalizedText(nameLabel, "&Name:");
323+
Mnemonics.setLocalizedText(nameLabel, Bundle.HeapViewerOptionsPanel_NameLabel());
310324
c = new GridBagConstraints();
311325
c.gridx = 0;
312326
c.gridy = 0;
@@ -338,7 +352,7 @@ public void setBackground(Color bg) {
338352
presetsPanel.add(nameField, c);
339353

340354
JLabel descrLabel = new JLabel();
341-
Mnemonics.setLocalizedText(descrLabel, "&Description (optional):");
355+
Mnemonics.setLocalizedText(descrLabel, Bundle.HeapViewerOptionsPanel_DescriptionLabel());
342356
c = new GridBagConstraints();
343357
c.gridx = 0;
344358
c.gridy = 1;
@@ -378,7 +392,7 @@ public void setEnabled(boolean b) {
378392
presetsPanel.add(descrScroll, c);
379393

380394
JLabel previewLabel = new JLabel();
381-
Mnemonics.setLocalizedText(previewLabel, "&Preview:");
395+
Mnemonics.setLocalizedText(previewLabel, Bundle.HeapViewerOptionsPanel_PreviewLabel());
382396
c = new GridBagConstraints();
383397
c.gridx = 0;
384398
c.gridy = 3;
@@ -403,7 +417,7 @@ public void setEnabled(boolean b) {
403417
presetsPanel.add(previewArea, c);
404418

405419

406-
JLabel hint = new JLabel("To add custom script, use the Save OQL Script action in Heap Viewer | OQL Console.");
420+
JLabel hint = new JLabel(Bundle.HeapViewerOptionsPanel_HintLabel());
407421
hint.setEnabled(false);
408422
c = new GridBagConstraints();
409423
c.gridx = 0;

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/oql/CustomOQLQueries.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@
3333
import org.netbeans.modules.profiler.api.ProfilerStorage;
3434
import org.netbeans.modules.profiler.heapwalk.OQLSupport;
3535
import org.openide.util.Exceptions;
36+
import org.openide.util.NbBundle;
3637
import org.openide.util.RequestProcessor;
3738

3839
/**
3940
*
4041
* @author Jiri Sedlacek
4142
*/
43+
@NbBundle.Messages({
44+
"CustomOQLQueries_SaveFailed=Failed to save OQL scripts.",
45+
"CustomOQLQueries_LoadFailed=Failed to load saved OQL scripts."
46+
})
4247
public final class CustomOQLQueries {
4348

4449
private static final String SAVED_OQL_QUERIES_FILENAME = "oqlqueries"; // NOI18N
@@ -83,13 +88,13 @@ public synchronized List<OQLSupport.Query> list() {
8388

8489

8590
private void save() {
86-
new RequestProcessor("OQL Scripts Saver").post(new Runnable() {
91+
new RequestProcessor("OQL Scripts Saver").post(new Runnable() { // NOI18N
8792
public void run() {
8893
try {
8994
Properties p = listToProperties(list());
9095
ProfilerStorage.saveGlobalProperties(p, SAVED_OQL_QUERIES_FILENAME);
9196
} catch (Exception e) {
92-
ProfilerDialogs.displayError("Failed to save OQL scripts.");
97+
ProfilerDialogs.displayError(Bundle.CustomOQLQueries_SaveFailed());
9398
Exceptions.printStackTrace(e);
9499
}
95100
}
@@ -140,7 +145,7 @@ private CustomOQLQueries() {
140145
ProfilerStorage.loadGlobalProperties(p, SAVED_OQL_QUERIES_FILENAME);
141146
propertiesToList(customQueries, p);
142147
} catch (Exception e) {
143-
ProfilerDialogs.displayError("Failed to load saved OQL scripts.");
148+
ProfilerDialogs.displayError(Bundle.CustomOQLQueries_LoadFailed());
144149
Exceptions.printStackTrace(e);
145150
}
146151
}

0 commit comments

Comments
 (0)