Blame SOURCES/10-revert-flameview.patch

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