From f2b289f8c518a2ae402c2659fc3fc1ce2daeaea7 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Tue, 26 Nov 2019 19:08:25 +0100 Subject: [PATCH] When pressing "Reset" button the state label will be updated accordingly --- .gitignore | 1 + src/main/java/Controller.java | 25 ++++++++++++++++++------- src/main/resources/mainWindow.fxml | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5df879d..68d071a 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,4 @@ $RECYCLE.BIN/ /test.json /steam_api.md5 /src/main/java/util/env/Default.java +/src/main/java/GetListOfDlc.java diff --git a/src/main/java/Controller.java b/src/main/java/Controller.java index 431de97..48a6b1c 100644 --- a/src/main/java/Controller.java +++ b/src/main/java/Controller.java @@ -68,11 +68,7 @@ public class Controller { //retrieveDlcList_button.setDisable(true); // WIP generate_tooltips(); fix_dlc_textarea_prompt_text(); - try { - read(); - } catch (NullPointerException e) { - System.err.println("Can't fill out fields, no configuration file set!"); - } + reset(true); } private void read() { @@ -114,12 +110,23 @@ public class Controller { }; } - public void reset() { + private void reset(boolean silent) { + if (silent) { + state_label.setText(""); + } else { + state_label.setText("Resetting fields..."); + } try { config.read(); read(); + if (!silent) { + state_label.setText("Successfully reset all fields!"); + } } catch (NullPointerException e) { System.err.println("Can't fill out fields, no configuration file set!"); + if (!silent) { + state_label.setText("Could not reset fields, no configuration file set!"); + } } } @@ -217,7 +224,7 @@ public class Controller { config.setConfig(file.getParent() + "\\cream_api.ini"); path_textfield.setText(file.getParent()); steamApiPathString = file.getAbsolutePath(); - reset(); + reset(true); } catch (ConfigurationException | IOException e) { e.printStackTrace(); } @@ -261,4 +268,8 @@ public class Controller { path_button.setDisable(b); retrieveDlcList_button.setDisable(b); } + + public void resetFromButton() { + reset(false); + } } diff --git a/src/main/resources/mainWindow.fxml b/src/main/resources/mainWindow.fxml index b0de22b..244d629 100644 --- a/src/main/resources/mainWindow.fxml +++ b/src/main/resources/mainWindow.fxml @@ -52,6 +52,6 @@ - +