1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.changeset;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.Component;
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 |
|
---|
9 | import javax.swing.AbstractAction;
|
---|
10 |
|
---|
11 | import org.openstreetmap.josm.actions.downloadtasks.ChangesetContentDownloadTask;
|
---|
12 | import org.openstreetmap.josm.tools.CheckParameterUtil;
|
---|
13 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Downloads/Updates the content of the changeset.
|
---|
17 | * @since 9493
|
---|
18 | */
|
---|
19 | public 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 | }
|
---|