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

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

Removed poSrc files and most "dead code"/commented out obsolete Mapillary code.

File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.streetside.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.awt.event.KeyEvent;
8
9import org.apache.log4j.Logger;
10import org.openstreetmap.josm.actions.JosmAction;
11import org.openstreetmap.josm.gui.MainApplication;
12import org.openstreetmap.josm.gui.layer.OsmDataLayer;
13import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
14import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
15import org.openstreetmap.josm.tools.ImageProvider;
16import org.openstreetmap.josm.tools.ImageProvider.ImageSizes;
17import org.openstreetmap.josm.tools.Shortcut;
18
19/**
20 * Action that triggers the plugin. If in automatic mode, it will automatically
21 * download the images in the areas where there is OSM data.
22 *
23 * @author nokutu
24 *
25 */
26public class StreetsideDownloadAction extends JosmAction {
27
28  private static final long serialVersionUID = 4426446157849005029L;
29
30  public static final Shortcut SHORTCUT = Shortcut.registerShortcut("Streetside", "Open Streetside layer", KeyEvent.VK_COMMA, Shortcut.SHIFT);
31
32  final static Logger logger = Logger.getLogger(StreetsideDownloadAction.class);
33
34  /**
35   * Main constructor.
36   */
37  public StreetsideDownloadAction() {
38    super(
39        tr("Streetside"),
40        new ImageProvider(StreetsidePlugin.LOGO).setSize(ImageSizes.DEFAULT),
41        tr("Open Streetside layer"),
42        SHORTCUT,
43        false,
44        "streetsideDownload",
45        false
46    );
47  }
48
49  @Override
50  public void actionPerformed(ActionEvent ae) {
51    if (!StreetsideLayer.hasInstance() || !MainApplication.getLayerManager().containsLayer(StreetsideLayer.getInstance())) {
52      MainApplication.getLayerManager().addLayer(StreetsideLayer.getInstance());
53      return;
54    }
55
56    try {
57      // Successive calls to this action toggle the active layer between the OSM data layer and the streetside layer
58      OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
59      if (MainApplication.getLayerManager().getActiveLayer() != StreetsideLayer.getInstance()) {
60        MainApplication.getLayerManager().setActiveLayer(StreetsideLayer.getInstance());
61      } else if (editLayer != null) {
62        MainApplication.getLayerManager().setActiveLayer(editLayer);
63      }
64    } catch (IllegalArgumentException e) {
65      // If the StreetsideLayer is not managed by LayerManager but you try to set it as active layer
66      logger.warn(e);
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.