source: josm/trunk/src/org/openstreetmap/josm/actions/UploadNotesAction.java@ 15918

Last change on this file since 15918 was 13437, checked in by Don-vip, 7 years ago

fix #15967 - proper loading of notes layers

  • Property svn:eol-style set to native
File size: 1.6 KB
RevLine 
[7699]1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7
8import org.openstreetmap.josm.actions.upload.UploadNotesTask;
9import org.openstreetmap.josm.data.osm.NoteData;
10import org.openstreetmap.josm.gui.layer.NoteLayer;
[12675]11import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
[7699]12import org.openstreetmap.josm.tools.ImageProvider;
[12620]13import org.openstreetmap.josm.tools.Logging;
[7699]14
15/**
16 * Action to initiate uploading changed notes to the OSM server.
17 * On click, it finds the note layer and fires off an upload task
18 * with the note data contained in the layer.
[13437]19 * @since 7699
[7699]20 */
21public class UploadNotesAction extends JosmAction {
22
23 /** Create a new action to upload notes */
[8419]24 public UploadNotesAction() {
[8510]25 putValue(SHORT_DESCRIPTION, tr("Upload note changes to server"));
[7699]26 putValue(NAME, tr("Upload notes"));
[10428]27 new ImageProvider("upload").getResource().attachImageIcon(this, true);
[7699]28 }
29
30 @Override
31 public void actionPerformed(ActionEvent e) {
[13437]32 NoteLayer layer = getLayerManager().getNoteLayer();
33 if (layer == null) {
[12620]34 Logging.error("No note layer found");
[7699]35 return;
36 }
[12620]37 Logging.debug("uploading note changes");
[7699]38 NoteData noteData = layer.getNoteData();
39
[8510]40 if (noteData == null || !noteData.isModified()) {
[12620]41 Logging.debug("No changed notes to upload");
[7699]42 return;
43 }
[8474]44 new UploadNotesTask().uploadNotes(noteData, new PleaseWaitProgressMonitor(tr("Uploading notes to server")));
[7699]45 }
46}
Note: See TracBrowser for help on using the repository browser.