Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/AbstractOsmAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/AbstractOsmAction.java	(revision 33026)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/AbstractOsmAction.java	(revision 33026)
@@ -0,0 +1,165 @@
+// License: GPL. For details, see LICENSE file.
+package CommandLine;
+
+import java.awt.AWTEvent;
+import java.awt.Cursor;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.event.AWTEventListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.mapmode.MapMode;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.tools.ImageProvider;
+
+public abstract class AbstractOsmAction<T extends OsmPrimitive> extends MapMode implements AWTEventListener {
+    private final CommandLine parentPlugin;
+    private final Cursor cursorNormal;
+    private final Cursor cursorActive;
+    private Cursor currentCursor;
+    private Point mousePos;
+    private T nearestPrimitive;
+    private boolean isCtrlDown;
+
+    protected AbstractOsmAction(MapFrame mapFrame, CommandLine parentPlugin, String activeCursorIcon) {
+        super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection"));
+        this.parentPlugin = parentPlugin;
+        cursorNormal = ImageProvider.getCursor("normal", "selection");
+        cursorActive = ImageProvider.getCursor("normal", activeCursorIcon);
+        currentCursor = cursorNormal;
+        nearestPrimitive = null;
+    }
+
+    @Override public void enterMode() {
+        super.enterMode();
+        currentCursor = cursorNormal;
+        Main.map.mapView.addMouseListener(this);
+        Main.map.mapView.addMouseMotionListener(this);
+        try {
+            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
+        } catch (SecurityException ex) {
+            Main.warn(ex);
+        }
+    }
+
+    @Override public void exitMode() {
+        super.exitMode();
+        Main.map.mapView.removeMouseListener(this);
+        Main.map.mapView.removeMouseMotionListener(this);
+        try {
+            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
+        } catch (SecurityException ex) {
+            Main.warn(ex);
+        }
+    }
+
+    @Override
+    public void mouseMoved(MouseEvent e) {
+        if (!Main.map.mapView.isActiveLayerDrawable())
+            return;
+        processMouseEvent(e);
+        updCursor();
+        Main.map.mapView.repaint();
+        super.mouseMoved(e);
+    }
+
+    @Override
+    public void mousePressed(MouseEvent e) {
+        if (!Main.map.mapView.isActiveLayerDrawable())
+            return;
+        processMouseEvent(e);
+        if (nearestPrimitive != null) {
+            DataSet ds = Main.getLayerManager().getEditDataSet();
+            if (isCtrlDown) {
+                ds.clearSelection(nearestPrimitive);
+                Main.map.mapView.repaint();
+            } else {
+                int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
+                switch (maxInstances) {
+                case 0:
+                    ds.addSelected(nearestPrimitive);
+                    Main.map.mapView.repaint();
+                    break;
+                case 1:
+                    ds.addSelected(nearestPrimitive);
+                    Main.map.mapView.repaint();
+                    parentPlugin.loadParameter(nearestPrimitive, true);
+                    exitMode();
+                    break;
+                default:
+                    if (ds.getSelected().size() < maxInstances) {
+                        ds.addSelected(nearestPrimitive);
+                        Main.map.mapView.repaint();
+                    } else
+                        parentPlugin.printHistory("Maximum instances is " + maxInstances);
+                }
+            }
+        }
+        super.mousePressed(e);
+    }
+
+    @Override
+    public void eventDispatched(AWTEvent arg0) {
+        if (!(arg0 instanceof KeyEvent))
+            return;
+        KeyEvent ev = (KeyEvent) arg0;
+        isCtrlDown = (ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0;
+        if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) {
+            ev.consume();
+            cancelDrawing();
+        }
+    }
+
+    private void updCursor() {
+        if (mousePos != null) {
+            if (!Main.isDisplayingMapView())
+                return;
+            nearestPrimitive = getNearest(mousePos);
+            if (nearestPrimitive != null) {
+                setCursor(cursorActive);
+            } else {
+                setCursor(cursorNormal);
+            }
+        }
+    }
+
+    protected abstract T getNearest(Point mousePos);
+
+    private void processMouseEvent(MouseEvent e) {
+        if (e != null) {
+            mousePos = e.getPoint();
+        }
+    }
+
+    private void setCursor(final Cursor c) {
+        if (currentCursor.equals(c))
+            return;
+        try {
+            // We invoke this to prevent strange things from happening
+            EventQueue.invokeLater(() -> {
+                // Don't change cursor when mode has changed already
+                if (!AbstractOsmAction.this.getClass().isAssignableFrom(Main.map.mapMode.getClass()))
+                    return;
+                Main.map.mapView.setCursor(c);
+            });
+            currentCursor = c;
+        } catch (Exception e) {
+            Main.warn(e);
+        }
+    }
+
+    public void cancelDrawing() {
+        if (Main.map == null || Main.map.mapView == null)
+            return;
+        Main.map.statusLine.setHeading(-1);
+        Main.map.statusLine.setAngle(-1);
+        Main.map.mapView.repaint();
+        updateStatusLine();
+        parentPlugin.abortInput();
+    }
+}
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java	(revision 33025)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/AnyAction.java	(revision 33026)
@@ -2,164 +2,19 @@
 package CommandLine;
 
-import java.awt.AWTEvent;
-import java.awt.Cursor;
-import java.awt.EventQueue;
 import java.awt.Point;
-import java.awt.Toolkit;
-import java.awt.event.AWTEventListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.mapmode.MapMode;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.MapFrame;
-import org.openstreetmap.josm.tools.ImageProvider;
 
-public class AnyAction extends MapMode implements AWTEventListener {
-    private final CommandLine parentPlugin;
-    private final Cursor cursorNormal, cursorActive;
-    private Cursor currentCursor;
-    private Point mousePos;
-    private OsmPrimitive nearestPrimitive;
-    private boolean isCtrlDown;
+public class AnyAction extends AbstractOsmAction<OsmPrimitive> {
 
     public AnyAction(MapFrame mapFrame, CommandLine parentPlugin) {
-        super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection"));
-        this.parentPlugin = parentPlugin;
-        cursorNormal = ImageProvider.getCursor("normal", "selection");
-        cursorActive = ImageProvider.getCursor("normal", "joinnode");
-        currentCursor = cursorNormal;
-        nearestPrimitive = null;
-    }
-
-    @Override public void enterMode() {
-        super.enterMode();
-        currentCursor = cursorNormal;
-        Main.map.mapView.addMouseListener(this);
-        Main.map.mapView.addMouseMotionListener(this);
-        try {
-            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
-        } catch (SecurityException ex) {
-            Main.warn(ex);
-        }
-    }
-
-    @Override public void exitMode() {
-        super.exitMode();
-        Main.map.mapView.removeMouseListener(this);
-        Main.map.mapView.removeMouseMotionListener(this);
-        try {
-            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
-        } catch (SecurityException ex) {
-            Main.warn(ex);
-        }
+        super(mapFrame, parentPlugin, "joinnode");
     }
 
     @Override
-    public void mouseMoved(MouseEvent e) {
-        if (!Main.map.mapView.isActiveLayerDrawable())
-            return;
-        processMouseEvent(e);
-        updCursor();
-        Main.map.mapView.repaint();
-        super.mouseMoved(e);
-    }
-
-    @Override
-    public void mousePressed(MouseEvent e) {
-        if (!Main.map.mapView.isActiveLayerDrawable())
-            return;
-        processMouseEvent(e);
-        if (nearestPrimitive != null) {
-            DataSet ds = Main.getLayerManager().getEditDataSet();
-            if (isCtrlDown) {
-                ds.clearSelection(nearestPrimitive);
-                Main.map.mapView.repaint();
-            } else {
-                int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
-                switch (maxInstances) {
-                case 0:
-                    ds.addSelected(nearestPrimitive);
-                    Main.map.mapView.repaint();
-                    break;
-                case 1:
-                    ds.addSelected(nearestPrimitive);
-                    Main.map.mapView.repaint();
-                    parentPlugin.loadParameter(nearestPrimitive, true);
-                    exitMode();
-                    break;
-                default:
-                    if (ds.getSelected().size() < maxInstances) {
-                        ds.addSelected(nearestPrimitive);
-                        Main.map.mapView.repaint();
-                    } else
-                        Main.info("Maximum instances!");
-                }
-            }
-        }
-        super.mousePressed(e);
-    }
-
-    @Override
-    public void eventDispatched(AWTEvent arg0) {
-        if (!(arg0 instanceof KeyEvent))
-            return;
-        KeyEvent ev = (KeyEvent) arg0;
-        isCtrlDown = (ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0;
-        if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) {
-            ev.consume();
-            cancelDrawing();
-        }
-    }
-
-    private void updCursor() {
-        if (mousePos != null) {
-            if (!Main.isDisplayingMapView())
-                return;
-            nearestPrimitive = Main.map.mapView.getNearestNodeOrWay(mousePos, OsmPrimitive::isUsable, false);
-            if (nearestPrimitive != null) {
-                setCursor(cursorActive);
-            } else {
-                setCursor(cursorNormal);
-            }
-        }
-    }
-
-    private void processMouseEvent(MouseEvent e) {
-        if (e != null) {
-            mousePos = e.getPoint();
-        }
-    }
-
-    private void setCursor(final Cursor c) {
-        if (currentCursor.equals(c))
-            return;
-        try {
-            // We invoke this to prevent strange things from happening
-            EventQueue.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    // Don't change cursor when mode has changed already
-                    if (!(Main.map.mapMode instanceof AnyAction))
-                        return;
-                    Main.map.mapView.setCursor(c);
-                }
-            });
-            currentCursor = c;
-        } catch (Exception e) {
-            Main.warn(e);
-        }
-    }
-
-    public void cancelDrawing() {
-        if (Main.map == null || Main.map.mapView == null)
-            return;
-        Main.map.statusLine.setHeading(-1);
-        Main.map.statusLine.setAngle(-1);
-        Main.map.mapView.repaint();
-        updateStatusLine();
-        parentPlugin.abortInput();
+    protected OsmPrimitive getNearest(Point mousePos) {
+        return Main.map.mapView.getNearestNodeOrWay(mousePos, OsmPrimitive::isUsable, false);
     }
 }
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java	(revision 33025)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/NodeAction.java	(revision 33026)
@@ -2,166 +2,20 @@
 package CommandLine;
 
-import java.awt.AWTEvent;
-import java.awt.Cursor;
-import java.awt.EventQueue;
 import java.awt.Point;
-import java.awt.Toolkit;
-import java.awt.event.AWTEventListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.mapmode.MapMode;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.MapFrame;
-import org.openstreetmap.josm.tools.ImageProvider;
 
-public class NodeAction extends MapMode implements AWTEventListener {
-    private final CommandLine parentPlugin;
-    private final Cursor cursorNormal, cursorActive;
-    private Cursor currentCursor;
-    private Point mousePos;
-    private Node nearestNode;
-    private boolean isCtrlDown;
-    // private Type type;
+public class NodeAction extends AbstractOsmAction<Node> {
 
     public NodeAction(MapFrame mapFrame, CommandLine parentPlugin) {
-        super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection"));
-        this.parentPlugin = parentPlugin;
-        cursorNormal = ImageProvider.getCursor("normal", "selection");
-        cursorActive = ImageProvider.getCursor("normal", "joinnode");
-        currentCursor = cursorNormal;
-        nearestNode = null;
-    }
-
-    @Override public void enterMode() {
-        super.enterMode();
-        currentCursor = cursorNormal;
-        Main.map.mapView.addMouseListener(this);
-        Main.map.mapView.addMouseMotionListener(this);
-        try {
-            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
-        } catch (SecurityException ex) {
-            Main.warn(ex);
-        }
-    }
-
-    @Override public void exitMode() {
-        super.exitMode();
-        Main.map.mapView.removeMouseListener(this);
-        Main.map.mapView.removeMouseMotionListener(this);
-        try {
-            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
-        } catch (SecurityException ex) {
-            Main.warn(ex);
-        }
+        super(mapFrame, parentPlugin, "joinnode");
     }
 
     @Override
-    public void mouseMoved(MouseEvent e) {
-        if (!Main.map.mapView.isActiveLayerDrawable())
-            return;
-        processMouseEvent(e);
-        updCursor();
-        Main.map.mapView.repaint();
-        super.mouseMoved(e);
-    }
-
-    @Override
-    public void mousePressed(MouseEvent e) {
-        if (!Main.map.mapView.isActiveLayerDrawable())
-            return;
-        processMouseEvent(e);
-        if (nearestNode != null) {
-            DataSet ds = Main.getLayerManager().getEditDataSet();
-            if (isCtrlDown) {
-                ds.clearSelection(nearestNode);
-                Main.map.mapView.repaint();
-            } else {
-                int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
-                switch (maxInstances) {
-                case 0:
-                    ds.addSelected(nearestNode);
-                    Main.map.mapView.repaint();
-                    break;
-                case 1:
-                    ds.addSelected(nearestNode);
-                    Main.map.mapView.repaint();
-                    parentPlugin.loadParameter(nearestNode, true);
-                    exitMode();
-                    break;
-                default:
-                    if (ds.getSelected().size() < maxInstances) {
-                        ds.addSelected(nearestNode);
-                        Main.map.mapView.repaint();
-                    } else
-                        parentPlugin.printHistory("Maximum instances is " + String.valueOf(maxInstances));
-                }
-            }
-        }
-        super.mousePressed(e);
-    }
-
-    @Override
-    public void eventDispatched(AWTEvent arg0) {
-        if (!(arg0 instanceof KeyEvent))
-            return;
-        KeyEvent ev = (KeyEvent) arg0;
-        isCtrlDown = (ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0;
-        if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) {
-            ev.consume();
-            cancelDrawing();
-        }
-    }
-
-    private void updCursor() {
-        if (mousePos != null) {
-            if (!Main.isDisplayingMapView())
-                return;
-            nearestNode = Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isUsable);
-            if (nearestNode != null) {
-                setCursor(cursorActive);
-            } else {
-                setCursor(cursorNormal);
-            }
-        }
-    }
-
-    private void processMouseEvent(MouseEvent e) {
-        if (e != null) {
-            mousePos = e.getPoint();
-        }
-    }
-
-    private void setCursor(final Cursor c) {
-        if (currentCursor.equals(c))
-            return;
-        try {
-            // We invoke this to prevent strange things from happening
-            EventQueue.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    // Don't change cursor when mode has changed already
-                    if (!(Main.map.mapMode instanceof NodeAction))
-                        return;
-                    Main.map.mapView.setCursor(c);
-                }
-            });
-            currentCursor = c;
-        } catch (Exception e) {
-            Main.warn(e);
-        }
-    }
-
-    public void cancelDrawing() {
-        if (Main.map == null || Main.map.mapView == null)
-            return;
-        Main.map.statusLine.setHeading(-1);
-        Main.map.statusLine.setAngle(-1);
-        Main.map.mapView.repaint();
-        updateStatusLine();
-        parentPlugin.abortInput();
+    protected Node getNearest(Point mousePos) {
+        return Main.map.mapView.getNearestNode(mousePos, OsmPrimitive::isUsable);
     }
 }
Index: /applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java
===================================================================
--- /applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java	(revision 33025)
+++ /applications/editors/josm/plugins/CommandLine/src/CommandLine/WayAction.java	(revision 33026)
@@ -2,187 +2,20 @@
 package CommandLine;
 
-import java.awt.AWTEvent;
-import java.awt.Cursor;
-import java.awt.EventQueue;
 import java.awt.Point;
-import java.awt.Toolkit;
-import java.awt.event.AWTEventListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.mapmode.MapMode;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.MapFrame;
-import org.openstreetmap.josm.tools.ImageProvider;
 
-public class WayAction extends MapMode implements AWTEventListener {
-    private final CommandLine parentPlugin;
-    private final Cursor cursorNormal, cursorActive;
-    private Cursor currentCursor;
-    private Point mousePos;
-    private Way nearestWay;
-    private boolean isCtrlDown;
-    // private Type type;
+public class WayAction extends AbstractOsmAction<Way> {
 
     public WayAction(MapFrame mapFrame, CommandLine parentPlugin) {
-        super(null, "addsegment.png", null, mapFrame, ImageProvider.getCursor("normal", "selection"));
-        this.parentPlugin = parentPlugin;
-        /*
-        this.type = type;
-        switch (type) {
-            case POINT:
-                cursorNormal = ImageProvider.getCursor("crosshair", null);
-                cursorActive = ImageProvider.getCursor("crosshair", "joinnode");
-                break;
-            case NODE:
-                cursorNormal = ImageProvider.getCursor("normal", "selection");
-                cursorActive = ImageProvider.getCursor("normal", "joinnode");
-                break;
-            case WAY:
-         */
-        cursorNormal = ImageProvider.getCursor("normal", "selection");
-        cursorActive = ImageProvider.getCursor("normal", "joinway");
-        /*
-                break;
-            default:
-                cursorNormal = ImageProvider.getCursor("normal", "selection");
-                cursorActive = ImageProvider.getCursor("normal", null);
-                break;
-        }
-         */
-        currentCursor = cursorNormal;
-        nearestWay = null;
-    }
-
-    @Override public void enterMode() {
-        super.enterMode();
-        currentCursor = cursorNormal;
-        Main.map.mapView.addMouseListener(this);
-        Main.map.mapView.addMouseMotionListener(this);
-        try {
-            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
-        } catch (SecurityException ex) {
-            Main.warn(ex);
-        }
-    }
-
-    @Override public void exitMode() {
-        super.exitMode();
-        Main.map.mapView.removeMouseListener(this);
-        Main.map.mapView.removeMouseMotionListener(this);
-        try {
-            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
-        } catch (SecurityException ex) {
-            Main.warn(ex);
-        }
+        super(mapFrame, parentPlugin, "joinway");
     }
 
     @Override
-    public void mouseMoved(MouseEvent e) {
-        if (!Main.map.mapView.isActiveLayerDrawable())
-            return;
-        processMouseEvent(e);
-        updCursor();
-        Main.map.mapView.repaint();
-        super.mouseMoved(e);
-    }
-
-    @Override
-    public void mousePressed(MouseEvent e) {
-        if (!Main.map.mapView.isActiveLayerDrawable())
-            return;
-        processMouseEvent(e);
-        if (nearestWay != null) {
-            DataSet ds = Main.getLayerManager().getEditDataSet();
-            if (isCtrlDown) {
-                ds.clearSelection(nearestWay);
-                Main.map.mapView.repaint();
-            } else {
-                int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
-                switch (maxInstances) {
-                case 0:
-                    ds.addSelected(nearestWay);
-                    Main.map.mapView.repaint();
-                    break;
-                case 1:
-                    ds.addSelected(nearestWay);
-                    Main.map.mapView.repaint();
-                    parentPlugin.loadParameter(nearestWay, true);
-                    exitMode();
-                    break;
-                default:
-                    if (ds.getSelected().size() < maxInstances) {
-                        ds.addSelected(nearestWay);
-                        Main.map.mapView.repaint();
-                    } else
-                        Main.info("Maximum instances!");
-                }
-            }
-        }
-        super.mousePressed(e);
-    }
-
-    @Override
-    public void eventDispatched(AWTEvent arg0) {
-        if (!(arg0 instanceof KeyEvent))
-            return;
-        KeyEvent ev = (KeyEvent) arg0;
-        isCtrlDown = (ev.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0;
-        if (ev.getKeyCode() == KeyEvent.VK_ESCAPE && ev.getID() == KeyEvent.KEY_PRESSED) {
-            ev.consume();
-            cancelDrawing();
-        }
-    }
-
-    private void updCursor() {
-        if (mousePos != null) {
-            if (!Main.isDisplayingMapView())
-                return;
-            nearestWay = Main.map.mapView.getNearestWay(mousePos, OsmPrimitive::isUsable);
-            if (nearestWay != null) {
-                setCursor(cursorActive);
-            } else {
-                setCursor(cursorNormal);
-            }
-        }
-    }
-
-    private void processMouseEvent(MouseEvent e) {
-        if (e != null) {
-            mousePos = e.getPoint();
-        }
-    }
-
-    private void setCursor(final Cursor c) {
-        if (currentCursor.equals(c))
-            return;
-        try {
-            // We invoke this to prevent strange things from happening
-            EventQueue.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    // Don't change cursor when mode has changed already
-                    if (!(Main.map.mapMode instanceof WayAction))
-                        return;
-                    Main.map.mapView.setCursor(c);
-                }
-            });
-            currentCursor = c;
-        } catch (Exception e) {
-            Main.warn(e);
-        }
-    }
-
-    public void cancelDrawing() {
-        if (Main.map == null || Main.map.mapView == null)
-            return;
-        Main.map.statusLine.setHeading(-1);
-        Main.map.statusLine.setAngle(-1);
-        Main.map.mapView.repaint();
-        updateStatusLine();
-        parentPlugin.abortInput();
+    protected Way getNearest(Point mousePos) {
+        return Main.map.mapView.getNearestWay(mousePos, OsmPrimitive::isUsable);
     }
 }
