Skip to content

Commit d5314a3

Browse files
committed
I18N for HeapViewer, part 1
1 parent 420506f commit d5314a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+414
-190
lines changed

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/ClassesContainer.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,32 @@
3030
import com.sun.tools.visualvm.heapviewer.model.ContainerNode;
3131
import com.sun.tools.visualvm.heapviewer.model.DataType;
3232
import com.sun.tools.visualvm.heapviewer.ui.UIThresholds;
33+
import org.openide.util.NbBundle;
3334

3435
/**
3536
*
3637
* @author Jiri Sedlacek
3738
*/
39+
@NbBundle.Messages({
40+
"ClassesContainer_MoreNodes=<another {0} classes left>",
41+
"ClassesContainer_SamplesContainer=<sample {0} classes>",
42+
"ClassesContainer_NodesContainer=<classes {0}-{1}>"
43+
})
3844
public final class ClassesContainer {
3945

4046
private ClassesContainer() {}
4147

4248

4349
private static String getMoreNodesString(String moreNodesCount) {
44-
return "<another " + moreNodesCount + " classes left>";
50+
return Bundle.ClassesContainer_MoreNodes(moreNodesCount);
4551
}
4652

4753
private static String getSamplesContainerString(String objectsCount) {
48-
return "<sample " + objectsCount + " classes>";
54+
return Bundle.ClassesContainer_SamplesContainer(objectsCount);
4955
}
5056

5157
private static String getNodesContainerString(String firstNodeIdx, String lastNodeIdx) {
52-
return "<classes " + firstNodeIdx + "-" + lastNodeIdx + ">";
58+
return Bundle.ClassesContainer_NodesContainer(firstNodeIdx, lastNodeIdx);
5359
}
5460

5561

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/InstanceNode.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@
3232
import org.netbeans.modules.profiler.heapwalk.details.api.DetailsSupport;
3333
import com.sun.tools.visualvm.heapviewer.model.DataType;
3434
import com.sun.tools.visualvm.heapviewer.model.HeapViewerNode;
35+
import org.openide.util.NbBundle;
3536

3637
/**
3738
*
3839
* @author Jiri Sedlacek
3940
*/
41+
@NbBundle.Messages({
42+
"InstanceNode_GCRootFlag={0} [GC root - {1}]"
43+
})
4044
public class InstanceNode extends HeapViewerNode {
4145

4246
public static enum Mode {
@@ -110,15 +114,15 @@ public int hashCode() {
110114

111115

112116
static String computeName(Instance instance, Heap heap) {
113-
String name = instance.getJavaClass().getName() + "#" + instance.getInstanceNumber();
117+
String name = instance.getJavaClass().getName() + "#" + instance.getInstanceNumber(); // NOI18N
114118
GCRoot gcroot = heap == null ? null : heap.getGCRoot(instance);
115-
if (gcroot != null) name += " [GC root - " + gcroot.getKind() + "]";
119+
if (gcroot != null) name = Bundle.InstanceNode_GCRootFlag(name, gcroot.getKind());
116120
return name;
117121
}
118122

119123
static String computeLogicalValue(Instance instance, Heap heap) {
120124
String detail = DetailsSupport.getDetailsString(instance, heap);
121-
return detail == null ? "" : detail;
125+
return detail == null ? "" : detail; // NOI18N
122126
}
123127

124128

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/InstanceNodeRenderer.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
import com.sun.tools.visualvm.heapviewer.model.HeapViewerNode;
3939
import org.openide.util.ImageUtilities;
4040
import com.sun.tools.visualvm.heapviewer.ui.HeapViewerRenderer;
41+
import org.openide.util.NbBundle;
4142

4243
/**
4344
*
4445
* @author Jiri Sedlacek
4546
*/
47+
@NbBundle.Messages({
48+
"InstanceNodeRenderer_LoopTo=loop to {0}"
49+
})
4650
public class InstanceNodeRenderer extends JavaNameRenderer implements HeapViewerRenderer {
4751

4852
private static final ImageIcon ICON_INSTANCE = Icons.getImageIcon(LanguageIcons.INSTANCE);
@@ -62,16 +66,16 @@ public void setValue(Object value, int row) {
6266
InstanceNode node = isLoop ? (InstanceNode)loop : (InstanceNode)value;
6367

6468
String name = node.getName(heap);
65-
if (name != null && !"null".equals(name)) {
69+
if (name != null && !"null".equals(name)) { // NOI18N
6670
super.setValue(name, row);
67-
if (isLoop) super.setNormalValue("loop to " + super.getNormalValue());
71+
if (isLoop) super.setNormalValue(Bundle.InstanceNodeRenderer_LoopTo(super.getNormalValue()));
6872
} else {
6973
super.setValue(null, row);
70-
super.setNormalValue("null");
74+
super.setNormalValue("null"); // NOI18N
7175
}
7276

7377
String log = node.getLogicalValue(heap);
74-
if (log != null && !log.isEmpty()) setGrayValue(" : " + log);
78+
if (log != null && !log.isEmpty()) setGrayValue(" : " + log); // NOI18N
7579

7680
JavaClass jclass = HeapViewerNode.getValue(node, DataType.CLASS, heap);
7781
ImageIcon icon = jclass != null && jclass.isArray() ? ICON_ARRAY : ICON_INSTANCE;

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/InstanceReferenceNode.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,16 @@
3232
import org.netbeans.lib.profiler.heap.ObjectFieldValue;
3333
import org.netbeans.lib.profiler.heap.Value;
3434
import com.sun.tools.visualvm.heapviewer.model.DataType;
35+
import org.openide.util.NbBundle;
3536

3637
/**
3738
*
3839
* @author Jiri Sedlacek
3940
*/
41+
@NbBundle.Messages({
42+
"InstanceReferenceNode_NodeNameField={0} {1}",
43+
"InstanceReferenceNode_NodeNameReference={0} in {1}"
44+
})
4045
public abstract class InstanceReferenceNode extends InstanceNode {
4146

4247
private final Mode mode;
@@ -89,11 +94,11 @@ public JavaClass getJavaClass() {
8994
}
9095

9196
public String getName(Heap heap) {
92-
return getInstance() == null ? "null" : super.getName(heap);
97+
return getInstance() == null ? "null" : super.getName(heap); // NOI18N
9398
}
9499

95100
public String getLogicalValue(Heap heap) {
96-
return getInstance() == null ? "" : super.getLogicalValue(heap);
101+
return getInstance() == null ? "" : super.getLogicalValue(heap); // NOI18N
97102
}
98103

99104
public long getOwnSize() {
@@ -109,7 +114,9 @@ public boolean isLeaf() {
109114
}
110115

111116
public String toString() {
112-
return getFieldName() + (Mode.INCOMING_REFERENCE.equals(mode) ? " in " : " ") + getName(null); // TODO: should not be called directly when sorting the tree
117+
// TODO: should not be called directly when sorting the tree
118+
if (Mode.INCOMING_REFERENCE.equals(mode)) return Bundle.InstanceReferenceNode_NodeNameReference(getFieldName(), getName(null));
119+
else return Bundle.InstanceReferenceNode_NodeNameField(getFieldName(), getName(null));
113120
}
114121

115122
public boolean equals(Object o) {
@@ -136,7 +143,7 @@ public ObjectFieldValue getValue() {
136143

137144
protected String computeFieldName() {
138145
org.netbeans.lib.profiler.heap.Field field = getValue().getField();
139-
return (field.isStatic() ? "static " : "") + field.getName();
146+
return (field.isStatic() ? "static " : "") + field.getName(); // NOI18N
140147
}
141148

142149
}
@@ -152,7 +159,7 @@ public ArrayItemValue getValue() {
152159
}
153160

154161
protected String computeFieldName() {
155-
return "[" + getValue().getIndex() + "]";
162+
return "[" + getValue().getIndex() + "]"; // NOI18N
156163
}
157164

158165
}

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/InstanceReferenceNodeRenderer.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@
3737
import com.sun.tools.visualvm.heapviewer.model.DataType;
3838
import com.sun.tools.visualvm.heapviewer.model.HeapViewerNode;
3939
import com.sun.tools.visualvm.heapviewer.ui.HeapViewerRenderer;
40+
import org.openide.util.NbBundle;
4041

4142
/**
4243
*
4344
* @author Jiri Sedlacek
4445
*/
46+
@NbBundle.Messages({
47+
"InstanceReferenceNodeRenderer_NodeNameRefence=in"
48+
})
4549
public class InstanceReferenceNodeRenderer extends MultiRenderer implements HeapViewerRenderer {
4650

4751
protected static final Icon ICON_PRIMITIVE = Icons.getIcon(LanguageIcons.PRIMITIVE);
@@ -63,11 +67,11 @@ public InstanceReferenceNodeRenderer(Heap heap) {
6367
public void setValue(Object value, int row) {
6468
InstanceReferenceNode node = (InstanceReferenceNode) value;
6569
String name = node.getFieldName();
66-
if (name.startsWith("static ")) {
67-
setNormalValue("static ");
68-
setBoldValue(name.substring("static ".length()));
70+
if (name.startsWith("static ")) { // NOI18N
71+
setNormalValue("static "); // NOI18N
72+
setBoldValue(name.substring("static ".length())); // NOI18N
6973
} else {
70-
setNormalValue("");
74+
setNormalValue(""); // NOI18N
7175
setBoldValue(name);
7276
}
7377
setIcon(Icons.getIcon(InstanceNode.Mode.INCOMING_REFERENCE.equals(node.getMode()) ? ProfilerIcons.NODE_REVERSE : ProfilerIcons.NODE_FORWARD));
@@ -77,10 +81,10 @@ public void setValue(Object value, int row) {
7781
public void setValue(Object value, int row) {
7882
InstanceReferenceNode node = (InstanceReferenceNode) value;
7983
if (InstanceNode.Mode.INCOMING_REFERENCE.equals(node.getMode())) {
80-
setText("in");
84+
setText(Bundle.InstanceReferenceNodeRenderer_NodeNameRefence());
8185
equalsRenderer.setMargin(3, 2, 3, 0);
8286
} else {
83-
setText("=");
87+
setText("="); // NOI18N
8488
equalsRenderer.setMargin(3, 0, 3, 0);
8589
}
8690
}

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/InstancesContainer.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@
3131
import com.sun.tools.visualvm.heapviewer.model.ContainerNode;
3232
import com.sun.tools.visualvm.heapviewer.model.DataType;
3333
import com.sun.tools.visualvm.heapviewer.ui.UIThresholds;
34+
import org.openide.util.NbBundle;
3435

3536
/**
3637
*
3738
* @author Jiri Sedlacek
3839
*/
40+
@NbBundle.Messages({
41+
"InstancesContainer_MoreNodes=<another {0} instances left>",
42+
"InstancesContainer_SamplesContainer=<sample {0} instances>",
43+
"InstancesContainer_NodesContainer=<instances {0}-{1}>"
44+
})
3945
public final class InstancesContainer {
4046

4147
public static class Objects extends ContainerNode<Instance> {
@@ -127,15 +133,15 @@ private InstancesContainer() {}
127133

128134

129135
private static String getMoreNodesString(String moreNodesCount) {
130-
return "<another " + moreNodesCount + " instances left>";
136+
return Bundle.InstancesContainer_MoreNodes(moreNodesCount);
131137
}
132138

133139
private static String getSamplesContainerString(String objectsCount) {
134-
return "<sample " + objectsCount + " instances>";
140+
return Bundle.InstancesContainer_SamplesContainer(objectsCount);
135141
}
136142

137143
private static String getNodesContainerString(String firstNodeIdx, String lastNodeIdx) {
138-
return "<instances " + firstNodeIdx + "-" + lastNodeIdx + ">";
144+
return Bundle.InstancesContainer_NodesContainer(firstNodeIdx, lastNodeIdx);
139145
}
140146

141147
}

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/JavaGoToSourceAction.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@
3333
import com.sun.tools.visualvm.heapviewer.model.HeapViewerNode;
3434
import com.sun.tools.visualvm.heapviewer.ui.HeapViewerActions;
3535
import com.sun.tools.visualvm.heapviewer.ui.HeapViewerNodeAction;
36+
import org.openide.util.NbBundle;
3637
import org.openide.util.lookup.ServiceProvider;
3738

3839
/**
3940
*
4041
* @author Jiri Sedlacek
4142
*/
4243
@ServiceProvider(service=HeapViewerNodeAction.Provider.class)
44+
@NbBundle.Messages({
45+
"JavaGoToSourceAction_GoToSource=Go to Source"
46+
})
4347
public class JavaGoToSourceAction extends HeapViewerNodeAction.Provider {
4448

4549
public boolean supportsView(HeapContext context, String viewID) {
@@ -68,7 +72,7 @@ private static class GoToSourceAction extends HeapViewerNodeAction {
6872

6973

7074
private GoToSourceAction(JavaClass javaClass) {
71-
super("Go to Source", 210);
75+
super(Bundle.JavaGoToSourceAction_GoToSource(), 210);
7276

7377
className = javaClass == null ? null : javaClass.getName();
7478
methodName = null;
@@ -78,20 +82,20 @@ private GoToSourceAction(JavaClass javaClass) {
7882
}
7983

8084
private GoToSourceAction(StackFrameNode sfNode) {
81-
super("Go to Source", 210);
85+
super(Bundle.JavaGoToSourceAction_GoToSource(), 210);
8286

8387
String name = sfNode.getName();
8488

85-
int fileIdx = name.indexOf("(");
89+
int fileIdx = name.indexOf("("); // NOI18N
8690
String methodName = name.substring(0, fileIdx);
8791
String fileName = name.substring(fileIdx);
8892

89-
int classIdx = methodName.lastIndexOf('.');
93+
int classIdx = methodName.lastIndexOf('.'); // NOI18N
9094
className = methodName.substring(0, classIdx);
9195
this.methodName = methodName.substring(classIdx + 1);
9296

93-
int lineIdxS = fileName.indexOf(':'); // can be 'Native Method' instead of '<file name>:<line number>'
94-
int lineIdxE = fileName.indexOf(')');
97+
int lineIdxS = fileName.indexOf(':'); // can be 'Native Method' instead of '<file name>:<line number>' // NOI18N
98+
int lineIdxE = fileName.indexOf(')'); // NOI18N
9599
line = lineIdxS == -1 ? -1 : Integer.parseInt(fileName.substring(lineIdxS + 1, lineIdxE));
96100

97101
setEnabled(true);

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/JavaHeapFragment.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@
2929
import org.netbeans.lib.profiler.heap.Heap;
3030
import com.sun.tools.visualvm.heapviewer.HeapContext;
3131
import com.sun.tools.visualvm.heapviewer.HeapFragment;
32+
import org.openide.util.NbBundle;
3233

3334
/**
3435
*
3536
* @author Jiri Sedlacek
3637
*/
38+
@NbBundle.Messages({
39+
"JavaHeapFragment_Name=Java Heap",
40+
"JavaHeapFragment_Description=Java Heap"
41+
})
3742
public class JavaHeapFragment extends HeapFragment {
3843

3944
public JavaHeapFragment(Heap heap) throws IOException {
40-
super("java_heap", "Java Heap", "Java Heap", heap);
45+
super("java_heap", Bundle.JavaHeapFragment_Name(), Bundle.JavaHeapFragment_Description(), heap); // NOI18N
4146
}
4247

4348
public static boolean isJavaHeap(HeapContext context) {

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/LocalObjectNode.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,24 @@
2828
import org.netbeans.lib.profiler.heap.Heap;
2929
import org.netbeans.lib.profiler.heap.Instance;
3030
import com.sun.tools.visualvm.heapviewer.model.DataType;
31+
import org.openide.util.NbBundle;
3132

3233
/**
3334
*
3435
* @author Jiri Sedlacek
3536
*/
37+
@NbBundle.Messages({
38+
"LocalObjectNode_LocalObject=local object",
39+
"LocalObjectNode_UnknownLocalObject=unknown local object",
40+
"LocalObjectNode_Unknown=<unknown>"
41+
})
3642
public class LocalObjectNode extends InstanceNode {
3743

3844
private final String localObjectName;
3945

4046

4147
public LocalObjectNode(Instance instance) {
42-
this(instance, "local object");
48+
this(instance, Bundle.LocalObjectNode_LocalObject());
4349
}
4450

4551
public LocalObjectNode(Instance instance, String localObjectName) {
@@ -56,11 +62,11 @@ public String getLocalObjectName() {
5662
public static class Unknown extends LocalObjectNode {
5763

5864
public Unknown() {
59-
super(null, "unknown local object");
65+
super(null, Bundle.LocalObjectNode_UnknownLocalObject());
6066
}
6167

6268
public String getName(Heap heap) {
63-
return "<unknown>";
69+
return Bundle.LocalObjectNode_Unknown();
6470
}
6571

6672
public boolean equals(Object o) {

visualvm/heapviewer/src/com/sun/tools/visualvm/heapviewer/java/LocalObjectNodeRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Icon getIcon() {
6767

6868
public String getShortName() {
6969
String name = instanceRenderer.getShortName();
70-
int nameIdx = name.lastIndexOf('[');
70+
int nameIdx = name.lastIndexOf('['); // NOI18N
7171
if (nameIdx != -1) name = name.substring(0, nameIdx).trim();
7272
return /*lvRenderer + " " +*/ name;
7373
}

0 commit comments

Comments
 (0)