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

Last change on this file since 10774 was 10382, checked in by Don-vip, 8 years ago

see #12943 - gsoc-core - fix most of deprecation warnings (static accesses must be fixed)

  • Property svn:eol-style set to native
File size: 2.4 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.Main;
12import org.openstreetmap.josm.data.osm.DataSet;
13import org.openstreetmap.josm.data.osm.OsmPrimitive;
14import org.openstreetmap.josm.io.OnlineResource;
15import org.openstreetmap.josm.tools.Shortcut;
16
17/**
18 * This action synchronizes a set of primitives with their state on the server.
19 * @since 2682
20 */
21public class UpdateModifiedAction extends UpdateSelectionAction {
22
23 /**
24 * Constructs a new {@code UpdateModifiedAction}.
25 */
26 public UpdateModifiedAction() {
27 super(tr("Update modified"), "updatedata",
28 tr("Updates the currently modified objects from the server (re-downloads data)"),
29 Shortcut.registerShortcut("file:updatemodified",
30 tr("File: {0}", tr("Update modified")), KeyEvent.VK_M,
31 Shortcut.ALT_CTRL),
32 true, "updatemodified");
33 putValue("help", ht("/Action/UpdateModified"));
34 }
35
36 // FIXME: overrides the behaviour of UpdateSelectionAction. Doesn't update
37 // the enabled state based on the current selection because it doesn't depend on it.
38 // The action should be enabled/disabled based on whether there is a least
39 // one modified object in the current dataset. Unfortunately, there is no
40 // efficient way to find out here. getDataSet().allModifiedPrimitives() is
41 // too heavy weight because it loops over the whole dataset.
42 // Perhaps this action should be a DataSetListener? Or it could listen to the
43 // REQUIRES_SAVE_TO_DISK_PROP and REQUIRES_UPLOAD_TO_SERVER_PROP properties
44 // in the OsmLayer?
45 //
46 @Override
47 protected void updateEnabledState() {
48 setEnabled(getLayerManager().getEditDataSet() != null && !Main.isOffline(OnlineResource.OSM_API));
49 }
50
51 @Override
52 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
53 // Do nothing
54 }
55
56 @Override
57 public Collection<OsmPrimitive> getData() {
58 DataSet ds = getLayerManager().getEditDataSet();
59 return ds == null ? Collections.<OsmPrimitive>emptyList() : ds.allModifiedPrimitives();
60 }
61}
Note: See TracBrowser for help on using the repository browser.