1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.KeyEvent;
|
---|
7 | import java.io.File;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.gui.ExtendedDialog;
|
---|
11 | import org.openstreetmap.josm.gui.layer.GpxLayer;
|
---|
12 | import org.openstreetmap.josm.gui.layer.Layer;
|
---|
13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Export the data as an OSM xml file.
|
---|
17 | *
|
---|
18 | * @author imi
|
---|
19 | */
|
---|
20 | public class SaveAction extends SaveActionBase {
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Construct the action with "Save" as label.
|
---|
24 | * @param layer Save this layer.
|
---|
25 | */
|
---|
26 | public SaveAction() {
|
---|
27 | super(tr("Save"), "save", tr("Save the current data."),
|
---|
28 | Shortcut.registerShortcut("system:save", tr("File: {0}", tr("Save")), KeyEvent.VK_S, Shortcut.GROUP_MENU));
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override public File getFile(Layer layer) {
|
---|
32 | File f = layer.getAssociatedFile();
|
---|
33 | if(f != null && ! f.exists()) {
|
---|
34 | f=null;
|
---|
35 | }
|
---|
36 | if(f != null && layer instanceof GpxLayer && 1 !=
|
---|
37 | new ExtendedDialog(Main.parent, tr("Overwrite"),
|
---|
38 | tr("File {0} exists. Overwrite?", f.getName()),
|
---|
39 | new String[] {tr("Overwrite"), tr("Cancel")},
|
---|
40 | new String[] {"save_as.png", "cancel.png"}).getValue()) {
|
---|
41 | f = null;
|
---|
42 | }
|
---|
43 | return f == null ? openFileDialog(layer) : f;
|
---|
44 | }
|
---|
45 | }
|
---|