source: josm/trunk/src/org/openstreetmap/josm/actions/SaveAction.java@ 2683

Last change on this file since 2683 was 2323, checked in by Gubaer, 14 years ago

Added explicit help topics
See also current list of help topics with links to source files and to help pages

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
6
7import java.awt.event.KeyEvent;
8import java.io.File;
9
10import org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.gui.ExtendedDialog;
12import org.openstreetmap.josm.gui.layer.GpxLayer;
13import org.openstreetmap.josm.gui.layer.Layer;
14import org.openstreetmap.josm.tools.Shortcut;
15
16/**
17 * Export the data as an OSM xml file.
18 *
19 * @author imi
20 */
21public class SaveAction extends SaveActionBase {
22
23 /**
24 * Construct the action with "Save" as label.
25 * @param layer Save this layer.
26 */
27 public SaveAction() {
28 super(tr("Save"), "save", tr("Save the current data."),
29 Shortcut.registerShortcut("system:save", tr("File: {0}", tr("Save")), KeyEvent.VK_S, Shortcut.GROUP_MENU));
30 putValue("help", ht("/Action/Save"));
31 }
32
33 @Override public File getFile(Layer layer) {
34 File f = layer.getAssociatedFile();
35 if(f != null && ! f.exists()) {
36 f=null;
37 }
38
39 // FIXME: why only for GpxLayer?
40 if(f != null && layer instanceof GpxLayer) {
41 ExtendedDialog dialog = new ExtendedDialog(
42 Main.parent,
43 tr("Overwrite"),
44 new String[] {tr("Overwrite"), tr("Cancel")}
45 );
46 dialog.setButtonIcons(new String[] {"save_as.png", "cancel.png"});
47 dialog.setContent(tr("File {0} exists. Overwrite?", f.getName()));
48 dialog.showDialog();
49 int ret = dialog.getValue();
50 if (ret != 1) {
51 f = null;
52 }
53 }
54 return f == null ? openFileDialog(layer) : f;
55 }
56}
Note: See TracBrowser for help on using the repository browser.