Fixes some behavior regarding backups
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

Makes sure to only proceed with backups if a valid path is given
Makes the backup run in its own thread to prevent the software from locking up
Makes sure only one backup can be running at once
This commit is contained in:
2021-09-27 18:06:33 +02:00
parent 849655bfc6
commit bf77c13072
2 changed files with 29 additions and 11 deletions

View File

@ -33,7 +33,7 @@ import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.getR
*/
public class ServerLauncherGUI extends MessageHandler implements ActionListener, GUI {
private final JLabel lblStatuslabel = new JLabel("Servers are stopped");
private final JLabel lblStatusLabel = new JLabel("Servers are stopped");
private final ServerLauncherController controller;
private Map<String, String> textStrings;
private Tray applicationTray;
@ -101,7 +101,7 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
@Override
public void setStatus(String text) {
this.lblStatuslabel.setText(text);
this.lblStatusLabel.setText(text);
this.logMessage(text);
}
@ -243,11 +243,11 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
panelBasic.add(profiles);
profiles.addActionListener(this);
sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 6, SpringLayout.SOUTH, addProfileButton);
sl_panel.putConstraint(SpringLayout.SOUTH, lblStatuslabel, -10, SpringLayout.SOUTH, panelBasic);
sl_panel.putConstraint(SpringLayout.WEST, lblStatuslabel, 10, SpringLayout.WEST, panelBasic);
sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, -10, SpringLayout.EAST, panelBasic);
panelBasic.add(lblStatuslabel);
sl_panel.putConstraint(SpringLayout.NORTH, lblStatusLabel, 6, SpringLayout.SOUTH, addProfileButton);
sl_panel.putConstraint(SpringLayout.SOUTH, lblStatusLabel, -10, SpringLayout.SOUTH, panelBasic);
sl_panel.putConstraint(SpringLayout.WEST, lblStatusLabel, 10, SpringLayout.WEST, panelBasic);
sl_panel.putConstraint(SpringLayout.EAST, lblStatusLabel, -10, SpringLayout.EAST, panelBasic);
panelBasic.add(lblStatusLabel);
addServerButton = new JButton("Add server");
sl_panel.putConstraint(SpringLayout.NORTH, addServerButton, 0, SpringLayout.NORTH, startServerButton);
@ -314,7 +314,7 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
@Override
public void actionPerformed(ActionEvent e) {
Object actionSource = e.getSource();
//Registers actions on the main tab
//Register actions on the main tab
handleMainTabButtons(actionSource);
}
@ -333,7 +333,8 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
} else if (actionSource == addServerButton) {
addServer();
} else if (actionSource == backupButton) {
CommonFunctions.backup(this);
//Run backup in its own thread to prevent locking up
Executors.newSingleThreadExecutor().execute(() -> CommonFunctions.backup(this));
} else if (actionSource == addProfileButton) {
controller.addProfile(JOptionPane.showInputDialog("Profile name: "));
updateProfiles();