source: josm/trunk/src/org/openstreetmap/josm/actions/UpdateModifiedAction.java@ 7402

Last change on this file since 7402 was 6814, checked in by Don-vip, 10 years ago

fix #8234 - remove duplicated/unused icons + javadoc

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.KeyEvent;
8import java.util.Collection;
9import java.util.Collections;
10
11import org.openstreetmap.josm.data.osm.OsmPrimitive;
12import org.openstreetmap.josm.tools.Shortcut;
13
14/**
15 * This action synchronizes a set of primitives with their state on the server.
16 * @since 2682
17 */
18public class UpdateModifiedAction extends UpdateSelectionAction {
19
20 /**
21 * Constructs a new {@code UpdateModifiedAction}.
22 */
23 public UpdateModifiedAction() {
24 super(tr("Update modified"), "updatedata",
25 tr("Updates the currently modified objects from the server (re-downloads data)"),
26 Shortcut.registerShortcut("file:updatemodified",
27 tr("File: {0}", tr("Update modified")), KeyEvent.VK_M,
28 Shortcut.ALT_CTRL),
29 true, "updatemodified");
30 putValue("help", ht("/Action/UpdateModified"));
31 }
32
33 // FIXME: overrides the behaviour of UpdateSelectionAction. Doesn't update
34 // the enabled state based on the current selection because
35 // it doesn't depend on it.
36 // The action should be enabled/disabled based on whether there is a least
37 // one modified object in the current dataset. Unfortunately, there is no
38 // efficient way to find out here. getDataSet().allModifiedPrimitives() is
39 // too heavy weight because it loops over the whole dataset.
40 // Perhaps this action should be a DataSetListener? Or it could listen to the
41 // REQUIRES_SAVE_TO_DISK_PROP and REQUIRES_UPLOAD_TO_SERVER_PROP properties
42 // in the OsmLayer?
43 //
44 @Override
45 protected void updateEnabledState() {
46 setEnabled(getCurrentDataSet() != null);
47 }
48
49 @Override
50 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
51 }
52
53 @Override
54 public Collection<OsmPrimitive> getData() {
55 if (getCurrentDataSet() == null) return Collections.emptyList();
56 return getCurrentDataSet().allModifiedPrimitives();
57 }
58}
Note: See TracBrowser for help on using the repository browser.