When pressing "Reset" button the state label will be updated accordingly

This commit is contained in:
Jeddunk 2019-11-26 19:08:25 +01:00
parent c65a800515
commit f2b289f8c5
3 changed files with 20 additions and 8 deletions

1
.gitignore vendored
View File

@ -160,3 +160,4 @@ $RECYCLE.BIN/
/test.json
/steam_api.md5
/src/main/java/util/env/Default.java
/src/main/java/GetListOfDlc.java

View File

@ -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);
}
}

View File

@ -52,6 +52,6 @@
<JFXTextArea fx:id="dlc_textarea" promptText="List of DLC..." GridPane.columnSpan="2147483647" GridPane.rowIndex="6" />
<JFXButton fx:id="retrieveDlcList_button" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onAction="#getDlcList" ripplerFill="BLACK" style="-fx-background-color: #ddd;" text="Get DLCs for AppID" GridPane.rowIndex="7" />
<JFXButton fx:id="save_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#save" ripplerFill="BLACK" style="-fx-background-color: #ddd;" text="Save" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<JFXButton fx:id="reset_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#reset" ripplerFill="BLACK" style="-fx-background-color: #ddd;" text="Reset" GridPane.columnIndex="2" GridPane.rowIndex="7" />
<JFXButton fx:id="reset_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#resetFromButton" ripplerFill="BLACK" style="-fx-background-color: #ddd;" text="Reset" GridPane.columnIndex="2" GridPane.rowIndex="7" />
<Label fx:id="state_label" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" GridPane.columnSpan="2147483647" GridPane.rowIndex="8" />
</GridPane>