Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java	(revision 2623)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java	(revision 2672)
@@ -68,6 +68,8 @@
 		if (newFrame != null)
 		{
+            errors = new ArrayList<TestError>(50);
 		    validationDialog = new ValidatorDialog();
 	        newFrame.addToggleDialog(validationDialog);
+            Main.main.addLayer(new ErrorLayer(tr("Validation errors")));
 		}
 	}
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Severity.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Severity.java	(revision 2623)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Severity.java	(revision 2672)
@@ -1,18 +1,25 @@
 package org.openstreetmap.josm.plugins.validator;
+
+import java.awt.Color;
+
+import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
 
 /** The error severity */
 public enum Severity {
 	/** Error messages */
-	ERROR("Errors", "error.gif"),
+	ERROR("Errors", "error.gif",       SimplePaintVisitor.getPreferencesColor("validation error", Color.RED)),
 	/** Warning messages */ 
-	WARNING("Warnings", "warning.gif"), 
+	WARNING("Warnings", "warning.gif", SimplePaintVisitor.getPreferencesColor("validation warning", Color.YELLOW)), 
 	/** Other messages */ 
-	OTHER("Other", "other.gif"); 
+	OTHER("Other", "other.gif",        SimplePaintVisitor.getPreferencesColor("validation other", Color.CYAN)); 
 	
 	/** Description of the severity code */
 	private final String message;
 	
-	/** Associated icon */
-	private final String icon;
+    /** Associated icon */
+    private final String icon;
+
+    /** Associated color */
+    private final Color color;
 
 	/**
@@ -22,8 +29,9 @@
 	 * @param icon Associated icon
 	 */
-    Severity(String message, String icon) 
+    Severity(String message, String icon, Color color) 
     {
         this.message = message;
 		this.icon = icon;
+        this.color = color;
     }
 
@@ -42,4 +50,13 @@
 		return icon;
 	}
+
+    /**
+     * Gets the associated color
+     * @return The associated color
+     */
+    public Color getColor()
+    {
+        return color;
+    }
     
     
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java	(revision 2623)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java	(revision 2672)
@@ -139,5 +139,5 @@
 	 * @return The command to fix the error
 	 */
-	public Command fixError(TestError testError)
+	public Command fixError(@SuppressWarnings("unused") TestError testError)
 	{
 		return null;
@@ -150,5 +150,5 @@
 	 * @return true if the error can be fixed
 	 */
-	public boolean isFixable(TestError testError)
+	public boolean isFixable(@SuppressWarnings("unused") TestError testError)
 	{
 		return false;
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java	(revision 2623)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/TestError.java	(revision 2672)
@@ -1,9 +1,12 @@
 package org.openstreetmap.josm.plugins.validator;
 
+import java.awt.*;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.*;
+import org.openstreetmap.josm.data.osm.visitor.Visitor;
+import org.openstreetmap.josm.gui.MapView;
 
 /**
@@ -23,4 +26,6 @@
 	/** Internal code used by testers to classify errors */
 	private int internalCode;
+    /** If this error is selected */
+    private boolean selected;
 	
 	/**
@@ -183,4 +188,157 @@
 		
 		return tester.fixError(this);
-	}	
+	}
+
+    /**
+     * Paints the error on affected primitives
+     * 
+     * @param g The graphics
+     * @param mv The MapView
+     */
+    public void paint(Graphics g, MapView mv)
+    {
+        PaintVisitor v = new PaintVisitor(g, mv);
+        for( OsmPrimitive p : primitives)
+        {
+            if( !p.deleted )
+                p.visit(v);
+        }
+    }	
+    
+    class PaintVisitor implements Visitor
+    {
+        /** The graphics */
+        private final Graphics g;
+        /** The MapView */
+        private final MapView mv;
+        
+        /**
+         * Constructor 
+         * @param g The graphics 
+         * @param mv The Mapview
+         */
+        public PaintVisitor(Graphics g, MapView mv)
+        {
+            this.g = g;
+            this.mv = mv;
+        }
+
+        /**
+         * Draws a circle around the node 
+         * @param n The node
+         * @param color The circle color
+         */
+        public void drawNode(Node n, Color color)
+        {
+            Point p = mv.getPoint(n.eastNorth);
+            g.setColor(color);
+            if( selected )
+            {
+                g.fillOval(p.x-5, p.y-5, 10, 10);
+            }
+            else
+                g.drawOval(p.x-5, p.y-5, 10, 10);
+        }
+
+        /**
+         * Draws a line around the segment
+         * 
+         * @param s The segment
+         * @param color The color
+         */
+        public void drawSegment(Segment s, Color color)
+        {
+            Point p1 = mv.getPoint(s.from.eastNorth);
+            Point p2 = mv.getPoint(s.to.eastNorth);
+            g.setColor(color);
+            
+            double t = Math.atan2(p2.x-p1.x, p2.y-p1.y);
+            double cosT = Math.cos(t);
+            double sinT = Math.sin(t);
+            int deg = (int)Math.toDegrees(t);
+            if( selected )
+            {
+                int[] x = new int[] {(int)(p1.x + 5*cosT), (int)(p2.x + 5*cosT), (int)(p2.x - 5*cosT), (int)(p1.x - 5*cosT)};
+                int[] y = new int[] {(int)(p1.y - 5*sinT), (int)(p2.y - 5*sinT), (int)(p2.y + 5*sinT), (int)(p1.y + 5*sinT)};
+                g.fillPolygon(x, y, 4);
+                g.fillArc(p1.x-5, p1.y-5, 10, 10, deg, 180 );
+                g.fillArc(p2.x-5, p2.y-5, 10, 10, deg, -180);
+            }
+            else
+            {
+                g.drawLine((int)(p1.x + 5*cosT), (int)(p1.y - 5*sinT), (int)(p2.x + 5*cosT), (int)(p2.y - 5*sinT));
+                g.drawLine((int)(p1.x - 5*cosT), (int)(p1.y + 5*sinT), (int)(p2.x - 5*cosT), (int)(p2.y + 5*sinT));
+                g.drawArc(p1.x-5, p1.y-5, 10, 10, deg, 180 );
+                g.drawArc(p2.x-5, p2.y-5, 10, 10, deg, -180);
+            }
+        }
+
+
+        
+        /**
+         * Draw a small rectangle. 
+         * White if selected (as always) or red otherwise.
+         * 
+         * @param n The node to draw.
+         */
+        public void visit(Node n) 
+        {
+            if( isNodeVisible(n) )
+                drawNode(n, severity.getColor());
+        }
+
+        /**
+         * Draw just a line between the points.
+         * White if selected (as always) or green otherwise.
+         */
+        public void visit(Segment ls) 
+        {
+            if( isSegmentVisible(ls) )
+                drawSegment(ls, severity.getColor());
+        }
+        
+        public void visit(Way w)
+        {
+            for (Segment ls : w.segments)
+            {
+                if (isSegmentVisible(ls))
+                {
+                    drawSegment(ls, severity.getColor());
+                }
+            }
+        }
+        
+        /**
+         * Checks if the given node is in the visible area.
+         */
+        protected boolean isNodeVisible(Node n) {
+            Point p = mv.getPoint(n.eastNorth);
+            return !((p.x < 0) || (p.y < 0) || (p.x > mv.getWidth()) || (p.y > mv.getHeight()));
+        }
+
+        /**
+         * Checks if the given segment is in the visible area.
+         * NOTE: This will return true for a small number of non-visible
+         *       segments.
+         */
+        protected boolean isSegmentVisible(Segment ls) {
+            if (ls.incomplete) return false;
+            Point p1 = mv.getPoint(ls.from.eastNorth);
+            Point p2 = mv.getPoint(ls.to.eastNorth);
+            if ((p1.x < 0) && (p2.x < 0)) return false;
+            if ((p1.y < 0) && (p2.y < 0)) return false;
+            if ((p1.x > mv.getWidth()) && (p2.x > mv.getWidth())) return false;
+            if ((p1.y > mv.getHeight()) && (p2.y > mv.getHeight())) return false;
+            return true;
+        }
+    }
+
+    /**
+     * Sets the selection flag of this error
+     * @param selected if this error is selected
+     */
+    public void setSelected(boolean selected)
+    {
+        this.selected = selected;
+    }
 }
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java	(revision 2623)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java	(revision 2672)
@@ -50,5 +50,5 @@
 	 * @param getSelectedItems If selected or last selected items must be validated
 	 */
-	public void doValidate(ActionEvent ev, boolean getSelectedItems)
+	public void doValidate(@SuppressWarnings("unused") ActionEvent ev, boolean getSelectedItems)
 	{
 		OSMValidatorPlugin plugin = OSMValidatorPlugin.getPlugin();
@@ -95,4 +95,7 @@
 		
 		plugin.validationDialog.refresh();
+        Main.map.repaint();
+        Main.ds.fireSelectionChanged(Main.ds.getSelected());
+        
 	}
 }
Index: applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java
===================================================================
--- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java	(revision 2623)
+++ applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java	(revision 2672)
@@ -37,5 +37,5 @@
      * The validation data.
      */
-	private DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
+	protected DefaultTreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
 
 	/**
@@ -47,6 +47,13 @@
      * The fix button
      */
-	private JButton fixButton;
-    
+    private JButton fixButton;
+    
+    /** 
+     * The select button
+     */
+    private JButton selectButton;
+    
+    /** Last selected truee element */
+    private DefaultMutableTreeNode lastSelectedNode = null;
 
     /**
@@ -70,8 +77,10 @@
         JPanel buttonPanel = new JPanel(new GridLayout(1,2));
 
-        buttonPanel.add(Util.createButton("Select", "mapmode/selection/select", "Set the selected elements on the map to the selected items in the list above.", this)); 
-        add(buttonPanel, BorderLayout.SOUTH);
+        selectButton = Util.createButton("Select", "mapmode/selection/select", "Set the selected elements on the map to the selected items in the list above.", this);
+        selectButton.setEnabled(false);
+        buttonPanel.add(selectButton); 
+        //add(buttonPanel, BorderLayout.SOUTH);
         buttonPanel.add(Util.createButton("Validate", "dialogs/refresh", "Validate the data.", this)); 
-        add(buttonPanel, BorderLayout.SOUTH);
+        // add(buttonPanel, BorderLayout.SOUTH);
         fixButton = Util.createButton("Fix", "dialogs/fix", "Fix the selected errors.", this);
         fixButton.setEnabled(false);
@@ -215,7 +224,13 @@
     private void setSelectedItems() 
     {
+        if( tree == null )
+            return;
+        
         Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(40);
 
         TreePath[] selectedPaths = tree.getSelectionPaths();
+        if( selectedPaths == null)
+            return;
+        
         for( TreePath path : selectedPaths)
         {
@@ -267,5 +282,21 @@
 		boolean hasFixes = false;
 
-		DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
+        DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
+        if( lastSelectedNode != null && !lastSelectedNode.equals(node) )
+        {
+            Enumeration<DefaultMutableTreeNode> children = lastSelectedNode.breadthFirstEnumeration();
+            while( children.hasMoreElements() )
+            {
+                DefaultMutableTreeNode childNode = children.nextElement();
+                Object nodeInfo = childNode.getUserObject();
+                if( nodeInfo instanceof TestError)
+                {
+                    TestError error = (TestError)nodeInfo;
+                    error.setSelected(false);
+                }
+            }  
+        }
+        
+        lastSelectedNode = node;
     	if( node == null ) 
     		return hasFixes;
@@ -279,4 +310,6 @@
     		{
     			TestError error = (TestError)nodeInfo;
+                error.setSelected(true);
+                
     			hasFixes = hasFixes || error.isFixable();
     			if( addSelected )
@@ -286,4 +319,5 @@
     		}
 		}
+        selectButton.setEnabled(true);
 		
 		return hasFixes;
@@ -298,15 +332,10 @@
 		public void mouseClicked(MouseEvent e) 
 		{
-	        fixButton.setEnabled(false);
-        	
-			if(e.getSource() instanceof JScrollPane)
-				return;
-        	
-			DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
-        	if( node == null )
-        		return;
-
-	        Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(40);
+            System.out.println("mouseClicked " + e.getClickCount() + " " + e.getSource());
+            fixButton.setEnabled(false);
+            selectButton.setEnabled(false);
+            
 			boolean isDblClick = e.getClickCount() > 1;
+            Collection<OsmPrimitive> sel = isDblClick ? new HashSet<OsmPrimitive>(40) : null;
 			
 			boolean hasFixes = setSelection(sel, isDblClick);
@@ -328,15 +357,17 @@
 		public void valueChanged(TreeSelectionEvent e) 
 		{
+            System.out.println("valueChanged");
 	        fixButton.setEnabled(false);
+            selectButton.setEnabled(false);
         	
 			if(e.getSource() instanceof JScrollPane)
-				return;
+            {
+                System.out.println(e.getSource());
+                return;
+            }
         	
-			DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
-        	if( node == null )
-        		return;
-
 			boolean hasFixes = setSelection(null, false);
 	        fixButton.setEnabled(hasFixes);
+            Main.map.repaint();            
 		}
 	}
