20 package net.sf.gridarta.gui.map.renderer;
22 import java.awt.Component;
24 import java.io.IOException;
25 import javax.swing.JFileChooser;
26 import javax.swing.JOptionPane;
35 import net.
sf.japi.swing.action.ActionBuilder;
36 import net.
sf.japi.swing.action.ActionBuilderFactory;
37 import org.jetbrains.annotations.NotNull;
49 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
81 final MapFile mapFile = mapModel.getMapFile();
84 fileChooser.setDialogTitle(
"Save Image As");
85 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
86 fileChooser.setMultiSelectionEnabled(
false);
87 fileChooser.setSelectedFile(file);
92 final int returnVal = fileChooser.showSaveDialog(component);
93 if (returnVal == JFileChooser.APPROVE_OPTION) {
95 File imageFile = fileChooser.getSelectedFile();
96 if (!imageFile.getName().endsWith(
".png")) {
97 imageFile =
new File(imageFile.getParentFile(), imageFile.getName() +
".png");
100 if (!imageFile.exists() ||
ACTION_BUILDER.showConfirmDialog(component, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
"overwriteOtherFile", imageFile) == JOptionPane.YES_OPTION) {
103 }
catch (
final IOException ex) {
104 ACTION_BUILDER.showMessageDialog(component,
"createImageIOException", imageFile, ex.getMessage());