source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/DownloadChangesetContentAction.java@ 11326

Last change on this file since 11326 was 10438, checked in by stoecker, 8 years ago

see #12994 - Old style SideButton

File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.changeset;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.Component;
7import java.awt.event.ActionEvent;
8
9import javax.swing.AbstractAction;
10
11import org.openstreetmap.josm.actions.downloadtasks.ChangesetContentDownloadTask;
12import org.openstreetmap.josm.tools.CheckParameterUtil;
13import org.openstreetmap.josm.tools.ImageProvider;
14
15/**
16 * Downloads/Updates the content of the changeset.
17 * @since 9493
18 */
19public class DownloadChangesetContentAction extends AbstractAction {
20 private final transient ChangesetAware component;
21
22 /**
23 * Constructs a new {@code DownloadChangesetContentAction}.
24 * @param component changeset-aware component
25 */
26 public DownloadChangesetContentAction(ChangesetAware component) {
27 CheckParameterUtil.ensureParameterNotNull(component, "component");
28 putValue(NAME, tr("Download content"));
29 new ImageProvider("dialogs/changeset", "downloadchangesetcontent").getResource().attachImageIcon(this);
30 putValue(SHORT_DESCRIPTION, tr("Download the changeset content from the OSM server"));
31 this.component = component;
32 }
33
34 @Override
35 public void actionPerformed(ActionEvent evt) {
36 if (component.getCurrentChangeset() != null) {
37 ChangesetCacheManager.getInstance().runDownloadTask(new ChangesetContentDownloadTask(
38 (Component) component, component.getCurrentChangeset().getId()));
39 }
40 }
41
42 /**
43 * Init properties.
44 */
45 public void initProperties() {
46 if (component.getCurrentChangeset() == null) {
47 setEnabled(false);
48 return;
49 } else {
50 setEnabled(true);
51 }
52 if (component.getCurrentChangeset().getContent() == null) {
53 putValue(NAME, tr("Download content"));
54 new ImageProvider("dialogs/changeset", "downloadchangesetcontent").getResource().attachImageIcon(this);
55 putValue(SHORT_DESCRIPTION, tr("Download the changeset content from the OSM server"));
56 } else {
57 putValue(NAME, tr("Update content"));
58 new ImageProvider("dialogs/changeset", "updatechangesetcontent").getResource().attachImageIcon(this);
59 putValue(SHORT_DESCRIPTION, tr("Update the changeset content from the OSM server"));
60 }
61 }
62}
Note: See TracBrowser for help on using the repository browser.