{
// Start at the location of the most recently loaded map file
String startLocation =
TiledConfiguration.node("recent").get("file0", null);
TiledFileFilter byExtensionFilter =
new TiledFileFilter(TiledFileFilter.FILTER_EXT);
TiledFileFilter tmxFilter =
new TiledFileFilter(TiledFileFilter.FILTER_TMX);
JFileChooser chooser = new ConfirmingFileChooser(startLocation);
chooser.setAcceptAllFileFilterUsed(false);
chooser.addChoosableFileFilter(byExtensionFilter);
chooser.addChoosableFileFilter(tmxFilter);
MapWriter[] writers = editor.getPluginLoader().getWriters();
for (int i = 0; i < writers.length; i++) {
try {
chooser.addChoosableFileFilter(new TiledFileFilter(writers[i]));
} catch (Exception e) {
e.printStackTrace();
}
}
chooser.setFileFilter(byExtensionFilter);
int result = chooser.showSaveDialog(editor.getAppFrame());
if (result == JFileChooser.APPROVE_OPTION)
{
savingCancelled = false;
TiledFileFilter saver = (TiledFileFilter) chooser.getFileFilter();
String selectedFile = chooser.getSelectedFile().getAbsolutePath();
saveFile(saver, selectedFile);
}
else {
savingCancelled = true;