Merge pull request #1013 from SiboVG/issue-899
[fixes #899] Use only filename in save/export filename input
This commit is contained in:
commit
a194fa033f
@ -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<String> 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.
|
||||
*/
|
||||
@ -194,6 +194,23 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
||||
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
|
||||
* @param file the new file handler object
|
||||
|
@ -1413,9 +1413,6 @@ public class BasicFrame extends JFrame {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!FileHelper.confirmWrite(file, this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
StorageOptions options = new StorageOptions();
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user