Skip to content

Commit

Permalink
Fixed alert being sent at the wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
skytasul authored and skytasul committed Jul 29, 2023
1 parent 7d5e12c commit af22ad5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.skytasul</groupId>
<artifactId>noesiseasyexport</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<name>Noesis Easy Export</name>
<description>A tool to make Noesis file export much easier</description>

Expand Down
58 changes: 23 additions & 35 deletions src/main/java/fr/skytasul/noesiseasyexport/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,20 @@ private void checkButton() {
}

public void save() throws IOException {
FileOutputStream stream = new FileOutputStream(new File("nee-properties"));

Properties properties = new Properties();
if (lastFolder != null) properties.setProperty("lastFolder", lastFolder.getAbsolutePath());
if (noesisFile != null) properties.setProperty("noesis", noesisFile.getAbsolutePath());
if (!type.getSelectionModel().isEmpty()) properties.setProperty("type", type.getSelectionModel().getSelectedItem());
properties.setProperty("destination", destination.getText());
properties.setProperty("flipuv", String.valueOf(flipUVs.isSelected()));
properties.setProperty("rotate", String.valueOf(rotate90.isSelected()));
properties.setProperty("notext", String.valueOf(noTextures.isSelected()));
properties.setProperty("nogeo", String.valueOf(noGeometry.isSelected()));
properties.setProperty("noanims", String.valueOf(noAnimations.isSelected()));
properties.setProperty("advancedOptions", advancedOptions.getText());
properties.store(stream, "Noesis Easy Export properties");

stream.close();
try (FileOutputStream stream = new FileOutputStream(new File("nee-properties"))) {
Properties properties = new Properties();
if (lastFolder != null) properties.setProperty("lastFolder", lastFolder.getAbsolutePath());
if (noesisFile != null) properties.setProperty("noesis", noesisFile.getAbsolutePath());
if (!type.getSelectionModel().isEmpty()) properties.setProperty("type", type.getSelectionModel().getSelectedItem());
properties.setProperty("destination", destination.getText());
properties.setProperty("flipuv", String.valueOf(flipUVs.isSelected()));
properties.setProperty("rotate", String.valueOf(rotate90.isSelected()));
properties.setProperty("notext", String.valueOf(noTextures.isSelected()));
properties.setProperty("nogeo", String.valueOf(noGeometry.isSelected()));
properties.setProperty("noanims", String.valueOf(noAnimations.isSelected()));
properties.setProperty("advancedOptions", advancedOptions.getText());
properties.store(stream, "Noesis Easy Export properties");
}
}

@FXML
Expand All @@ -116,12 +114,9 @@ public void write(byte[] b, int off, int len) throws IOException {
}, true);
System.setOut(out);

FileInputStream stream = null;
try {
File file = new File("nee-properties");
if (file.exists()) {
stream = new FileInputStream(file);

File file = new File("nee-properties");
if (file.exists()) {
try (FileInputStream stream = new FileInputStream(file)){
Properties properties = new Properties();
properties.load(stream);
if (properties.containsKey("lastFolder")) lastFolder = new File(properties.getProperty("lastFolder"));
Expand All @@ -136,16 +131,10 @@ public void write(byte[] b, int off, int len) throws IOException {
advancedOptions.setText(properties.getProperty("advancedOptions"));

if (noesisFile != null) exe.setTextFill(Color.rgb(34, 109, 31));
}
}catch (IOException e) {
System.err.println("An error occured during load of properties.");
e.printStackTrace();
e.printStackTrace(out);
}finally {
try {
if (stream != null) stream.close();
}catch (IOException e) {
System.err.println("An error occured during load of properties.");
e.printStackTrace();
e.printStackTrace(out);
}
}
}
Expand Down Expand Up @@ -247,16 +236,15 @@ private void startButton() {
while ((s = inStreamReader.readLine()) != null) {
System.out.println(s);
}

System.out.println();
System.out.println();
System.out.println("Extraction finished!");
new Alert(AlertType.INFORMATION, "Extraction finished!").showAndWait();
}catch (IOException e) {
e.printStackTrace();
e.printStackTrace(out);
}
}
System.out.println();
System.out.println();
System.out.println("Extraction finished!");
new Alert(AlertType.INFORMATION, "Extraction finished!").showAndWait();
}

}

0 comments on commit af22ad5

Please sign in to comment.