source: subversion/applications/editors/josm/plugins/MicrosoftStreetside/src/org/openstreetmap/josm/plugins/streetside/actions/StreetsideDownloadViewAction.java

Last change on this file was 34349, checked in by renerr18, 10 months ago

Repaired image display after JOSM changes once more

File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.streetside.actions;
3
4import java.awt.event.ActionEvent;
5import java.awt.event.KeyEvent;
6
7import org.openstreetmap.josm.actions.JosmAction;
8import org.openstreetmap.josm.data.preferences.AbstractProperty.ValueChangeEvent;
9import org.openstreetmap.josm.data.preferences.AbstractProperty.ValueChangeListener;
10import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
11import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
12import org.openstreetmap.josm.plugins.streetside.io.download.StreetsideDownloader;
13import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
14import org.openstreetmap.josm.tools.I18n;
15import org.openstreetmap.josm.tools.ImageProvider;
16import org.openstreetmap.josm.tools.ImageProvider.ImageSizes;
17import org.openstreetmap.josm.tools.Shortcut;
18
19/**
20 * If in "download images in visible area" mode, downloads all the images in the current view.
21 *
22 * @author nokutu
23 *
24 */
25public class StreetsideDownloadViewAction extends JosmAction implements ValueChangeListener<String> {
26
27  private static final long serialVersionUID = 6738276777802831669L;
28
29  private static final String DESCRIPTION = I18n.marktr("Download Streetside images in current view");
30
31  /**
32   * Main constructor.
33   */
34  public StreetsideDownloadViewAction() {
35    super(
36      I18n.tr(DESCRIPTION),
37      new ImageProvider(StreetsidePlugin.LOGO).setSize(ImageSizes.DEFAULT),
38      I18n.tr(DESCRIPTION),
39      Shortcut.registerShortcut("Streetside area", I18n.tr(DESCRIPTION), KeyEvent.VK_PERIOD, Shortcut.SHIFT),
40      false,
41      "streetsideArea",
42      true
43    );
44    StreetsideProperties.DOWNLOAD_MODE.addListener(this);
45    initEnabledState();
46  }
47
48  @Override
49  public void actionPerformed(ActionEvent arg0) {
50    StreetsideDownloader.downloadVisibleArea();
51  }
52
53  @Override
54  protected boolean listenToSelectionChange() {
55    return false;
56  }
57
58  /**
59   * Enabled when the Streetside layer is instantiated and download mode is either "osm area" or "manual".
60   */
61  @Override
62  protected void updateEnabledState() {
63    super.updateEnabledState();
64    setEnabled(
65      StreetsideLayer.hasInstance() && (
66        StreetsideDownloader.getMode() == StreetsideDownloader.DOWNLOAD_MODE.OSM_AREA
67        || StreetsideDownloader.getMode() == StreetsideDownloader.DOWNLOAD_MODE.MANUAL_ONLY
68      )
69    );
70  }
71
72  @Override
73  public void valueChanged(ValueChangeEvent<? extends String> e) {
74    updateEnabledState();
75  }
76}
Note: See TracBrowser for help on using the repository browser.