Skip to content

Commit ef45678

Browse files
committed
GH-308 use class selector in header instead of direct style attribute
1 parent 1989bb1 commit ef45678

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaThreadsProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static String getThreadsHTML(HeapContext context) {
198198
JavaClass javaClassClass = heap.getJavaClassByName(Class.class.getName());
199199
// Use this to enable VisualVM color scheme for threads dumps:
200200
// sw.append("<pre style='color: #cc3300;'>"); // NOI18N
201+
sb.append("<head><style>span.g {color: #666666;}</style></head>");
201202
sb.append("<pre>"); // NOI18N
202203
for (GCRoot root : roots) {
203204
if(root.getKind().equals(GCRoot.THREAD_OBJECT)) {
@@ -255,15 +256,15 @@ static String getThreadsHTML(HeapContext context) {
255256
} else if (GCRoot.JNI_LOCAL.equals(local.getKind())) {
256257
text = Bundle.JavaThreadsProvider_JniLocal();
257258
}
258-
sb.append(" <span style=\"color: #666666\">" + text + ":</span> ").append(HeapUtils.instanceToHtml(localInstance, false, javaClassClass)).append("<br>"); // NOI18N
259+
sb.append(" <span class=\"g\">" + text + ":</span> ").append(HeapUtils.instanceToHtml(localInstance, false, javaClassClass)).append("<br>"); // NOI18N
259260
} else {
260261
String text = "";
261262
if (GCRoot.JAVA_FRAME.equals(local.getKind())) {
262263
text = Bundle.JavaThreadsProvider_UnknownLocalVariable();
263264
} else if (GCRoot.JNI_LOCAL.equals(local.getKind())) {
264265
text = Bundle.JavaThreadsProvider_UnknownJniLocal();
265266
}
266-
sb.append(" <span style=\"color: #666666\">" + text + "</span><br>"); // NOI18N
267+
sb.append(" <span class=\"g\">" + text + "</span><br>"); // NOI18N
267268
}
268269
}
269270
}

visualvm/libs.profiler/lib.profiler.ui/src/org/graalvm/visualvm/lib/ui/components/HTMLTextArea.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,14 @@ public void setText(String value) {
653653
value = value.replaceAll("\\n\\r|\\r\\n|\\n|\\r", "<br>"); //NOI18N
654654
value = value.replace("<code>", "<code style=\"font-size: " + font.getSize() + "pt;\">"); //NOI18N
655655

656+
int index = getHeaderEndIndex(value);
657+
String header = "";
658+
if (index != -1) {
659+
header = value.substring(0, index);
660+
value = value.substring(index);
661+
}
656662
String colorText = "rgb(" + textColor.getRed() + "," + textColor.getGreen() + "," + textColor.getBlue() + ")"; //NOI18N
657-
String newText = "<html><body text=\"" + colorText + "\" style=\"font-size: " + font.getSize() + //NOI18N
663+
String newText = "<html>" + header + "<body text=\"" + colorText + "\" style=\"font-size: " + font.getSize() + //NOI18N
658664
"pt; font-family: " + font.getName() + ";\">" + value + "</body></html>"; //NOI18N
659665

660666
setDocument(getEditorKit().createDefaultDocument()); // Workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042872
@@ -866,4 +872,10 @@ protected void showURL(URL url) {
866872
// override to react to URL clicks
867873
}
868874

875+
private static int getHeaderEndIndex(String htmlText) {
876+
if (htmlText.startsWith("<head>")) {
877+
return htmlText.indexOf("</head>")+"</head>".length();
878+
}
879+
return -1;
880+
}
869881
}

0 commit comments

Comments
 (0)