Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 14846)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 14847)
@@ -27,5 +27,4 @@
 import javax.swing.event.TreeSelectionListener;
 import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreePath;
 
@@ -42,4 +41,8 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.WaySegment;
+import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
+import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
+import org.openstreetmap.josm.data.osm.event.DatasetEventManager;
+import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
 import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
@@ -77,5 +80,6 @@
  * @author frsantos
  */
-public class ValidatorDialog extends ToggleDialog implements DataSelectionListener, ActiveLayerChangeListener {
+public class ValidatorDialog extends ToggleDialog
+        implements DataSelectionListener, ActiveLayerChangeListener, DataSetListenerAdapter.Listener {
 
     /** The display tree */
@@ -85,17 +89,18 @@
     public static final ValidateAction validateAction = new ValidateAction();
 
-    /** The fix button */
-    private final SideButton fixButton;
-    /** The ignore button */
-    private final SideButton ignoreButton;
-    /** The reset ignorelist button */
-    private final SideButton ignorelistManagement;
-    /** The select button */
-    private final SideButton selectButton;
-    /** The lookup button */
-    private final SideButton lookupButton;
+    /** The fix action */
+    private final transient Action fixAction;
+    /** The ignore action */
+    private final transient Action ignoreAction;
+    /** The ignore-list management action */
+    private final transient Action ignorelistManagementAction;
+    /** The select action */
+    private final transient Action selectAction;
+    /** The lookup action */
+    private final transient LookupAction lookupAction;
 
     private final JPopupMenu popupMenu = new JPopupMenu();
     private final transient PopupMenuHandler popupMenuHandler = new PopupMenuHandler(popupMenu);
+    private final transient DataSetListenerAdapter dataChangedAdapter = new DataSetListenerAdapter(this);
 
     /** Last selected element */
@@ -120,21 +125,20 @@
         List<SideButton> buttons = new LinkedList<>();
 
-        selectButton = new SideButton(new AbstractSelectAction() {
+        selectAction = new AbstractSelectAction() {
             @Override
             public void actionPerformed(ActionEvent e) {
                 setSelectedItems();
             }
-        });
-        InputMapUtils.addEnterAction(tree, selectButton.getAction());
-
-        selectButton.setEnabled(false);
-        buttons.add(selectButton);
-
-        lookupButton = new SideButton(new LookupAction());
-        buttons.add(lookupButton);
+        };
+        selectAction.setEnabled(false);
+        InputMapUtils.addEnterAction(tree, selectAction);
+        buttons.add(new SideButton(selectAction));
+
+        lookupAction = new LookupAction();
+        buttons.add(new SideButton(lookupAction));
 
         buttons.add(new SideButton(validateAction));
 
-        fixButton = new SideButton(new AbstractAction() {
+        fixAction = new AbstractAction() {
             {
                 putValue(NAME, tr("Fix"));
@@ -146,10 +150,10 @@
                 fixErrors();
             }
-        });
-        fixButton.setEnabled(false);
-        buttons.add(fixButton);
+        };
+        fixAction.setEnabled(false);
+        buttons.add(new SideButton(fixAction));
 
         if (ValidatorPrefHelper.PREF_USE_IGNORE.get()) {
-            ignoreButton = new SideButton(new AbstractAction() {
+            ignoreAction = new AbstractAction() {
                 {
                     putValue(NAME, tr("Ignore"));
@@ -161,24 +165,13 @@
                     ignoreErrors();
                 }
-            });
-            ignoreButton.setEnabled(false);
-            buttons.add(ignoreButton);
-
-            ignorelistManagement = new SideButton(new AbstractAction() {
-                {
-                    putValue(NAME, tr("Manage Ignore"));
-                    putValue(SHORT_DESCRIPTION, tr("Manage the ignore list"));
-                    new ImageProvider("dialogs", "fix").getResource().attachImageIcon(this, true);
-                }
-
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    new ValidatorListManagementDialog("Ignore");
-                }
-            });
-            buttons.add(ignorelistManagement);
+            };
+            ignoreAction.setEnabled(false);
+            buttons.add(new SideButton(ignoreAction));
+
+            ignorelistManagementAction = new IgnorelistManagementAction();
+            buttons.add(new SideButton(ignorelistManagementAction));
         } else {
-            ignoreButton = null;
-            ignorelistManagement = null;
+            ignoreAction = null;
+            ignorelistManagementAction = null;
         }
 
@@ -187,13 +180,27 @@
 
     /**
+     * The action to manage the ignore list.
+     */
+    static class IgnorelistManagementAction extends AbstractAction {
+        IgnorelistManagementAction() {
+            putValue(NAME, tr("Manage Ignore"));
+            putValue(SHORT_DESCRIPTION, tr("Manage the ignore list"));
+            new ImageProvider("dialogs", "fix").getResource().attachImageIcon(this, true);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            new ValidatorListManagementDialog("Ignore");
+        }
+    }
+
+    /**
      * The action to lookup the selection in the error tree.
      */
-    class LookupAction extends AbstractAction implements DataSelectionListener {
-
+    class LookupAction extends AbstractAction {
         LookupAction() {
             putValue(NAME, tr("Lookup"));
             putValue(SHORT_DESCRIPTION, tr("Looks up the selected primitives in the error list."));
             new ImageProvider("dialogs", "search").getResource().attachImageIcon(this, true);
-            SelectionEventManager.getInstance().addSelectionListener(this);
             updateEnabledState();
         }
@@ -208,5 +215,5 @@
         }
 
-        protected void updateEnabledState() {
+        public void updateEnabledState() {
             boolean found = false;
             for (TestError e : tree.getErrors()) {
@@ -220,13 +227,9 @@
             setEnabled(found);
         }
-
-        @Override
-        public void selectionChanged(SelectionChangeEvent event) {
-            updateEnabledState();
-        }
     }
 
     @Override
     public void showNotify() {
+        DatasetEventManager.getInstance().addDatasetListener(dataChangedAdapter, FireMode.IN_EDT_CONSOLIDATED);
         SelectionEventManager.getInstance().addSelectionListener(this);
         DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
@@ -235,8 +238,10 @@
         }
         MainApplication.getLayerManager().addAndFireActiveLayerChangeListener(this);
+
     }
 
     @Override
     public void hideNotify() {
+        DatasetEventManager.getInstance().removeDatasetListener(dataChangedAdapter);
         MainApplication.getLayerManager().removeActiveLayerChangeListener(this);
         SelectionEventManager.getInstance().removeSelectionListener(this);
@@ -349,5 +354,5 @@
         for (TreePath path : selectedPaths) {
             DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
-            Enumeration<TreeNode> children = node.breadthFirstEnumeration();
+            Enumeration<?> children = node.breadthFirstEnumeration();
             while (children.hasMoreElements()) {
                 DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement();
@@ -394,7 +399,7 @@
                 }
             });
-            selectButton.setEnabled(true);
-            if (ignoreButton != null) {
-                ignoreButton.setEnabled(node.getDepth() <= 1);
+            selectAction.setEnabled(true);
+            if (ignoreAction != null) {
+                ignoreAction.setEnabled(node.getDepth() <= 1);
             }
         }
@@ -472,9 +477,9 @@
             }
 
-            fixButton.setEnabled(false);
-            if (ignoreButton != null) {
-                ignoreButton.setEnabled(false);
-            }
-            selectButton.setEnabled(false);
+            fixAction.setEnabled(false);
+            if (ignoreAction != null) {
+                ignoreAction.setEnabled(false);
+            }
+            selectAction.setEnabled(false);
 
             boolean isDblClick = isDoubleClick(e);
@@ -483,5 +488,5 @@
 
             boolean hasFixes = setSelection(sel, isDblClick);
-            fixButton.setEnabled(hasFixes);
+            fixAction.setEnabled(hasFixes);
 
             if (isDblClick) {
@@ -514,13 +519,12 @@
         @Override
         public void valueChanged(TreeSelectionEvent e) {
-            fixButton.setEnabled(false);
-            if (ignoreButton != null) {
-                ignoreButton.setEnabled(false);
-            }
-            selectButton.setEnabled(false);
+            if (ignoreAction != null) {
+                ignoreAction.setEnabled(false);
+            }
+            selectAction.setEnabled(false);
 
             Collection<OsmPrimitive> sel = new HashSet<>();
             boolean hasFixes = setSelection(sel, true);
-            fixButton.setEnabled(hasFixes);
+            fixAction.setEnabled(hasFixes);
             popupMenuHandler.setPrimitives(sel);
             invalidateValidatorLayers();
@@ -578,4 +582,5 @@
     public void selectionChanged(SelectionChangeEvent event) {
         updateSelection(event.getSelection());
+        lookupAction.updateEnabledState();
     }
 
@@ -682,10 +687,6 @@
 
     @Override
-    public void destroy() {
-        if (lookupButton != null && lookupButton.getAction() instanceof DataSelectionListener) {
-            Action a = lookupButton.getAction();
-            SelectionEventManager.getInstance().removeSelectionListener((DataSelectionListener) a);
-        }
-        super.destroy();
+    public void processDatasetEvent(AbstractDatasetChangedEvent event) {
+        validateAction.updateEnabledState();
     }
 
