Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilder.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilder.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilder.java	(revision 23571)
@@ -2,4 +2,5 @@
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -11,4 +12,5 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 
@@ -20,94 +22,6 @@
  */
 public class TurnRestrictionBuilder {
-
-    private Way from;
-    private Way to;
-    private final ArrayList<OsmPrimitive> vias = new ArrayList<OsmPrimitive>();
     
     public TurnRestrictionBuilder(){
-    }
-    
-    /**
-     * Initializes the 'from' leg. Proposes the  first element
-     * in {@code primitives} as 'from' leg if this element is a
-     * non-deleted, visible way.
-     * 
-     * @param primitives
-     */
-    protected void initFromLeg(List<OsmPrimitive> primitives){
-        if (primitives == null || primitives.isEmpty()) return;
-        OsmPrimitive p = primitives.get(0);
-        if (! (p instanceof Way)) return;
-        Way fromLeg = (Way)p;
-        if (fromLeg.isDeleted() || ! fromLeg.isVisible()) return;
-        this.from = fromLeg;
-    }
-
-    /**
-     * Initializes the 'to' leg. Proposes the last element 
-     * in {@code primitives} as 'to' leg if this element is a
-     * non-deleted, visible way.
-     *
-     * @param primitives
-     */
-    protected void initToLeg(List<OsmPrimitive> primitives){
-        if (primitives == null || primitives.isEmpty()) return;
-        if (primitives.size() < 2) return;
-        OsmPrimitive p = primitives.get(primitives.size()-1);
-        if (! (p instanceof Way)) return;
-        Way toLeg = (Way)p;
-        if (toLeg.isDeleted() || ! toLeg.isVisible()) return;
-        this.to = toLeg;
-    }
-    
-    /**
-     * Initializes the vias from the two turn restriction legs. The two
-     * legs have to be defined, otherwise no via is proposed. This methods
-     * proposes exactly one node as via, if the two turn restriction
-     * legs intersect at exactly one node. 
-     */
-    protected void initViaFromLegs(){
-        if (from == null || to == null) return;     
-        // check whether 'from' and 'to' have exactly one intersecting 
-        // node. This node is proposed as via node. The turn restriction
-        // node will also provide functionality to split either or both
-        // of 'from' and 'to' way if they aren't connected from tail to
-        // head
-        //
-        HashSet<Node> nodes = new HashSet<Node>();
-        nodes.addAll(from.getNodes());
-        nodes.retainAll(to.getNodes());
-        if (nodes.size() == 1){
-            vias.add(nodes.iterator().next());
-        }       
-    }
-    
-    /**
-     * Initializes the vias with the primitives (1..size-2), provided
-     * these primitives aren't relations and they are visible and non-deleted.
-     * 
-     * @param primitives
-     */
-    protected void initViasFromPrimitives(List<OsmPrimitive> primitives) {
-        if (primitives == null || primitives.size() <=2) return;
-        // if we didn't find a from or a to way, we don't propose via objects
-        // either
-        if (from == null || to == null) return;
-        for(int i=1; i< primitives.size() -2;i++){
-            OsmPrimitive p = primitives.get(i);
-            if (p == null) continue;
-            if (p instanceof Relation) continue;
-            if (p.isDeleted() || ! p.isVisible()) continue;
-            vias.add(p);
-        }
-    }
-    
-    /**
-     * Resets the builder 
-     */
-    protected void reset() {
-        this.from = null;
-        this.to = null;
-        this.vias.clear();
     }
     
@@ -128,4 +42,250 @@
 
     /**
+     * Tries to initialize a No-U-Turn restriction from the primitives in 
+     * <code>primitives</code>. If successful, replies true, otherwise false.
+     * 
+     * @param primitives the primitives 
+     * @return true, if we can propose a U-turn restriction for the primitives
+     * in <code>primitives</code>
+     */
+    protected Relation initNoUTurnRestriction(List<OsmPrimitive> primitives) {
+    	if (primitives.size() != 2) return null;
+    	    	
+    	// we need exactly one node and one way in the selection ...
+    	List<Node> nodes = OsmPrimitive.getFilteredList(primitives, Node.class);
+    	List<Way> ways = OsmPrimitive.getFilteredList(primitives, Way.class);
+    	if (nodes.size() != 1 || ways.size() != 1) return null;
+    	
+    	// .. and the node has to be the start or the node of the way
+    	Way way = ways.get(0);
+    	Node node = nodes.get(0);
+    	List<Node> wayNodes = way.getNodes();
+    	if (wayNodes.size() < 2) return null; // shouldn't happen - just in case
+    	if (! (wayNodes.get(0).equals(node) ||wayNodes.get(wayNodes.size()-1).equals(node))) return null;
+
+    	Relation tr = new Relation();
+    	tr.put("type", "restriction");
+    	tr.addMember(new RelationMember("from", way));
+    	tr.addMember(new RelationMember("to", way));
+    	tr.addMember(new RelationMember("via", node));
+    	tr.put("restriction", TurnRestrictionType.NO_U_TURN.getTagValue());
+    	return tr;    	
+    }
+
+    /**
+     * Replies the unique common node of two ways, or null, if either no
+     * such node or multiple common nodes exist.
+     * 
+     * @param w1 the first way
+     * @param w2 the second way
+     * @return the common node
+     */
+    protected Node getUniqueCommonNode(Way w1, Way w2){
+    	List<Node> w1Nodes = w1.getNodes();
+    	w1Nodes.retainAll(w2.getNodes());
+    	if (w1Nodes.size() != 1) return null;
+    	return w1Nodes.get(0);
+    }    
+    
+    /**
+     * Replies true, if {@code n} is the start node of the way {@code w}.
+     * 
+     * @param w the way 
+     * @param n the node 
+     * @return true, if {@code n} is the start node of the way {@code w}.
+     */
+    protected boolean isStartNode(Way w, Node n) {
+    	if (w.getNodesCount() == 0) return false;
+    	return w.getNode(0).equals(n);
+    }
+    
+    
+    /**
+     * Replies true, if {@code n} is the end node of the way {@code w}.
+     * 
+     * @param w the way 
+     * @param n the node 
+     * @return true, if {@code n} is the end node of the way {@code w}.
+     */
+    protected boolean isEndNode(Way w, Node n){
+    	if (w.getNodesCount() == 0) return false;
+    	return w.getNode(w.getNodesCount()-1).equals(n);
+    }
+    
+    /**
+     * <p>Replies true, if the ways {@code w1} and {@code w2} are connected
+     * at the node {@code n}.</p>
+     * 
+     * <p>If {@code w1} and {@code w2} <em>intersect</em> at the node {@code n},
+     * this method replies false.</p>
+     * 
+     * @param w1 the first way
+     * @param w2 the second way 
+     * @param n the node 
+     * @return
+     */
+    protected boolean isConnectingNode(Way w1, Way w2, Node n){
+    	if (isStartNode(w1, n)) {
+    		return isStartNode(w2, n)  | isEndNode(w2, n);
+    	} else if (isEndNode(w1, n)){
+    		return isStartNode(w2, n)  | isEndNode(w2, n);
+    	}
+    	return false;
+    }
+    
+    /**
+     * Replies true, if the way {@code w} is closed at the node {@code n}.
+     * 
+     * @param w the way
+     * @param n the node 
+     * @return true, if the way {@code w} is closed at the node {@code n}.
+     */
+    protected boolean isClosedAt(Way w, Node n){
+    	List<Node> nodes = w.getNodes();
+    	nodes.retainAll(Collections.singletonList(n));
+    	return nodes.size() >= 2;
+    }
+    
+    protected double phi(Way w) {
+    	return phi(w, false /* not inverse */);
+    }
+    
+    protected double phi(Way w, boolean doInvert) {
+    	double x1 = w.getNode(0).getCoor().getX();
+    	double y1 = w.getNode(0).getCoor().getY();
+    	double x2 = w.getNode(w.getNodesCount()-1).getCoor().getX();
+    	double y2 = w.getNode(w.getNodesCount()-1).getCoor().getY();
+    	if (doInvert){
+    		double t = x1; x1 = x2; x2 = t;
+    		t = y1; y1 = y2; y2 = t;
+    	}
+    	x2-=x1;
+    	y2-=y1;
+    	return phi(x2,y2);    	
+    }
+    
+    protected double phi(double x, double y) {
+    	return Math.atan2(y, x);
+    }   
+    
+    /**
+     * <p>Determines the standard turn restriction between from way {@code w1} to
+     * way {@code w2}.</p>
+     * 
+     * <p>Replies {@link TurnRestrictionType#NO_LEFT_TURN no_left_turn} or 
+     * {@link TurnRestrictionType#NO_RIGHT_TURN no_right_turn}, if applicable. Or
+     * null, if neither of these restrictions is applicable, for instance because
+     * the passed in via node {@code via} isn't a node where the two ways are
+     * connected.</p>
+     * 
+     * @param w1 the "from"-way
+     * @param w2 the "to"-way
+     * @param via the via node
+     * @return an applicable turn restriction, or null, if no turn restriction is
+     * applicable
+     */
+    protected String determineRestriction(Way w1, Way w2, Node via){
+    	if (via == null) return null;
+    	if (!isConnectingNode(w1, w2, via)) return null;
+    	// if either w1 or w2 are closed at the via node, we can't determine automatically
+    	// whether the connection at "via" is a "left turn" or a "right turn"
+    	if (isClosedAt(w1, via)) return null;
+    	if (isClosedAt(w2, via)) return null;
+    	
+    	double phi1 = 0, phi2 = 0;
+    	if (isEndNode(w1, via)){
+    		if (isStartNode(w2, via)) {
+	    		phi1 = phi(w1);
+	    		phi2 = phi(w2);
+    		} else if (isEndNode(w2, via)){
+    			phi1 = phi(w1);
+    			phi2 = phi(w2, true /* reverse it */);
+    		} else {
+    			assert false: "Unexpected state: via node is expected to be a start or and end node";
+    		}	    		
+    	} else if (isStartNode(w1,via)) {
+    		if (isStartNode(w2, via)) {
+	    		phi1 = phi(w1, true /* reverse it */);
+	    		phi2 = phi(w2);
+    		} else if (isEndNode(w2, via)){
+    			phi1 = phi(w1, true /* reverse it */);
+    			phi2 = phi(w2, true /* reverse it */);
+    		} else {
+    			assert false: "Unexpected state: via node is expected to be a start or and end node";
+    		}	    
+    	} else {
+    		assert false: "Unexpected state: via node is expected to be a start or and end node of w1";    		
+    	}
+    	
+    	double phi = phi1-phi2;
+    	if (phi >=0 && phi <= Math.PI) {
+    		// looks like a right turn  
+    		return TurnRestrictionType.NO_RIGHT_TURN.getTagValue();
+    	} else {
+    		// looks like a left turn 
+    		return TurnRestrictionType.NO_LEFT_TURN.getTagValue();
+    	} 
+    }
+    
+    protected Relation initTurnRestrictionFromTwoWays(List<OsmPrimitive> primitives) {
+    	Way w1 = null;
+    	Way w2 = null;
+    	Node via = null;
+    	if (primitives.size() == 2) {
+    		// if we have exactly two selected primitives, we expect two ways. 
+    		// See initNoUTurnRestriction() for the case where we have a selected way
+    		// and a selected node
+    		List<Way> selWays = OsmPrimitive.getFilteredList(primitives, Way.class);
+    		if (selWays.size() != 2) return null;
+    		w1 = selWays.get(0);
+    		w2 = selWays.get(1);
+    		via = getUniqueCommonNode(w1, w2);    		
+    	} else if (primitives.size() == 3){
+    		// if we have exactly three selected primitives, we need two ways and a 
+    		// node, which should be an acceptable via node 
+    		List<Way> selWays = OsmPrimitive.getFilteredList(primitives, Way.class);
+    		List<Node> selNodes = OsmPrimitive.getFilteredList(primitives, Node.class);
+    		if (selWays.size() != 2) return null;
+    		if (selNodes.size() != 1) return null;
+    		w1 = selWays.get(0);
+    		w2 = selWays.get(1);
+    		via = selNodes.get(0);
+    		if (! w1.getNodes().contains(via) || ! w2.getNodes().contains(via)){
+    			// the selected node is not an acceptable via node
+    			via = null;
+    		}
+    	} else {
+    		// the selection doesn't consists of primitives for which we can build
+    		// a turn restriction 
+    		return null;
+    	}
+    	
+    	// if we get here, we know the two "legs" of the turn restriction. We may
+    	// or may not know a via node, though
+    	assert w1 != null;
+    	assert w2 != null;
+    	
+    	Relation tr = new Relation();
+    	tr.put("type", "restriction");
+    	tr.addMember(new RelationMember("from", w1));
+    	tr.addMember(new RelationMember("to", w2));
+    	
+    	if (via != null){
+    		tr.addMember(new RelationMember("via", via));
+    		String restriction = determineRestriction(w1, w2, via); 
+    		if (restriction != null){
+    			tr.put("restriction", restriction);
+    		}
+    	}
+    	return tr;
+    }
+       
+    protected Relation initEmptyTurnRestriction() {
+	   Relation tr = new Relation();
+       tr.put("type", "restriction");
+       return tr;
+    }
+    
+    /**
      * Creates and initializes a new turn restriction based on primitives 
      * in {@code primitives}.
@@ -136,27 +296,31 @@
      */
     public synchronized Relation build(List<OsmPrimitive> primitives){
-        Relation tr = new Relation();
-        tr.put("type", "restriction");
-        if (primitives == null || primitives.isEmpty()) return tr;
-        if (primitives.size() <=2){
-            initFromLeg(primitives);
-            initToLeg(primitives);
-            initViaFromLegs();
-        } else if (primitives.size() > 2) {
-            initFromLeg(primitives);
-            initToLeg(primitives);
-            initViasFromPrimitives(primitives);
+        if (primitives == null || primitives.isEmpty()) {
+        	return initEmptyTurnRestriction();
         }
-        
-        if (from != null){
-            tr.addMember(new RelationMember("from", from));
+        Relation tr;
+        switch(primitives.size()){
+        // case 0 already handled 
+        case 1: 
+        	tr = initEmptyTurnRestriction();
+        	if (OsmPrimitive.getFilteredList(primitives, Way.class).size() == 1) {     
+        		// we have exactly one selected way? -> init the "from" leg
+        		// of the turn restriction with it
+        		tr.addMember(new RelationMember("from", primitives.get(0)));
+        	}
+        	return tr;
+        	
+        case 2:
+        	tr = initNoUTurnRestriction(primitives);
+        	if (tr != null) return tr;
+        	tr = initTurnRestrictionFromTwoWays(primitives);
+        	if (tr != null) return tr;
+        	return initEmptyTurnRestriction();       
+        	
+        default:        	
+        	tr = initTurnRestrictionFromTwoWays(primitives);
+        	if (tr != null) return tr;
+        	return initEmptyTurnRestriction();       
         }
-        if (to != null){
-            tr.addMember(new RelationMember("to", to));
-        }
-        for(OsmPrimitive via: vias){
-            tr.addMember(new RelationMember("via", via));
-        }
-        return tr;
     }       
 }
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModel.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModel.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModel.java	(revision 23571)
@@ -10,4 +10,5 @@
 import javax.swing.AbstractListModel;
 import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
 
 import org.openstreetmap.josm.Main;
@@ -38,5 +39,5 @@
     
     private final List<OsmPrimitive> selection = new ArrayList<OsmPrimitive>();
-    private DefaultListSelectionModel selectionModel;
+    private final DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
     private OsmDataLayer layer;
 
@@ -46,12 +47,9 @@
      * @param selectionModel the selection model used in the list. Must not be null.
      * @param layer the layer this model is displaying the selection from. Must not be null.
-     * @throws IllegalArgumentException thrown if {@code selectionModel} is null
      * @throws IllegalArgumentException thrown if {@code layer} is null
      */
-    public JosmSelectionListModel(OsmDataLayer layer, DefaultListSelectionModel selectionModel) {
-        CheckParameterUtil.ensureParameterNotNull(selectionModel, "selectionModel");
+    public JosmSelectionListModel(OsmDataLayer layer) throws IllegalArgumentException{
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
         this.layer = layer;
-        this.selectionModel = selectionModel;
         setJOSMSelection(layer.data.getSelected());
     }
@@ -118,5 +116,10 @@
         this.selection.addAll(selection);
         fireContentsChanged(this, 0, getSize());       
-        setSelected(sel);
+        setSelected(sel);       
+        // if the user selects exactly one primitive (i.e. a way), we automatically
+        // select it in the list of selected JOSM objects too. 
+        if (getSelected().isEmpty() && this.selection.size() == 1) {
+        	setSelected(this.selection);
+        }
     }
 
@@ -138,4 +141,8 @@
         }
         setSelected(sel);
+    }
+        
+    public ListSelectionModel getListSelectionModel() {
+    	return selectionModel;
     }
 
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionPanel.java	(revision 23571)
@@ -54,9 +54,7 @@
     protected void build(OsmDataLayer layer) {
         setLayout(new BorderLayout());
-        DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
-        model = new JosmSelectionListModel(layer,selectionModel);
         lstSelection = new JList(model);
         lstSelection.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-        lstSelection.setSelectionModel(selectionModel);
+        lstSelection.setSelectionModel(model.getListSelectionModel());
         lstSelection.setCellRenderer(new OsmPrimitivRenderer());
         lstSelection.setTransferHandler(transferHandler = new JosmSelectionTransferHandler(model));
@@ -77,6 +75,7 @@
      * @exception IllegalArgumentException thrown if {@code layer} is null
      */
-    public JosmSelectionPanel(OsmDataLayer layer) throws IllegalArgumentException{
+    public JosmSelectionPanel(OsmDataLayer layer, JosmSelectionListModel model) throws IllegalArgumentException{
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
+        this.model = model;
         build(layer); 
     }
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditor.java	(revision 23571)
@@ -114,10 +114,10 @@
      */
     protected JPanel buildJOSMSelectionPanel() {
-        pnlJosmSelection = new JosmSelectionPanel(layer);
+        pnlJosmSelection = new JosmSelectionPanel(layer,editorModel.getJosmSelectionListModel());
         return pnlJosmSelection;
     }
     
     /**
-     * Builds the panel with the editor masks (the left panel in the split pane of 
+     * Builds the panel with the editor forms (the left panel in the split pane of 
      * this dialog)
      * 
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModel.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModel.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModel.java	(revision 23571)
@@ -69,4 +69,5 @@
     private  IssuesModel issuesModel;
     private NavigationControler navigationControler;
+    private JosmSelectionListModel selectionModel;
     
     /**
@@ -87,4 +88,12 @@
         addObserver(issuesModel);
         tagEditorModel.addTableModelListener(new TagEditorModelObserver());
+        selectionModel = new JosmSelectionListModel(layer);
+    }
+    
+    /**
+     * Replies the model for the currently selected JOSM primitives
+     */
+    public JosmSelectionListModel getJosmSelectionListModel() {
+    	return selectionModel;
     }
     
@@ -211,4 +220,5 @@
         CheckParameterUtil.ensureParameterNotNull(turnRestriction, "turnRestriction");      
         TagCollection tags = tagEditorModel.getTagCollection();
+        logger.info(tags.toString());
         turnRestriction.removeAll();
         tags.applyTo(turnRestriction);
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditor.java	(revision 23571)
@@ -4,4 +4,5 @@
 
 import java.awt.BorderLayout;
+import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.Toolkit;
@@ -38,8 +39,11 @@
 import javax.swing.TransferHandler;
 import javax.swing.UIManager;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
 
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
 import org.openstreetmap.josm.data.osm.PrimitiveId;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.DefaultNameFormatter;
 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
@@ -64,4 +68,5 @@
     private CopyAction actCopy;
     private PasteAction actPaste;
+    private AcceptAction actAccept;
     private TransferHandler transferHandler;
     
@@ -81,10 +86,19 @@
         );
         
+        JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.LEFT,0,0));
+        pnlButtons.setBorder(null);
         JButton btn;
         actDelete = new DeleteAction();
-        add(btn = new JButton(actDelete), BorderLayout.EAST);
+        pnlButtons.add(btn = new JButton(actDelete));
         btn.setFocusable(false);
         btn.setText(null);
         btn.setBorder(BorderFactory.createRaisedBevelBorder());
+        
+        actAccept = new AcceptAction();
+        pnlButtons.add(btn = new JButton(actAccept));
+        btn.setFocusable(false);
+        btn.setText(null);
+        btn.setBorder(BorderFactory.createRaisedBevelBorder());
+        add(pnlButtons, BorderLayout.EAST);
                 
         // focus handling
@@ -260,4 +274,35 @@
     
     /**
+     * Accepts the currently selected way as turn restriction leg. Only enabled,
+     * if there is exactly one way selected 
+     */
+    class AcceptAction extends AbstractAction implements ListSelectionListener {
+    	
+    	public AcceptAction() {
+			 putValue(SHORT_DESCRIPTION, tr("Accept the currently selected way"));
+	         putValue(NAME, tr("Accept"));
+	         putValue(SMALL_ICON, ImageProvider.get("accept"));
+	         model.getJosmSelectionListModel().getListSelectionModel().addListSelectionListener(this);
+	         updateEnabledState();	         
+    	}
+    	
+    	 public void actionPerformed(ActionEvent e) {
+    		 List<Way> selWays = OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class);
+    		 if (selWays.size() != 1) return;
+    		 Way w = selWays.get(0);    		 
+             model.setTurnRestrictionLeg(role, w);            
+         }       
+         
+         public void updateEnabledState() {
+        	setEnabled(OsmPrimitive.getFilteredList(model.getJosmSelectionListModel().getSelected(), Way.class).size() == 1);
+         }
+
+		@Override
+		public void valueChanged(ListSelectionEvent e) {
+			updateEnabledState();
+		}
+    }
+    
+    /**
      * The transfer handler for Drag-and-Drop. 
      */
@@ -366,3 +411,5 @@
         }
     }
+    
+     
 }
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditor.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditor.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditor.java	(revision 23571)
@@ -51,4 +51,6 @@
     private ExceptValueModel exceptValue = new ExceptValueModel();
     
+    private StandardVehicleTypeChangeListener svtChangeListener;
+    
     private JPanel buildMessagePanel() {
         JPanel pnl = new JPanel(new BorderLayout());
@@ -67,5 +69,5 @@
             return pnlStandard;
         
-        StandardVehicleTypeChangeListener changeHandler = new StandardVehicleTypeChangeListener();
+        svtChangeListener = new StandardVehicleTypeChangeListener();
         
         GridBagConstraints gc = new GridBagConstraints();
@@ -78,5 +80,5 @@
         JLabel lbl;
         cbPsv = new JCheckBox();
-        cbPsv.addItemListener(changeHandler);
+        cbPsv.addItemListener(svtChangeListener);
         lbl = new JLabel();
         lbl.setText(tr("Public Service Vehicles"));
@@ -91,5 +93,5 @@
         
         cbHgv = new JCheckBox();
-        cbHgv.addItemListener(changeHandler);
+        cbHgv.addItemListener(svtChangeListener);
         lbl = new JLabel();
         lbl.setText(tr("Heavy Goods Vehicles"));
@@ -104,5 +106,5 @@
 
         cbMotorcar = new JCheckBox();
-        cbMotorcar.addItemListener(changeHandler);
+        cbMotorcar.addItemListener(svtChangeListener);
         lbl = new JLabel();
         lbl.setText(tr("Motorcars"));
@@ -118,5 +120,5 @@
         
         cbBicyle = new JCheckBox();
-        cbBicyle.addItemListener(changeHandler);
+        cbBicyle.addItemListener(svtChangeListener);
         lbl = new JLabel();
         lbl.setText(tr("Bicycles"));
@@ -212,5 +214,5 @@
         bgStandardOrNonStandard.add(rbStandardException);
         
-        StandardNonStandardChangeHander changeHandler = new StandardNonStandardChangeHander();
+        StandardNonStandardChangeHandler changeHandler = new StandardNonStandardChangeHandler();
         rbNonStandardException.addItemListener(changeHandler);
         rbStandardException.addItemListener(changeHandler);
@@ -231,8 +233,15 @@
     
     protected void init() {
-        cbPsv.setSelected(exceptValue.isVehicleException("psv"));
-        cbBicyle.setSelected(exceptValue.isVehicleException("bicycle"));
-        cbMotorcar.setSelected(exceptValue.isVehicleException("motorcar"));
-        cbHgv.setSelected(exceptValue.isVehicleException("hgv"));
+    	try {
+    		// temporarily disable the checkbox listeners while initializing the
+    		// checkboxes with the input value
+    		this.svtChangeListener.setEnabled(false);
+	        cbPsv.setSelected(exceptValue.isVehicleException("psv"));
+	        cbBicyle.setSelected(exceptValue.isVehicleException("bicycle"));
+	        cbMotorcar.setSelected(exceptValue.isVehicleException("motorcar"));
+	        cbHgv.setSelected(exceptValue.isVehicleException("hgv"));
+    	} finally {
+    		this.svtChangeListener.setEnabled(true);
+    	}
         if (!exceptValue.isStandard()){
             rbNonStandardException.setSelected(true);
@@ -285,5 +294,5 @@
     /* inner classes                                                                        */
     /* ------------------------------------------------------------------------------------ */
-    class StandardNonStandardChangeHander implements ItemListener {
+    class StandardNonStandardChangeHandler implements ItemListener {
         public void itemStateChanged(ItemEvent e) {
             if (rbNonStandardException.isSelected()){
@@ -301,9 +310,16 @@
     
     class StandardVehicleTypeChangeListener implements ItemListener {
-        public void itemStateChanged(ItemEvent e) {
+    	private boolean enabled = true;
+    	
+    	public void setEnabled(boolean enabled){
+    		this.enabled = enabled;
+    	}
+    	
+        public void itemStateChanged(ItemEvent e) {        	
+        	if (!enabled) return;
             exceptValue.setVehicleException("bicycle", cbBicyle.isSelected());
             exceptValue.setVehicleException("hgv", cbHgv.isSelected());
             exceptValue.setVehicleException("psv", cbPsv.isSelected());
-            exceptValue.setVehicleException("motorcar", cbMotorcar.isSelected());
+            exceptValue.setVehicleException("motorcar", cbMotorcar.isSelected());            
             model.setExcept(exceptValue);
         }
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesModel.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesModel.java	(revision 23526)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesModel.java	(revision 23571)
@@ -22,10 +22,10 @@
 
 /**
- * IssuesModel is a model for an observable list of {@code Issues}
- * related to turn restriction.
+ * <p>IssuesModel is a model for an observable list of {@code Issues}
+ * related to turn restriction.</p>
  * 
- * It is also an {@see Observer} to an {@see TurnRestrictionEditorModel}
+ * <p>It is also an {@link Observer} to an {@link TurnRestrictionEditorModel}
  * and populates itself with issues it derives from the current state
- * in the {@see TurnRestrictionEditorModel}.
+ * in the {@link TurnRestrictionEditorModel}.</p>
  *  
  */
@@ -36,8 +36,4 @@
     /**
      * Creates the model 
-     * 
-     * {@code controler} is used in resolution actions for issues in
-     * this model to direct the user to a specific input field in one
-     * of the editor tabs in order to fix an issue. 
      * 
      * @param editorModel the editor model. Must not be null.
@@ -224,14 +220,19 @@
                 issues.add(new IntersectionMissingAsViaError(this, from, to, intersect));
             }
-        }
-        
-        // 'from' intersects with 'to' - should be split  
-        if (intersect != null && from.getNode(0) != intersect && from.getNode(from.getNodesCount()-1) != intersect){
-            issues.add(new TurnRestrictionLegSplitRequiredError(this, TurnRestrictionLegRole.FROM, from, to, intersect));
-        }
-        // 'to' intersects with 'from' - should be split
-        if (intersect != null && to.getNode(0) != intersect && to.getNode(to.getNodesCount()-1) != intersect){
-            issues.add(new TurnRestrictionLegSplitRequiredError(this, TurnRestrictionLegRole.TO, from, to, intersect));
-        }       
+            // 'from' intersects with 'to' - should be split  
+            if (from.getNode(0) != intersect && from.getNode(from.getNodesCount()-1) != intersect){
+                issues.add(new TurnRestrictionLegSplitRequiredError(this, TurnRestrictionLegRole.FROM, from, to, intersect));
+            }
+            // 'to' intersects with 'from' - should be split
+            if (to.getNode(0) != intersect && to.getNode(to.getNodesCount()-1) != intersect){
+                issues.add(new TurnRestrictionLegSplitRequiredError(this, TurnRestrictionLegRole.TO, from, to, intersect));
+            }                  
+        } else {
+        	if (editorModel.getVias().isEmpty() && ! from.equals(to)){
+        		// the two turn restriction legs aren't connected and we don't have configured
+        		// via objects 
+        		issues.add(new MissingViaError(this));
+        	}        	
+        }               
     }
     
Index: applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/MissingViaError.java
===================================================================
--- applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/MissingViaError.java	(revision 23571)
+++ applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/qa/MissingViaError.java	(revision 23571)
@@ -0,0 +1,39 @@
+package org.openstreetmap.josm.plugins.turnrestrictions.qa;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+
+/**
+ * Issue if the legs of a turn restriction aren't connected and if there 
+ * are no via objects configured. 
+ * 
+ */
+public class MissingViaError extends Issue {
+
+	public MissingViaError(IssuesModel parent) throws IllegalArgumentException {
+		super(parent, Severity.WARNING);
+		actions.add(new FixAction());
+	}
+
+	@Override
+	public String getText() {
+		 String msg = 
+			 tr("The two ways participating in the turn restriction <strong>aren''t connected.</strong>")
+			+ "<p>"
+			+ tr("Make sure you add one or more via objects (nodes or ways) to the turn restriction.");
+		 return msg;
+	}
+
+	class FixAction extends AbstractAction {
+        public FixAction() {
+            putValue(NAME, tr("Fix in editor"));
+            putValue(SHORT_DESCRIPTION, tr("Go to the Advanced Editor and add via objects"));
+        }
+        public void actionPerformed(ActionEvent e) {
+            getIssuesModel().getNavigationControler().gotoAdvancedEditor();
+        }       
+    }
+}
