Skip to content

Commit

Permalink
Allow opening Mapillary layer without OSM data layer
Browse files Browse the repository at this point in the history
  • Loading branch information
floscher committed May 1, 2017
1 parent ccbffc3 commit 81056da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
28 changes: 15 additions & 13 deletions src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
Expand Down Expand Up @@ -115,10 +116,10 @@ private MapillaryLayer() {
* Initializes the Layer.
*/
private void init() {
if (Main.main != null && Main.isDisplayingMapView()) {
setMode(new SelectMode());
if (!GraphicsEnvironment.isHeadless()) {
Main.getLayerManager().addLayer(this);
Main.getLayerManager().addActiveLayerChangeListener(this);
setMode(new SelectMode());
if (Main.getLayerManager().getEditLayer() != null) {
Main.getLayerManager().getEditLayer().data.addDataSetListener(DATASET_LISTENER);
}
Expand All @@ -133,21 +134,21 @@ private void init() {
if (MapillaryPlugin.getExportMenu() != null) {
MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getExportMenu(), true);
if (!MapillaryMainDialog.getInstance().isShowing()) {
MapillaryMainDialog.getInstance().getButton().doClick();
MapillaryMainDialog.getInstance().showDialog();
}
}
createHatchTexture();
if (Main.main != null) {
if (MapillaryPlugin.getMapView() != null) {
MapillaryMainDialog.getInstance().mapillaryImageDisplay.repaint();
MapillaryMainDialog.getInstance()
.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
.put(KeyStroke.getKeyStroke("DELETE"), "MapillaryDel");
MapillaryMainDialog.getInstance().getActionMap()
.put("MapillaryDel", new DeleteImageAction());

MapillaryData.dataUpdated();
getLocationChangeset().addChangesetListener(MapillaryChangesetDialog.getInstance());
}
createHatchTexture();
MapillaryData.dataUpdated();
}

/**
Expand All @@ -156,16 +157,17 @@ private void init() {
* @param mode The mode that is going to be activated.
*/
public void setMode(AbstractMode mode) {
if (this.mode != null) {
Main.map.mapView.removeMouseListener(this.mode);
Main.map.mapView.removeMouseMotionListener(this.mode);
final MapView mv = MapillaryPlugin.getMapView();
if (this.mode != null && mv != null) {
mv.removeMouseListener(this.mode);
mv.removeMouseMotionListener(this.mode);
NavigatableComponent.removeZoomChangeListener(this.mode);
}
this.mode = mode;
if (mode != null) {
Main.map.mapView.setNewCursor(mode.cursor, this);
Main.map.mapView.addMouseListener(mode);
Main.map.mapView.addMouseMotionListener(mode);
if (mode != null && mv != null) {
mv.setNewCursor(mode.cursor, this);
mv.addMouseListener(mode);
mv.addMouseMotionListener(mode);
NavigatableComponent.addZoomChangeListener(mode);
MapillaryUtils.updateHelpText();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public class MapillaryPlugin extends Plugin {
/** Upload action */
private static final MapillaryUploadAction UPLOAD_ACTION = new MapillaryUploadAction();

/** Menu button for the {@link MapillaryDownloadAction} action. */
private static final JMenuItem DOWNLOAD_MENU;
/** Menu button for the {@link MapillaryExportAction} action. */
private static final JMenuItem EXPORT_MENU;
/** Menu button for the {@link MapillaryImportAction} action. */
Expand All @@ -87,7 +85,6 @@ public class MapillaryPlugin extends Plugin {
static {
if (Main.main == null) {
EXPORT_MENU = null;
DOWNLOAD_MENU = null;
IMPORT_MENU = null;
ZOOM_MENU = null;
DOWNLOAD_VIEW_MENU = null;
Expand All @@ -98,8 +95,7 @@ public class MapillaryPlugin extends Plugin {
} else {
EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, EXPORT_ACTION, false, 14);
EXPORT_MENU.setEnabled(false);
DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imagerySubMenu, DOWNLOAD_ACTION, false);
DOWNLOAD_MENU.setEnabled(false);
MainMenu.add(Main.main.menu.imagerySubMenu, DOWNLOAD_ACTION, false);
IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, IMPORT_ACTION, false, 14);
IMPORT_MENU.setEnabled(false);
ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, ZOOM_ACTION, false, 15);
Expand Down Expand Up @@ -218,7 +214,6 @@ public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
Main.map.addToggleDialog(MapillaryHistoryDialog.getInstance(), false);
Main.map.addToggleDialog(MapillaryChangesetDialog.getInstance(), false);
Main.map.addToggleDialog(MapillaryFilterDialog.getInstance(), false);
setMenuEnabled(DOWNLOAD_MENU, true);
if (MapillaryDownloader.getMode() == DOWNLOAD_MODE.MANUAL_ONLY) {
setMenuEnabled(DOWNLOAD_VIEW_MENU, true);
}
Expand All @@ -231,7 +226,6 @@ public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
MapillaryChangesetDialog.destroyInstance();
MapillaryFilterDialog.destroyInstance();
ImageInfoPanel.destroyInstance();
setMenuEnabled(DOWNLOAD_MENU, false);
setMenuEnabled(DOWNLOAD_VIEW_MENU, false);
setMenuEnabled(IMPORT_MENU, false);
setMenuEnabled(IMPORT_INTO_SEQUENCE_MENU, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public MapillaryDownloadAction() {
"mapillaryDownload",
false
);
this.setEnabled(false);
}

@Override
Expand Down

0 comments on commit 81056da

Please sign in to comment.