Add a method for manually reloading a server

This commit is contained in:
Manuel Thalmann 2022-11-16 21:29:27 +01:00
parent 5e93294c38
commit ce65993bee

View file

@ -32,7 +32,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
private final Dimension UHDTHRESHOLD = new Dimension(2000, 1500);
private final String STANDARDENCODING = "UTF-8";
private JMenuItem connect, exit, open, test, retest, textView, graphicView, clear;
private JMenuItem connect, reset, exit, open, test, retest, textView, graphicView, clear;
private JMenu menuServer;
private JButton enter;
private JTextField arguments;
@ -80,6 +80,9 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
connect = new JMenuItem("Connect ...");
connect.addActionListener(this);
menuServer.add(connect);
reset = new JMenuItem("Reset Server...");
reset.addActionListener(this);
menuServer.add(reset);
JMenu menuView = new JMenu("View");
menuBar.add(menuView);
@ -251,7 +254,7 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
private void connectCommand() throws Exception {
String name = openFileDialog(getPathCompiled(), "*Server.class");
command = ServerFactory.createServer(name);
loadServer(name);
lastServer = name;
String fullClassName = command.getClass().getName();
String simpleClassName = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
@ -259,6 +262,16 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
}
private void resetCommand() throws Exception {
if (lastServer != null) {
loadServer(lastServer);
}
}
private void loadServer(String name) throws Exception {
command = ServerFactory.createServer(name);
}
private void openFile() throws Exception {
String name = openFileDialog(null, null);
@ -291,6 +304,8 @@ public class ExBoxFrame extends JFrame implements ActionListener, ItemListener {
execute(arguments.getText());
} else if (e.getSource() == connect) {
connectCommand();
} else if (e.getSource() == reset) {
resetCommand();
} else if (e.getSource() == test) {
testCommand(false);
} else if (e.getSource() == retest) {