source: osm/applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/BoundsLayerSaveAction.java

Last change on this file was 33493, checked in by donvip, 7 years ago

fix SonarQube issues

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.imageryxmlbounds.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.io.File;
9
10import org.openstreetmap.josm.actions.SaveActionBase;
11import org.openstreetmap.josm.gui.layer.Layer;
12import org.openstreetmap.josm.gui.layer.Layer.LayerSaveAction;
13import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsLayer;
14
15/**
16 * Save the current data.
17 * @author Don-vip
18 */
19public class BoundsLayerSaveAction extends LayerSaveAction {
20
21 /**
22 * Save the current data.
23 */
24 public static class SaveBoundsAction extends SaveActionBase {
25
26 /**
27 * Constructs a new {@code SaveBoundsAction}.
28 */
29 public SaveBoundsAction() {
30 super(tr("Save"), "save", tr("Save the current data."), null);
31 putValue("help", ht("/Action/Save"));
32 }
33
34 @Override
35 public File getFile(Layer layer) {
36 File f = layer.getAssociatedFile();
37 if (f != null && !f.exists()) {
38 f = null;
39 }
40 return f == null ? BoundsLayerSaveAsAction.SaveBoundsAsAction.openFileDialog(layer) : f;
41 }
42 }
43
44 protected final XmlBoundsLayer layer;
45
46 /**
47 * Constructs a new {@code BoundsLayerSaveAction}.
48 * @param layer XML bounds layer
49 */
50 public BoundsLayerSaveAction(XmlBoundsLayer layer) {
51 super(layer);
52 this.layer = layer;
53 }
54
55 @Override
56 public void actionPerformed(ActionEvent e) {
57 new SaveBoundsAction().doSave(layer);
58 }
59}
Note: See TracBrowser for help on using the repository browser.