From 05561b2872e203e86839cc2f532c976321fdfb32 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 14 Mar 2023 00:20:00 +0100 Subject: [PATCH] Confirm file overwrite --- swing/src/net/sf/openrocket/gui/main/SimulationPanel.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java index 5cc7ca8ce..39fddc02a 100644 --- a/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/SimulationPanel.java @@ -648,13 +648,18 @@ public class SimulationPanel extends JPanel { JFileChooser fch = this.setUpFileChooser(); int selectionStatus = fch.showSaveDialog(tableParent); if (selectionStatus != JFileChooser.APPROVE_OPTION) { - log.info("User cancelled CSV export"); + log.debug("User cancelled CSV export"); return; } // Fetch the info from the file chooser File CSVFile = fch.getSelectedFile(); CSVFile = FileHelper.forceExtension(CSVFile, "csv"); + if (!FileHelper.confirmWrite(CSVFile, SimulationPanel.this)) { + log.debug("User cancelled CSV export overwrite"); + return; + } + String separator = ((CsvOptionPanel) fch.getAccessory()).getFieldSeparator(); int precision = ((CsvOptionPanel) fch.getAccessory()).getDecimalPlaces(); ((CsvOptionPanel) fch.getAccessory()).storePreferences(); @@ -688,7 +693,6 @@ public class SimulationPanel extends JPanel { // Add CSV options to FileChooser CsvOptionPanel CSVOptions = new CsvOptionPanel(SimulationTableCSVExport.class); fch.setAccessory(CSVOptions); - fch.revalidate(); // TODO: update this dynamically instead of hard-coded values // The macOS file chooser has an issue where it does not update its size when the accessory is added.