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

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

see #15182 - move the Swing-based ProgressMonitor implementations from gui.progress to gui.progress.swing. Progress monitor concept is used in very large parts of JOSM, a console-based implementation could be added later

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
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;
7import java.util.List;
8
9import org.openstreetmap.josm.actions.upload.UploadNotesTask;
10import org.openstreetmap.josm.data.osm.NoteData;
11import org.openstreetmap.josm.gui.layer.NoteLayer;
12import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
13import org.openstreetmap.josm.tools.ImageProvider;
14import org.openstreetmap.josm.tools.Logging;
15
16/**
17 * Action to initiate uploading changed notes to the OSM server.
18 * On click, it finds the note layer and fires off an upload task
19 * with the note data contained in the layer.
20 *
21 */
22public class UploadNotesAction extends JosmAction {
23
24 /** Create a new action to upload notes */
25 public UploadNotesAction() {
26 putValue(SHORT_DESCRIPTION, tr("Upload note changes to server"));
27 putValue(NAME, tr("Upload notes"));
28 new ImageProvider("upload").getResource().attachImageIcon(this, true);
29 }
30
31 @Override
32 public void actionPerformed(ActionEvent e) {
33 List<NoteLayer> noteLayers = getLayerManager().getLayersOfType(NoteLayer.class);
34 NoteLayer layer;
35 if (!noteLayers.isEmpty()) {
36 layer = noteLayers.get(0);
37 } else {
38 Logging.error("No note layer found");
39 return;
40 }
41 Logging.debug("uploading note changes");
42 NoteData noteData = layer.getNoteData();
43
44 if (noteData == null || !noteData.isModified()) {
45 Logging.debug("No changed notes to upload");
46 return;
47 }
48 new UploadNotesTask().uploadNotes(noteData, new PleaseWaitProgressMonitor(tr("Uploading notes to server")));
49 }
50}
Note: See TracBrowser for help on using the repository browser.