mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
Refactor shutdown code, although AWT is still misbehaving.
This commit is contained in:
parent
55b5a5a393
commit
f2dd59ebd3
@ -6,6 +6,11 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.logging.LogManager;
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration class for JUL / TornadoFX.
|
||||||
|
* Requires <code>-Djava.util.logging.config.class=net.corda.demobench.config.LoggingConfig</code>
|
||||||
|
* to be added to the JVM's command line.
|
||||||
|
*/
|
||||||
public class LoggingConfig {
|
public class LoggingConfig {
|
||||||
|
|
||||||
public LoggingConfig() throws IOException {
|
public LoggingConfig() throws IOException {
|
||||||
@ -16,7 +21,8 @@ public class LoggingConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static InputStream getLoggingProperties() throws IOException {
|
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) {
|
if (input == null) {
|
||||||
File javaHome = new File(System.getProperty("java.home"));
|
File javaHome = new File(System.getProperty("java.home"));
|
||||||
input = new FileInputStream(new File(new File(javaHome, "lib"), "logging.properties"));
|
input = new FileInputStream(new File(new File(javaHome, "lib"), "logging.properties"));
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
package net.corda.demobench.pty;
|
package net.corda.demobench.pty;
|
||||||
|
|
||||||
import com.jediterm.terminal.TerminalColor;
|
|
||||||
import com.jediterm.terminal.TextStyle;
|
|
||||||
import com.jediterm.terminal.TtyConnector;
|
import com.jediterm.terminal.TtyConnector;
|
||||||
import com.jediterm.terminal.ui.*;
|
import com.jediterm.terminal.ui.*;
|
||||||
import com.jediterm.terminal.ui.settings.DefaultSettingsProvider;
|
|
||||||
import com.jediterm.terminal.ui.settings.SettingsProvider;
|
import com.jediterm.terminal.ui.settings.SettingsProvider;
|
||||||
import com.pty4j.PtyProcess;
|
import com.pty4j.PtyProcess;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -81,38 +75,4 @@ public class R3Pty implements AutoCloseable {
|
|||||||
run(args, System.getenv());
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,12 @@ package net.corda.demobench.views
|
|||||||
import com.jediterm.terminal.TerminalColor
|
import com.jediterm.terminal.TerminalColor
|
||||||
import com.jediterm.terminal.TextStyle
|
import com.jediterm.terminal.TextStyle
|
||||||
import com.jediterm.terminal.ui.settings.DefaultSettingsProvider
|
import com.jediterm.terminal.ui.settings.DefaultSettingsProvider
|
||||||
|
import java.util.*
|
||||||
import javafx.application.Platform
|
import javafx.application.Platform
|
||||||
import javafx.collections.FXCollections
|
|
||||||
import javafx.embed.swing.SwingNode
|
import javafx.embed.swing.SwingNode
|
||||||
import javafx.scene.Parent
|
import javafx.scene.Parent
|
||||||
import javafx.scene.control.Button
|
import javafx.scene.control.Button
|
||||||
|
import javafx.scene.control.Tab
|
||||||
import javafx.scene.control.TabPane
|
import javafx.scene.control.TabPane
|
||||||
import javax.swing.SwingUtilities
|
import javax.swing.SwingUtilities
|
||||||
import net.corda.demobench.pty.R3Pty
|
import net.corda.demobench.pty.R3Pty
|
||||||
@ -27,11 +28,9 @@ class DemoBenchView : View("Corda Demo Bench") {
|
|||||||
importStylesheet("/net/corda/demobench/style.css")
|
importStylesheet("/net/corda/demobench/style.css")
|
||||||
|
|
||||||
primaryStage.setOnCloseRequest {
|
primaryStage.setOnCloseRequest {
|
||||||
// Close all open tabs
|
log.info("Exiting")
|
||||||
FXCollections.observableArrayList(nodeTabPane.tabs).forEach {
|
|
||||||
(it as CloseableTab).requestClose()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
closeAllTabs()
|
||||||
Platform.exit()
|
Platform.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,13 +41,19 @@ class DemoBenchView : View("Corda Demo Bench") {
|
|||||||
addNodeButton.fire()
|
addNodeButton.fire()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun closeAllTabs() {
|
||||||
|
ArrayList<Tab>(nodeTabPane.tabs).forEach {
|
||||||
|
(it as CloseableTab).requestClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun createNode(): CloseableTab {
|
fun createNode(): CloseableTab {
|
||||||
val pty = R3Pty("Banksy", settingsProvider, java.awt.Dimension(160, 80))
|
val pty = R3Pty("Banksy", settingsProvider, java.awt.Dimension(160, 80))
|
||||||
val nodeTabView = NodeTabView(pty.name)
|
val nodeTabView = NodeTabView(pty.name)
|
||||||
val nodeTab = CloseableTab(pty.name, nodeTabView.root)
|
val nodeTab = CloseableTab(pty.name, nodeTabView.root)
|
||||||
|
|
||||||
// Ensure that we close the terminal along with the tab.
|
// Ensure that we close the terminal along with the tab.
|
||||||
nodeTab.setOnClosed {
|
nodeTab.setOnCloseRequest {
|
||||||
pty.close()
|
pty.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,5 +13,4 @@
|
|||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="FILE" />
|
<appender-ref ref="FILE" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
Loading…
Reference in New Issue
Block a user