Index: trunk/src/org/openstreetmap/josm/actions/CopyAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/CopyAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/CopyAction.java	(revision 10409)
@@ -13,5 +13,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
@@ -26,5 +25,5 @@
 public final class CopyAction extends JosmAction {
 
-    // regular expression that matches text clipboard contents after copying
+    /** regular expression that matches text clipboard contents after copying */
     public static final String CLIPBOARD_REGEXP = "((node|way|relation)\\s\\d+,)*(node|way|relation)\\s\\d+";
 
@@ -57,5 +56,5 @@
      */
     public static void copy(OsmDataLayer source, Collection<OsmPrimitive> primitives) {
-        /* copy ids to the clipboard */
+        // copy ids to the clipboard
         String ids = getCopyString(primitives);
         Utils.copyToClipboard(ids);
@@ -75,10 +74,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java	(revision 10409)
@@ -25,5 +25,4 @@
 import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -290,10 +289,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/DeleteAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/DeleteAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/DeleteAction.java	(revision 10409)
@@ -10,5 +10,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -38,10 +37,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/DistributeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/DistributeAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/DistributeAction.java	(revision 10409)
@@ -20,5 +20,4 @@
 import org.openstreetmap.josm.command.MoveCommand;
 import org.openstreetmap.josm.command.SequenceCommand;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -301,10 +300,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java	(revision 10409)
@@ -11,5 +11,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -62,10 +61,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java	(revision 10409)
@@ -11,5 +11,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;
@@ -36,10 +35,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java	(revision 10409)
@@ -16,5 +16,4 @@
 import org.openstreetmap.josm.command.SelectCommand;
 import org.openstreetmap.josm.command.SequenceCommand;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -36,4 +35,7 @@
 public class FollowLineAction extends JosmAction {
 
+    /**
+     * Constructs a new {@code FollowLineAction}.
+     */
     public FollowLineAction() {
         super(
@@ -48,10 +50,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 10409)
@@ -1548,10 +1548,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java	(revision 10409)
@@ -25,5 +25,4 @@
 import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.data.coor.EastNorth;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -209,10 +208,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/JosmAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/JosmAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/JosmAction.java	(revision 10409)
@@ -171,5 +171,5 @@
         }
     }
-    
+
     /**
      * Installs the listeners to this action.
@@ -351,4 +351,18 @@
 
     /**
+     * Updates enabled state according to primitives currently selected in edit data set, if any.
+     * Can be called in {@link #updateEnabledState()} implementations.
+     * @since 10409
+     */
+    protected final void updateEnabledStateOnCurrentSelection() {
+        DataSet ds = getLayerManager().getEditDataSet();
+        if (ds == null) {
+            setEnabled(false);
+        } else {
+            updateEnabledState(ds.getSelected());
+        }
+    }
+
+    /**
      * Adapter for layer change events. Runs updateEnabledState() whenever the active layer changed.
      */
Index: trunk/src/org/openstreetmap/josm/actions/MirrorAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/MirrorAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/MirrorAction.java	(revision 10409)
@@ -18,5 +18,4 @@
 import org.openstreetmap.josm.command.MoveCommand;
 import org.openstreetmap.josm.command.SequenceCommand;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -87,10 +86,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/MoveAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/MoveAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/MoveAction.java	(revision 10409)
@@ -152,10 +152,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java	(revision 10409)
@@ -276,10 +276,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 10409)
@@ -32,5 +32,4 @@
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.command.SequenceCommand;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -658,10 +657,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java	(revision 10409)
@@ -18,5 +18,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.RemoveNodesCommand;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -187,10 +186,5 @@
     @Override
     protected void updateEnabledState() {
-        DataSet ds = getLayerManager().getEditDataSet();
-        if (ds == null) {
-            setEnabled(false);
-        } else {
-            updateEnabledState(ds.getSelected());
-        }
+        updateEnabledStateOnCurrentSelection();
     }
 
Index: trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 10409)
@@ -253,5 +253,5 @@
         }
 
-        protected OsmDataLayer addNewLayerIfRequired(String newLayerName, Bounds bounds) {
+        protected OsmDataLayer addNewLayerIfRequired(String newLayerName) {
             int numDataLayers = getNumDataLayers();
             if (newLayer || numDataLayers == 0 || (numDataLayers > 1 && getEditLayer() == null)) {
@@ -268,5 +268,5 @@
 
         protected void loadData(String newLayerName, Bounds bounds) {
-            OsmDataLayer layer = addNewLayerIfRequired(newLayerName, bounds);
+            OsmDataLayer layer = addNewLayerIfRequired(newLayerName);
             if (layer == null) {
                 layer = getEditLayer();
Index: trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 10407)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 10409)
@@ -690,13 +690,13 @@
         if (selectedWay != null) {
             int posn0 = selectedWay.getNodes().indexOf(currentNode);
+            // CHECKSTYLE.OFF: SingleSpaceSeparator
             if (posn0 != -1 && // n0 is part of way
-                  // CHECKSTYLE.OFF: SingleSpaceSeparator
-                  (posn0 >= 1                             && targetNode.equals(selectedWay.getNode(posn0-1))) || // previous node
-                  (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) {  // next node
-                  // CHECKSTYLE.ON: SingleSpaceSeparator
+               (posn0 >= 1                             && targetNode.equals(selectedWay.getNode(posn0-1))) || // previous node
+               (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) {  // next node
                 getLayerManager().getEditDataSet().setSelected(targetNode);
                 lastUsedNode = targetNode;
                 return true;
             }
+            // CHECKSTYLE.ON: SingleSpaceSeparator
         }
 
