File saveLocation = document.getSaveLocation();
if(askForFilename || saveLocation==null || (saveLocation.isFile() && !saveLocation.canWrite()))
{
// Ask for filename
SaveFileChooser fileChooser = new SaveFileChooser(getPrefs().mainFileType);
fileChooser.setCurrentDirectory(getPrefs().openLocation);
fileChooser.setSelectedFile(new File(document.getRootNode().getTitle() +
(fileType==JreepadPrefs.FILETYPE_XML?".jree":".hjt")));
if(fileChooser.showSaveDialog(JreepadViewer.this) != JFileChooser.APPROVE_OPTION)
{
successful = false;
return; // No file chosen
}
saveLocation = fileChooser.getSelectedFile();
fileType = fileChooser.getFileType();
}
getPrefs().openLocation = saveLocation; // Remember the file's directory
// Save the file
try