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;
}