diff --git a/tools/demobench/src/main/java/net/corda/demobench/config/LoggingConfig.java b/tools/demobench/src/main/java/net/corda/demobench/config/LoggingConfig.java
index 912f72204c..9a1c4cf40c 100644
--- a/tools/demobench/src/main/java/net/corda/demobench/config/LoggingConfig.java
+++ b/tools/demobench/src/main/java/net/corda/demobench/config/LoggingConfig.java
@@ -6,6 +6,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;
+/**
+ * Configuration class for JUL / TornadoFX.
+ * Requires -Djava.util.logging.config.class=net.corda.demobench.config.LoggingConfig
+ * to be added to the JVM's command line.
+ */
public class LoggingConfig {
public LoggingConfig() throws IOException {
@@ -16,7 +21,8 @@ public class LoggingConfig {
}
private static InputStream getLoggingProperties() throws IOException {
- InputStream input = LoggingConfig.class.getResourceAsStream("logging.properties");
+ ClassLoader classLoader = LoggingConfig.class.getClassLoader();
+ InputStream input = classLoader.getResourceAsStream("logging.properties");
if (input == null) {
File javaHome = new File(System.getProperty("java.home"));
input = new FileInputStream(new File(new File(javaHome, "lib"), "logging.properties"));
diff --git a/tools/demobench/src/main/java/net/corda/demobench/pty/R3Pty.java b/tools/demobench/src/main/java/net/corda/demobench/pty/R3Pty.java
index 3f4cd27859..f133c27ce9 100644
--- a/tools/demobench/src/main/java/net/corda/demobench/pty/R3Pty.java
+++ b/tools/demobench/src/main/java/net/corda/demobench/pty/R3Pty.java
@@ -1,19 +1,13 @@
package net.corda.demobench.pty;
-import com.jediterm.terminal.TerminalColor;
-import com.jediterm.terminal.TextStyle;
import com.jediterm.terminal.TtyConnector;
import com.jediterm.terminal.ui.*;
-import com.jediterm.terminal.ui.settings.DefaultSettingsProvider;
import com.jediterm.terminal.ui.settings.SettingsProvider;
import com.pty4j.PtyProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.imageio.ImageIO;
-import javax.swing.*;
import java.awt.*;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -81,38 +75,4 @@ public class R3Pty implements AutoCloseable {
run(args, System.getenv());
}
- public static void main(final String[] args) throws IOException {
- JFrame frame = new JFrame("R3 Example");
- frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- frame.setIconImage(ImageIO.read(R3Pty.class.getResourceAsStream("/r3logo.png")));
-
- SettingsProvider settings = new DefaultSettingsProvider() {
- @Override
- public TextStyle getDefaultStyle() {
- return new TextStyle(TerminalColor.WHITE, TerminalColor.BLACK);
- }
-
- @Override
- public float getTerminalFontSize() {
- return 20;
- }
-
- @Override
- public boolean emulateX11CopyPaste() {
- return true;
- }
- };
-
- R3Pty pty = new R3Pty("Bungo", settings, new Dimension(164, 40));
-
- frame.getContentPane().add(pty.getTerminal(), BorderLayout.CENTER);
-
- frame.pack();
- frame.setLocationByPlatform(true);
- frame.setResizable(true);
- frame.setVisible(true);
-
- pty.run(args);
- }
-
}
diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/views/DemoBenchView.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/views/DemoBenchView.kt
index 36ab22e691..8e80638ec4 100644
--- a/tools/demobench/src/main/kotlin/net/corda/demobench/views/DemoBenchView.kt
+++ b/tools/demobench/src/main/kotlin/net/corda/demobench/views/DemoBenchView.kt
@@ -3,11 +3,12 @@ package net.corda.demobench.views
import com.jediterm.terminal.TerminalColor
import com.jediterm.terminal.TextStyle
import com.jediterm.terminal.ui.settings.DefaultSettingsProvider
+import java.util.*
import javafx.application.Platform
-import javafx.collections.FXCollections
import javafx.embed.swing.SwingNode
import javafx.scene.Parent
import javafx.scene.control.Button
+import javafx.scene.control.Tab
import javafx.scene.control.TabPane
import javax.swing.SwingUtilities
import net.corda.demobench.pty.R3Pty
@@ -27,11 +28,9 @@ class DemoBenchView : View("Corda Demo Bench") {
importStylesheet("/net/corda/demobench/style.css")
primaryStage.setOnCloseRequest {
- // Close all open tabs
- FXCollections.observableArrayList(nodeTabPane.tabs).forEach {
- (it as CloseableTab).requestClose()
- }
+ log.info("Exiting")
+ closeAllTabs()
Platform.exit()
}
@@ -42,13 +41,19 @@ class DemoBenchView : View("Corda Demo Bench") {
addNodeButton.fire()
}
+ private fun closeAllTabs() {
+ ArrayList(nodeTabPane.tabs).forEach {
+ (it as CloseableTab).requestClose()
+ }
+ }
+
fun createNode(): CloseableTab {
val pty = R3Pty("Banksy", settingsProvider, java.awt.Dimension(160, 80))
val nodeTabView = NodeTabView(pty.name)
val nodeTab = CloseableTab(pty.name, nodeTabView.root)
// Ensure that we close the terminal along with the tab.
- nodeTab.setOnClosed {
+ nodeTab.setOnCloseRequest {
pty.close()
}
diff --git a/tools/demobench/src/main/resources/logback.xml b/tools/demobench/src/main/resources/logback.xml
index a3e60a7979..35361a9ef1 100644
--- a/tools/demobench/src/main/resources/logback.xml
+++ b/tools/demobench/src/main/resources/logback.xml
@@ -13,5 +13,4 @@
-
\ No newline at end of file