Index: /trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java	(revision 13611)
@@ -14,4 +14,5 @@
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
@@ -28,4 +29,5 @@
 import org.openstreetmap.josm.data.osm.NodeGraph;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.TagCollection;
 import org.openstreetmap.josm.data.osm.Way;
@@ -115,5 +117,5 @@
             return null;
 
-        List<DataSet> dataSets = ways.stream().map(Way::getDataSet).distinct().collect(Collectors.toList());
+        List<DataSet> dataSets = ways.stream().map(Way::getDataSet).filter(Objects::nonNull).distinct().collect(Collectors.toList());
         if (dataSets.size() != 1) {
             throw new IllegalArgumentException("Cannot combine ways of multiple data sets.");
@@ -251,5 +253,5 @@
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
         int numWays = 0;
-        if (selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked)) {
+        if (OsmUtils.isOsmCollectionEditable(selection)) {
             for (OsmPrimitive osm : selection) {
                 if (osm instanceof Way && !osm.isIncomplete() && ++numWays >= 2) {
Index: /trunk/src/org/openstreetmap/josm/actions/JosmAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/JosmAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/JosmAction.java	(revision 13611)
@@ -20,4 +20,5 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
@@ -365,6 +366,5 @@
      */
     protected final void updateEnabledStateOnModifiableSelection(Collection<? extends OsmPrimitive> selection) {
-        setEnabled(selection != null && !selection.isEmpty()
-                && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked));
+        setEnabled(OsmUtils.isOsmCollectionEditable(selection));
     }
 
Index: /trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 13611)
@@ -28,8 +28,8 @@
 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.DefaultNameFormatter;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.TagCollection;
 import org.openstreetmap.josm.data.osm.Way;
@@ -365,14 +365,11 @@
     @Override
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
-        if (selection == null || selection.isEmpty()
-                || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isLocked)) {
-            setEnabled(false);
-            return;
-        }
-        boolean ok = true;
-        for (OsmPrimitive osm : selection) {
-            if (!(osm instanceof Node)) {
-                ok = false;
-                break;
+        boolean ok = OsmUtils.isOsmCollectionEditable(selection);
+        if (ok) {
+            for (OsmPrimitive osm : selection) {
+                if (!(osm instanceof Node)) {
+                    ok = false;
+                    break;
+                }
             }
         }
Index: /trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java	(revision 13611)
@@ -11,7 +11,7 @@
 import org.openstreetmap.josm.command.MoveCommand;
 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;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.dialogs.LatLonDialog;
@@ -62,14 +62,5 @@
     @Override
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
-        if (selection == null || selection.isEmpty()
-                || selection.stream().map(OsmPrimitive::getDataSet).anyMatch(DataSet::isLocked)) {
-            setEnabled(false);
-            return;
-        }
-        if ((selection.size()) == 1 && (selection.toArray()[0] instanceof Node)) {
-            setEnabled(true);
-        } else {
-            setEnabled(false);
-        }
+        setEnabled(OsmUtils.isOsmCollectionEditable(selection) && selection.size() == 1 && selection.toArray()[0] instanceof Node);
     }
 }
Index: /trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java	(revision 13611)
@@ -26,8 +26,8 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.SplitWayCommand;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.PrimitiveId;
 import org.openstreetmap.josm.data.osm.Relation;
@@ -296,6 +296,5 @@
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
         // Selection still can be wrong, but let SplitWayAction process and tell user what's wrong
-        setEnabled(selection != null && !selection.isEmpty()
-                && selection.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked)
+        setEnabled(OsmUtils.isOsmCollectionEditable(selection)
                 && selection.stream().anyMatch(o -> o instanceof Node && !o.isIncomplete()));
     }
Index: /trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java	(revision 13611)
@@ -16,4 +16,5 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.gui.MainApplication;
@@ -70,6 +71,6 @@
     @Override
     public void selectionChanged(final Collection<? extends OsmPrimitive> newSelection) {
-        GuiHelper.runInEDT(() -> setEnabled(newSelection != null && !newSelection.isEmpty() && !relations.isEmpty()
-                && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked)));
+        GuiHelper.runInEDT(() -> setEnabled(newSelection != null && !newSelection.isEmpty()
+                && OsmUtils.isOsmCollectionEditable(relations)));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java	(revision 13611)
@@ -8,5 +8,5 @@
 
 import org.openstreetmap.josm.actions.mapmode.DeleteAction;
-import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.gui.MainApplication;
@@ -51,5 +51,5 @@
     @Override
     protected void updateEnabledState() {
-        setEnabled(!relations.isEmpty() && relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked));
+        setEnabled(OsmUtils.isOsmCollectionEditable(relations));
     }
 }
Index: /trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java	(revision 13611)
@@ -13,6 +13,6 @@
 
 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.OsmUtils;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
@@ -89,5 +89,5 @@
     protected void updateEnabledState() {
         boolean enabled = false;
-        if (relations.stream().map(Relation::getDataSet).noneMatch(DataSet::isLocked)) {
+        if (OsmUtils.isOsmCollectionEditable(relations)) {
             for (Relation r : relations) {
                 if (!r.isDeleted()) {
Index: /trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java	(revision 13611)
@@ -3,7 +3,9 @@
 
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
@@ -153,3 +155,14 @@
         return layer1;
     }
+
+    /**
+     * Determines if the given collection contains primitives, and that none of them belong to a locked layer.
+     * @param collection collection of OSM primitives
+     * @return {@code true} if the given collection is not empty and does not contain any primitive in a locked layer.
+     * @since 13611
+     */
+    public static boolean isOsmCollectionEditable(Collection<? extends OsmPrimitive> collection) {
+        return collection != null && !collection.isEmpty()
+            && collection.stream().map(OsmPrimitive::getDataSet).filter(Objects::nonNull).noneMatch(DataSet::isLocked);
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/data/validation/TestError.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/TestError.java	(revision 13610)
+++ /trunk/src/org/openstreetmap/josm/data/validation/TestError.java	(revision 13611)
@@ -12,7 +12,7 @@
 
 import org.openstreetmap.josm.command.Command;
-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.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.Way;
@@ -360,5 +360,5 @@
     public boolean isFixable() {
         return (fixingCommand != null || ((tester != null) && tester.isFixable(this)))
-                && primitives.stream().map(OsmPrimitive::getDataSet).noneMatch(DataSet::isLocked);
+                && OsmUtils.isOsmCollectionEditable(primitives);
     }
 
