diff --git a/core/src/net/sf/openrocket/document/OpenRocketDocument.java b/core/src/net/sf/openrocket/document/OpenRocketDocument.java index b531cc2c3..b62c7938b 100644 --- a/core/src/net/sf/openrocket/document/OpenRocketDocument.java +++ b/core/src/net/sf/openrocket/document/OpenRocketDocument.java @@ -34,7 +34,7 @@ import net.sf.openrocket.util.ArrayList; */ public class OpenRocketDocument implements ComponentChangeListener { private static final Logger log = LoggerFactory.getLogger(OpenRocketDocument.class); - + private final List file_extensions = Arrays.asList("ork", "ork.gz", "rkt", "rkt.gz"); // Possible extensions of an OpenRocket document /** * The minimum number of undo levels that are stored. */ @@ -193,6 +193,23 @@ public class OpenRocketDocument implements ComponentChangeListener { public File getFile() { return file; } + + /** + * returns the File handler object for the document without the file extension (e.g. '.ork' removed) + * @return the File handler object for the document without the file extension + */ + public File getFileNoExtension() { + if (file == null) return null; + int index = file.getAbsolutePath().lastIndexOf('.'); + if (index > 0) { + String filename = file.getAbsolutePath().substring(0, index); + String extension = file.getAbsolutePath().substring(index + 1); + if (file_extensions.contains(extension)) { + return new File(filename); + } + } + return file; + } /** * set the file handler object for the document diff --git a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java index a5a6f27b9..305e5ce29 100644 --- a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -1413,9 +1413,6 @@ public class BasicFrame extends JFrame { return false; } } - if (!FileHelper.confirmWrite(file, this)) { - return false; - } try { StorageOptions options = new StorageOptions(); diff --git a/swing/src/net/sf/openrocket/gui/main/SaveAsFileChooser.java b/swing/src/net/sf/openrocket/gui/main/SaveAsFileChooser.java index 36d84aa5d..844178f80 100644 --- a/swing/src/net/sf/openrocket/gui/main/SaveAsFileChooser.java +++ b/swing/src/net/sf/openrocket/gui/main/SaveAsFileChooser.java @@ -3,6 +3,9 @@ package net.sf.openrocket.gui.main; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import javax.swing.JFileChooser; @@ -31,9 +34,9 @@ public class SaveAsFileChooser extends JFileChooser { this.document = document; this.type = type; - this.setAcceptAllFileFilterUsed(true); + this.setAcceptAllFileFilterUsed(false); - File defaultFilename = document.getFile(); + File defaultFilename = document.getFileNoExtension(); switch( type ) { default: