Commit 28c0fe3a authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

fix #225. Keep dialog open after csv export.

parent 1a26f9ef
Pipeline #100634 passed with stages
in 135 minutes and 32 seconds
......@@ -10,7 +10,6 @@ import org.vadere.util.logging.Logger;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
......@@ -27,7 +26,7 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
private final ProjectView projectView;
private final ProjectViewModel projectViewModel;
public ProjectRunResultDialog(ProjectView projectView, ProjectViewModel projectViewModel) {
ProjectRunResultDialog(ProjectView projectView, ProjectViewModel projectViewModel) {
this.projectView = projectView;
this.projectViewModel = projectViewModel;
}
......@@ -46,8 +45,8 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
String[] headers = res.getHeaders();
String[] values = res.getAsTableRow();
for(int i = 0; i < headers.length; i++) {
sb.append(" " + headers[i] + ": ").append(values[i]).append("\n");
for (int i = 0; i < headers.length; i++) {
sb.append(" ").append(headers[i]).append(": ").append(values[i]).append("\n");
}
}
......@@ -73,7 +72,7 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
LinkedList<SimulationResult> data;
public ResultDialog(ProjectView projectView, LinkedList<SimulationResult> data) {
ResultDialog(ProjectView projectView, LinkedList<SimulationResult> data) {
super(projectView);
this.data = data;
main = new JPanel();
......@@ -96,7 +95,6 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
btnPane.add(Box.createRigidArea(new Dimension(10, 0)));
btnPane.add(btnCsv);
Container c = getContentPane();
c.add(main, BorderLayout.CENTER);
c.add(btnPane, BorderLayout.PAGE_END);
......@@ -107,7 +105,7 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
}
public Object[][] getData(LinkedList<SimulationResult> data) {
Object[][] getData(LinkedList<SimulationResult> data) {
Object[][] res = new Object[data.size()][5];
int rowIdx = 0;
for (SimulationResult d : data) {
......@@ -126,25 +124,19 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
SimulationResult.addCsvHeader(data.getFirst(), sj, ';');
data.forEach(simulationResult -> simulationResult.addCsvRow(sj, ';'));
FileDialog fd = new FileDialog(this, Messages.getString("ProjectView.chooseFile"), FileDialog.SAVE);
fd.setVisible(true);
Path p = (Paths.get(fd.getDirectory()).resolve(fd.getFile()));
fd.setVisible(false);
try (OutputStreamWriter writer =
new OutputStreamWriter(new FileOutputStream(p.toString(), false), StandardCharsets.UTF_8)) {
writer.write(sj.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
setVisible(false);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment