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

Last change on this file since 11710 was 10428, checked in by stoecker, 8 years ago

see #9995 - patch mainly by strump - improve HIDPI behaviour

  • Property svn:eol-style set to native
File size: 1.7 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;
7import java.util.List;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.actions.upload.UploadNotesTask;
11import org.openstreetmap.josm.data.osm.NoteData;
12import org.openstreetmap.josm.gui.layer.NoteLayer;
13import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
14import org.openstreetmap.josm.tools.ImageProvider;
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 */
[8419]25 public UploadNotesAction() {
[8510]26 putValue(SHORT_DESCRIPTION, tr("Upload note changes to server"));
[7699]27 putValue(NAME, tr("Upload notes"));
[10428]28 new ImageProvider("upload").getResource().attachImageIcon(this, true);
[7699]29 }
30
31 @Override
32 public void actionPerformed(ActionEvent e) {
[10318]33 List<NoteLayer> noteLayers = Main.getLayerManager().getLayersOfType(NoteLayer.class);
[7699]34 NoteLayer layer;
[10318]35 if (!noteLayers.isEmpty()) {
[7699]36 layer = noteLayers.get(0);
37 } else {
38 Main.error("No note layer found");
39 return;
40 }
[10318]41 Main.debug("uploading note changes");
[7699]42 NoteData noteData = layer.getNoteData();
43
[8510]44 if (noteData == null || !noteData.isModified()) {
[10318]45 Main.debug("No changed notes to upload");
[7699]46 return;
47 }
[8474]48 new UploadNotesTask().uploadNotes(noteData, new PleaseWaitProgressMonitor(tr("Uploading notes to server")));
[7699]49 }
50}
Note: See TracBrowser for help on using the repository browser.