int sel = tblStyles.getSelectionModel().getLeadSelectionIndex();
if (sel < 0 || sel >= model.getRowCount())
return;
final StyleSource s = model.getRow(sel);
JFileChooserManager fcm = new JFileChooserManager(false, "mappaint.clone-style.lastDirectory", System.getProperty("user.home"));
String suggestion = fcm.getInitialDirectory() + File.separator + s.getFileNamePart();
FileFilter ff;
if (s instanceof MapCSSStyleSource) {
ff = new ExtensionFileFilter("mapcss,css,zip", "mapcss", tr("Map paint style file (*.mapcss, *.zip)"));
} else {
ff = new ExtensionFileFilter("xml,zip", "xml", tr("Map paint style file (*.xml, *.zip)"));
}
fcm.createFileChooser(false, null, Arrays.asList(ff, FileFilterAllFiles.getInstance()), ff, JFileChooser.FILES_ONLY)
.getFileChooser().setSelectedFile(new File(suggestion));
JFileChooser fc = fcm.openFileChooser();
if (fc == null)
return;
Main.worker.submit(new SaveToFileTask(s, fc.getSelectedFile()));
}