jmc/10-revert-flameview.patch

359 lines
13 KiB
Diff
Raw Normal View History

# HG changeset patch
# Parent 37a493c3f60b2015c37630807015b217b98106cf
diff -r 37a493c3f60b -r bbf0648beb5c application/org.openjdk.jmc.flightrecorder.flameview/.classpath
--- a/application/org.openjdk.jmc.flightrecorder.flameview/.classpath Tue Nov 12 16:25:24 2019 +0100
+++ b/application/org.openjdk.jmc.flightrecorder.flameview/.classpath Mon Nov 25 17:57:23 2019 -0500
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
diff -r 37a493c3f60b -r bbf0648beb5c application/org.openjdk.jmc.flightrecorder.flameview/build.properties
--- a/application/org.openjdk.jmc.flightrecorder.flameview/build.properties Tue Nov 12 16:25:24 2019 +0100
+++ b/application/org.openjdk.jmc.flightrecorder.flameview/build.properties Mon Nov 25 17:57:23 2019 -0500
@@ -1,5 +1,4 @@
-source.. = src/main/java/,\
- src/main/resources/
+source.. = src/main/java/
output.. = target/classes/
bin.includes = META-INF/,\
.,\
diff -r 37a493c3f60b -r bbf0648beb5c application/org.openjdk.jmc.flightrecorder.flameview/pom.xml
--- a/application/org.openjdk.jmc.flightrecorder.flameview/pom.xml Tue Nov 12 16:25:24 2019 +0100
+++ b/application/org.openjdk.jmc.flightrecorder.flameview/pom.xml Mon Nov 25 17:57:23 2019 -0500
@@ -41,94 +41,4 @@
</parent>
<artifactId>org.openjdk.jmc.flightrecorder.flameview</artifactId>
<packaging>eclipse-plugin</packaging>
-
- <properties>
- <download.maven.plugin.version>1.4.2</download.maven.plugin.version>
- <download-maven-plugin.phase>process-resources</download-maven-plugin.phase>
- <download-maven-plugin.output>${project.basedir}/src/main/resources/jslibs</download-maven-plugin.output>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>com.googlecode.maven-download-plugin</groupId>
- <artifactId>download-maven-plugin</artifactId>
- <version>${download.maven.plugin.version}</version>
- <executions>
- <execution>
- <id>d3-flamegraph-css</id>
- <phase>${download-maven-plugin.phase}</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css</url>
- <unpack>false</unpack>
- <outputDirectory>${download-maven-plugin.output}</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>ie-html5shiv-js</id>
- <phase>${download-maven-plugin.phase}</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js</url>
- <unpack>false</unpack>
- <outputDirectory>${download-maven-plugin.output}</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>ie-respond-js</id>
- <phase>${download-maven-plugin.phase}</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>https://oss.maxcdn.com/respond/1.4.2/respond.min.js</url>
- <unpack>false</unpack>
- <outputDirectory>${download-maven-plugin.output}</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>d3-v4-js</id>
- <phase>${download-maven-plugin.phase}</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>https://d3js.org/d3.v4.min.js</url>
- <unpack>false</unpack>
- <outputDirectory>${download-maven-plugin.output}</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>d3-tip-js</id>
- <phase>${download-maven-plugin.phase}</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js</url>
- <unpack>false</unpack>
- <outputDirectory>${download-maven-plugin.output}</outputDirectory>
- </configuration>
- </execution>
- <execution>
- <id>d3-flamegraph-js</id>
- <phase>${download-maven-plugin.phase}</phase>
- <goals>
- <goal>wget</goal>
- </goals>
- <configuration>
- <url>https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.min.js</url>
- <unpack>false</unpack>
- <outputDirectory>${download-maven-plugin.output}</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>
diff -r 37a493c3f60b -r bbf0648beb5c application/org.openjdk.jmc.flightrecorder.flameview/src/main/java/org/openjdk/jmc/flightrecorder/flameview/views/FlameGraphView.java
--- a/application/org.openjdk.jmc.flightrecorder.flameview/src/main/java/org/openjdk/jmc/flightrecorder/flameview/views/FlameGraphView.java Tue Nov 12 16:25:24 2019 +0100
+++ b/application/org.openjdk.jmc.flightrecorder.flameview/src/main/java/org/openjdk/jmc/flightrecorder/flameview/views/FlameGraphView.java Mon Nov 25 17:57:23 2019 -0500
@@ -34,14 +34,11 @@
package org.openjdk.jmc.flightrecorder.flameview.views;
import java.io.IOException;
-
-import java.text.MessageFormat;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jface.action.Action;
@@ -77,32 +74,7 @@
import org.openjdk.jmc.ui.misc.DisplayToolkit;
public class FlameGraphView extends ViewPart implements ISelectionListener {
- private static final String HTML_PAGE;
- static {
- // from: https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css
- String cssD3Flamegraph = "jslibs/d3-flamegraph.css";
- // from: https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js
- String jsHtml5shiv = "jslibs/html5shiv.min.js";
- // from: https://oss.maxcdn.com/respond/1.4.2/respond.min.js
- String jsRespond = "jslibs/respond.min.js";
- // from: https://d3js.org/d3.v4.min.js
- String jsD3V4 = "jslibs/d3.v4.min.js";
- // from: https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js
- String jsD3Tip = "jslibs/d3-tip.min.js";
- // from: https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.min.js
- String jsD3FlameGraph = "jslibs/d3-flamegraph.min.js";
-
- String jsIeLibraries = loadLibraries(jsHtml5shiv, jsRespond);
- String jsD3Libraries = loadLibraries(jsD3V4, jsD3Tip, jsD3FlameGraph);
-
- // formatter arguments for the template: %1 - CSSs, %2 - IE9 specific scripts, %3 - 3rd party scripts
- HTML_PAGE = String.format(fileContent("page.template"),
- fileContent(cssD3Flamegraph),
- jsIeLibraries,
- jsD3Libraries);
- }
-
- private static final ExecutorService MODEL_EXECUTOR = Executors.newFixedThreadPool(1);
+ private static ExecutorService MODEL_EXECUTOR = Executors.newFixedThreadPool(1);
private FrameSeparator frameSeparator;
private Browser browser;
@@ -207,6 +179,13 @@
}, MODEL_EXECUTOR);
}
+ private static Void handleModelBuildException(Throwable ex) {
+ if (!(ex.getCause() instanceof CancellationException)) {
+ FlightRecorderUI.getDefault().getLogger().log(Level.SEVERE, "Failed to build stacktrace view model", ex); //$NON-NLS-1$
+ }
+ return null;
+ }
+
private void setModel(TraceNode root) {
if (!browser.isDisposed() && !root.equals(currentRoot)) {
currentRoot = root;
@@ -215,21 +194,19 @@
}
private void setViewerInput(TraceNode root) {
- browser.setText(HTML_PAGE);
- browser.addProgressListener(new ProgressAdapter() {
- @Override
- public void completed(ProgressEvent event) {
- browser.removeProgressListener(this);
- browser.execute(String.format("processGraph(%s);", toJSon(root)));
- }
- });
- }
-
- private static Void handleModelBuildException(Throwable ex) {
- if (!(ex.getCause() instanceof CancellationException)) {
- FlightRecorderUI.getDefault().getLogger().log(Level.SEVERE, "Failed to build stacktrace view model", ex); //$NON-NLS-1$
+ try {
+ browser.setText(StringToolkit.readString(FlameGraphView.class.getResourceAsStream("page.html")));
+ browser.addProgressListener(new ProgressAdapter() {
+ @Override
+ public void completed(ProgressEvent event) {
+ browser.removeProgressListener(this);
+ browser.execute(String.format("processGraph(%s);", toJSon(root)));
+ }
+ });
+ } catch (IOException e) {
+ browser.setText(e.getMessage());
+ e.printStackTrace();
}
- return null;
}
private static String toJSon(TraceNode root) {
@@ -261,23 +238,4 @@
private static String toJSonKeyValue(String key, String value) {
return "\"" + key + "\": " + "\"" + value + "\"";
}
-
- private static String loadLibraries(String... libs) {
- if(libs == null || libs.length == 0) {
- return "";
- } else {
- return Stream.of(libs).map(FlameGraphView::fileContent).collect(Collectors.joining("\n"));
- }
- }
-
- private static String fileContent(String fileName){
- try {
- return StringToolkit.readString(FlameGraphView.class.getClassLoader().getResourceAsStream(fileName));
- } catch (IOException e) {
- FlightRecorderUI.getDefault().getLogger()
- .log(Level.WARNING, MessageFormat
- .format("Could not load script \"{0}\",\"{1}\"", fileName, e.getMessage())); //$NON-NLS-1$
- return "";
- }
- }
}
diff -r 37a493c3f60b -r bbf0648beb5c application/org.openjdk.jmc.flightrecorder.flameview/src/main/java/org/openjdk/jmc/flightrecorder/flameview/views/page.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/application/org.openjdk.jmc.flightrecorder.flameview/src/main/java/org/openjdk/jmc/flightrecorder/flameview/views/page.html Mon Nov 25 17:57:23 2019 -0500
@@ -0,0 +1,54 @@
+<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css">
+ <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
+ <!--[if lt IE 9]>
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
+ <![endif]-->
+</head>
+
+<body onresize="resizeFlameGraph()">
+ <div id="chart"></div>
+
+ <script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js"></script>
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.min.js"></script>
+ <script type="text/javascript">
+
+ var flameGraph;
+ var currentJson;
+
+ function processGraph(jsonObj) {
+ flameGraph = d3.flamegraph()
+ .width(windowSize() * 0.9)
+ .transitionDuration(500)
+ .transitionEase(d3.easeCubic)
+ .sort(true)
+ .title("");
+ currentJson = jsonObj;
+ d3.select("#chart")
+ .datum(currentJson)
+ .call(flameGraph);
+ }
+
+ function windowSize() {
+ return Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
+ }
+
+ function resizeFlameGraph() {
+ if (flameGraph) {
+ flameGraph.width(windowSize() * 0.9);
+ d3.select("#chart")
+ .datum(currentJson)
+ .call(flameGraph);
+ }
+ }
+
+ </script>
+</body>
+
+</html>
diff -r 37a493c3f60b -r bbf0648beb5c application/org.openjdk.jmc.flightrecorder.flameview/src/main/resources/page.template
--- a/application/org.openjdk.jmc.flightrecorder.flameview/src/main/resources/page.template Tue Nov 12 16:25:24 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <style type="text/css">%1$s</style>
- <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
- <!--[if lt IE 9]>
- <script>%2$s</script>
- <![endif]-->
-</head>
-
-<body onresize="resizeFlameGraph()">
- <div id="chart"></div>
- <script type="text/javascript">%3$s</script>
- <script type="text/javascript">
-
- var flameGraph;
- var currentJson;
-
- function processGraph(jsonObj) {
- flameGraph = d3.flamegraph()
- .width(windowSize() * 0.9)
- .transitionDuration(500)
- .transitionEase(d3.easeCubic)
- .sort(true)
- .title("");
- currentJson = jsonObj;
- d3.select("#chart")
- .datum(currentJson)
- .call(flameGraph);
- }
-
- function windowSize() {
- return Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
- }
-
- function resizeFlameGraph() {
- if (flameGraph) {
- flameGraph.width(windowSize() * 0.9);
- d3.select("#chart")
- .datum(currentJson)
- .call(flameGraph);
- }
- }
-
- </script>
-</body>
-</html>
\ No newline at end of file