Index: trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java	(revision 18850)
+++ trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java	(revision 18851)
@@ -18,4 +18,6 @@
 import java.util.Objects;
 import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
@@ -38,4 +40,5 @@
 import org.openstreetmap.josm.data.UndoRedoHandler;
 import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.osm.DataSelectionListener;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
@@ -48,4 +51,5 @@
 import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.Notification;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.spi.preferences.IPreferences;
@@ -130,10 +134,23 @@
      */
     public static double askSimplifyWays(List<Way> ways, String text, boolean auto) {
-        IPreferences s = Config.getPref();
-        String key = "simplify-way." + (auto ? "auto." : "");
-        String keyRemember = key + "remember";
-        String keyError = key + "max-error";
-
-        String r = s.get(keyRemember, "ask");
+        return askSimplifyWays(ways, () -> text, null, auto);
+    }
+
+    /**
+     * Asks the user for max-err value used to simplify ways, if not remembered before
+     * @param ways the ways that are being simplified (to show estimated number of nodes to be removed)
+     * @param textSupplier the text being shown (called when the DataSet selection changes)
+     * @param auto whether it's called automatically (conversion) or by the user
+     * @param listener The dataset selection update listener
+     * @return the max-err value or -1 if canceled
+     */
+    private static double askSimplifyWays(List<Way> ways, Supplier<String> textSupplier, SimplifyWayDataSelectionListener listener,
+                                          boolean auto) {
+        final IPreferences s = Config.getPref();
+        final String key = "simplify-way." + (auto ? "auto." : "");
+        final String keyRemember = key + "remember";
+        final String keyError = key + "max-error";
+
+        final String r = s.get(keyRemember, "ask");
         if (auto && "no".equals(r)) {
             return -1;
@@ -142,9 +159,11 @@
         }
 
-        JPanel p = new JPanel(new GridBagLayout());
-        p.add(new JLabel("<html><body style=\"width: 375px;\">" + text + "<br><br>" +
+        final JPanel p = new JPanel(new GridBagLayout());
+        final Supplier<String> actualTextSupplier = () -> "<html><body style=\"width: 375px;\">" + textSupplier.get() + "<br><br>" +
                 tr("This reduces unnecessary nodes along the way and is especially recommended if GPS tracks were recorded by time "
-                 + "(e.g. one point per second) or when the accuracy was low (reduces \"zigzag\" tracks).")
-                + "</body></html>"), GBC.eol());
+                        + "(e.g. one point per second) or when the accuracy was low (reduces \"zigzag\" tracks).")
+                + "</body></html>";
+        final JLabel textLabel = new JLabel(actualTextSupplier.get());
+        p.add(textLabel, GBC.eol());
         p.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 5));
         JPanel q = new JPanel(new GridBagLayout());
@@ -158,4 +177,17 @@
         JLabel nodesToRemove = new JLabel();
         SimplifyChangeListener l = new SimplifyChangeListener(nodesToRemove, errorModel, ways);
+        final Runnable changeCleanup = () -> {
+            if (l.lastCommand != null && l.lastCommand.equals(UndoRedoHandler.getInstance().getLastCommand())) {
+                UndoRedoHandler.getInstance().undo();
+                l.lastCommand = null;
+            }
+        };
+        if (listener != null) {
+            listener.addConsumer(ignored -> {
+                textLabel.setText(actualTextSupplier.get());
+                changeCleanup.run();
+                l.stateChanged(null);
+            });
+        }
         if (!ways.isEmpty()) {
             errorModel.addChangeListener(l);
@@ -183,8 +215,5 @@
         int ret = ed.showDialog().getValue();
         double val = (double) n.getValue();
-        if (l.lastCommand != null && l.lastCommand.equals(UndoRedoHandler.getInstance().getLastCommand())) {
-            UndoRedoHandler.getInstance().undo();
-            l.lastCommand = null;
-        }
+        changeCleanup.run();
         if (ret == 1) {
             s.putDouble(keyError, val);
@@ -203,9 +232,10 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-        DataSet ds = getLayerManager().getEditDataSet();
-        ds.update(() -> {
-            List<Way> ways = ds.getSelectedWays().stream()
-                    .filter(p -> !p.isIncomplete())
-                    .collect(Collectors.toList());
+        final DataSet ds = getLayerManager().getEditDataSet();
+        final List<Way> ways = new ArrayList<>();
+        final SimplifyWayDataSelectionListener listener = new SimplifyWayDataSelectionListener(ways);
+        ds.addSelectionListener(listener);
+        try {
+            listener.updateWayList(ds);
             if (ways.isEmpty()) {
                 alertSelectAtLeastOneWay();
@@ -215,16 +245,18 @@
             }
 
-            String lengthstr = SystemOfMeasurement.getSystemOfMeasurement().getDistText(
+            final Supplier<String> lengthStr = () -> SystemOfMeasurement.getSystemOfMeasurement().getDistText(
                     ways.stream().mapToDouble(Way::getLength).sum());
 
-            double err = askSimplifyWays(ways, trn(
-                    "You are about to simplify {0} way with a total length of {1}.",
-                    "You are about to simplify {0} ways with a total length of {1}.",
-                    ways.size(), ways.size(), lengthstr), false);
+            final double err = askSimplifyWays(ways, () -> trn(
+                                "You are about to simplify {0} way with a total length of {1}.",
+                                "You are about to simplify {0} ways with a total length of {1}.",
+                                ways.size(), ways.size(), lengthStr.get()), listener, false);
 
             if (err > 0) {
                 simplifyWays(ways, err);
             }
-        });
+        } finally {
+            ds.removeSelectionListener(listener);
+        }
     }
 
@@ -249,6 +281,5 @@
         }
         if (!isRequired) {
-            List<OsmPrimitive> parents = new LinkedList<>();
-            parents.addAll(node.getReferrers());
+            List<OsmPrimitive> parents = new LinkedList<>(node.getReferrers());
             parents.remove(way);
             isRequired = !parents.isEmpty();
@@ -519,3 +550,36 @@
         }
     }
+
+    private static final class SimplifyWayDataSelectionListener implements DataSelectionListener {
+        private final List<Way> wayList;
+        private Consumer<List<Way>> consumer;
+
+        /**
+         * Create a new selection listener for {@link SimplifyWayAction}
+         * @param wayList The <i>modifiable</i> list to update on selection changes
+         */
+        SimplifyWayDataSelectionListener(List<Way> wayList) {
+            this.wayList = wayList;
+        }
+
+        @Override
+        public void selectionChanged(SelectionChangeEvent event) {
+            updateWayList(event.getSource());
+        }
+
+        void updateWayList(DataSet dataSet) {
+            final List<Way> newWays = dataSet.getSelectedWays().stream()
+                    .filter(p -> !p.isIncomplete())
+                    .collect(Collectors.toList());
+            this.wayList.clear();
+            this.wayList.addAll(newWays);
+            if (this.consumer != null) {
+                GuiHelper.runInEDT(() -> this.consumer.accept(this.wayList));
+            }
+        }
+
+        void addConsumer(Consumer<List<Way>> wayConsumer) {
+            this.consumer = wayConsumer;
+        }
+    }
 }
