Index: trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java	(revision 763)
+++ trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java	(revision 764)
@@ -14,7 +14,9 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.ChangeCommand;
+import org.openstreetmap.josm.command.ChangePropertyCommand;
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.corrector.ReverseWayTagCorrector;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.Node;
@@ -25,29 +27,36 @@
 public final class ReverseWayAction extends JosmAction {
 
-    public ReverseWayAction() {
-    	super(tr("Reverse ways"), "wayflip",
-			tr("Reverse the direction of all selected ways."),
-			KeyEvent.VK_R, 0, true);
-    }
+	public ReverseWayAction() {
+		super(tr("Reverse ways"), "wayflip",
+		        tr("Reverse the direction of all selected ways."),
+		        KeyEvent.VK_R, 0, true);
+	}
 
 	public void actionPerformed(ActionEvent e) {
-    	final Collection<Way> sel = new LinkedList<Way>();
-    	new Visitor(){
-			public void visit(Node n)    {}
-			public void visit(Way w)     {sel.add(w);}
-			public void visit(Relation e){}
+		final Collection<Way> sel = new LinkedList<Way>();
+		new Visitor() {
+			public void visit(Node n) {
+			}
+
+			public void visit(Way w) {
+				sel.add(w);
+			}
+
+			public void visit(Relation e) {
+			}
+
 			public void visitAll() {
 				for (OsmPrimitive osm : Main.ds.getSelected())
 					osm.visit(this);
 			}
-    	}.visitAll();
+		}.visitAll();
 
-    	if (sel.isEmpty()) {
-    		JOptionPane.showMessageDialog(Main.parent,
-				tr("Please select at least one way."));
-    		return;
-    	}
+		if (sel.isEmpty()) {
+			JOptionPane.showMessageDialog(Main.parent,
+			        tr("Please select at least one way."));
+			return;
+		}
 
-    	boolean propertiesUpdated = false;
+		boolean propertiesUpdated = false;
 		ReverseWayTagCorrector reverseWayTagCorrector = new ReverseWayTagCorrector();
 		Collection<Command> c = new LinkedList<Command>();
@@ -55,12 +64,18 @@
 			Way wnew = new Way(w);
 			Collections.reverse(wnew.nodes);
-			if (Main.pref.getBoolean("tag-correction.reverse-way", true))
-				propertiesUpdated = reverseWayTagCorrector.execute(wnew) || propertiesUpdated;
+			if (Main.pref.getBoolean("tag-correction.reverse-way", true)) {
+				final Collection<ChangePropertyCommand> changePropertyCommands = reverseWayTagCorrector
+				        .execute(wnew);
+				propertiesUpdated = propertiesUpdated
+				        || (changePropertyCommands != null && !changePropertyCommands
+				                .isEmpty());
+				c.addAll(changePropertyCommands);
+			}
 			c.add(new ChangeCommand(w, wnew));
 		}
 		Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), c));
 		if (propertiesUpdated)
-			Main.ds.fireSelectionChanged(Main.ds.getSelected());
+			DataSet.fireSelectionChanged(Main.ds.getSelected());
 		Main.map.repaint();
-    }
+	}
 }
Index: trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java	(revision 763)
+++ trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java	(revision 764)
@@ -5,7 +5,13 @@
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.openstreetmap.josm.command.ChangePropertyCommand;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.Way;
@@ -13,51 +19,87 @@
 public class ReverseWayTagCorrector extends TagCorrector<Way> {
 
-	private static final Pattern leftRightStartRegex = Pattern.compile(
-	        "^(left|right):.*", Pattern.CASE_INSENSITIVE);
+	private static class PrefixSuffixSwitcher {
 
-	private static final Pattern leftRightEndRegex = Pattern.compile(
-	        ".*:(left|right)$", Pattern.CASE_INSENSITIVE);
+		private final String a;
 
-	@Override public boolean execute(Way way) {
+		private final String b;
 
-		ArrayList<TagCorrection> tagCorrections = new ArrayList<TagCorrection>();
+		private final Pattern startPattern;
 
-		for (String key : way.keySet()) {
-			String newKey = key;
-			String value = way.get(key);
-			String newValue = value;
+		private final Pattern endPattern;
 
-			if (key.equals("oneway")) {
-				if (value.equals("-1"))
-					newValue = OsmUtils.trueval;
-				else {
-					Boolean boolValue = OsmUtils.getOsmBoolean(value);
-					if (boolValue != null && boolValue.booleanValue()) {
-						newValue = "-1";
+		public PrefixSuffixSwitcher(String a, String b) {
+			this.a = a;
+			this.b = b;
+			startPattern = Pattern.compile("^(" + a + "|" + b + "):.*",
+			        Pattern.CASE_INSENSITIVE);
+			endPattern = Pattern.compile(".*:(" + a + "|" + b + ")$",
+			        Pattern.CASE_INSENSITIVE);
+		}
+
+		public String apply(String text) {
+			Matcher m = startPattern.matcher(text);
+			if (!m.matches())
+				m = endPattern.matcher(text);
+
+			if (m.matches()) {
+				String leftRight = m.group(1).toLowerCase();
+
+				return text.substring(0, m.start(1)).concat(
+				        leftRight.equals(a) ? b : a).concat(
+				        text.substring(m.end(1)));
+			}
+			return text;
+		}
+	}
+
+	private static PrefixSuffixSwitcher[] prefixSuffixSwitchers = new PrefixSuffixSwitcher[] {
+	        new PrefixSuffixSwitcher("left", "right"),
+	        new PrefixSuffixSwitcher("forward", "backward") };
+
+	@Override public Collection<ChangePropertyCommand> execute(Way way) {
+
+		Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = new HashMap<OsmPrimitive, List<TagCorrection>>();
+
+		ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
+		primitives.add(way);
+		primitives.addAll(way.nodes);
+
+		for (OsmPrimitive primitive : primitives) {
+
+			tagCorrectionsMap.put(primitive, new ArrayList<TagCorrection>());
+
+			for (String key : primitive.keySet()) {
+				String newKey = key;
+				String value = primitive.get(key);
+				String newValue = value;
+
+				if (key.equals("oneway")) {
+					if (value.equals("-1"))
+						newValue = OsmUtils.trueval;
+					else {
+						Boolean boolValue = OsmUtils.getOsmBoolean(value);
+						if (boolValue != null && boolValue.booleanValue()) {
+							newValue = "-1";
+						}
+					}
+				} else {
+					for (PrefixSuffixSwitcher prefixSuffixSwitcher : prefixSuffixSwitchers) {
+						newKey = prefixSuffixSwitcher.apply(key);
+						if (!key.equals(newKey))
+							break;
 					}
 				}
-			} else {
-				Matcher m = leftRightStartRegex.matcher(key);
-				if (!m.matches())
-					m = leftRightEndRegex.matcher(key);
 
-				if (m.matches()) {
-					String leftRight = m.group(1).toLowerCase();
-
-					newKey = key.substring(0, m.start(1)).concat(
-					        leftRight.equals("left") ? "right" : "left")
-					        .concat(key.substring(m.end(1)));
-				}
+				if (!key.equals(newKey) || !value.equals(newValue))
+					tagCorrectionsMap.get(primitive).add(
+					        new TagCorrection(key, value, newKey, newValue));
 			}
-
-			if (key != newKey || value != newValue)
-				tagCorrections.add(new TagCorrection(key, value, newKey,
-				        newValue));
 		}
 
-		return applyCorrections(tagCorrections, way,
-		        tr("When reverting this way, following changes to the "
-		                + "properties are suggested in order to maintain "
-		                + "data consistency."));
+		return applyCorrections(tagCorrectionsMap,
+		        tr("When reverting this way, following changes to properties "
+		                + "of the way and its nodes are suggested in order "
+		                + "to maintain data consistency."));
 	}
 }
Index: trunk/src/org/openstreetmap/josm/corrector/TagCorrectionTable.java
===================================================================
--- trunk/src/org/openstreetmap/josm/corrector/TagCorrectionTable.java	(revision 763)
+++ trunk/src/org/openstreetmap/josm/corrector/TagCorrectionTable.java	(revision 764)
@@ -13,5 +13,5 @@
 public class TagCorrectionTable extends JTable {
 
-	public class BoldRenderer extends JLabel implements TableCellRenderer {
+	public static class BoldRenderer extends JLabel implements TableCellRenderer {
 
 		public Component getTableCellRendererComponent(JTable table,
@@ -30,9 +30,6 @@
 	private static TableCellRenderer boldRenderer = null;
 
-	private static TagCorrectionTableModel tagCorrectionTableModel;
-
 	public static TagCorrectionTable create(List<TagCorrection> tagCorrections) {
-
-		tagCorrectionTableModel = new TagCorrectionTableModel(tagCorrections);
+		TagCorrectionTableModel tagCorrectionTableModel = new TagCorrectionTableModel(tagCorrections);
 		TagCorrectionTable table = new TagCorrectionTable(
 		        tagCorrectionTableModel);
@@ -46,5 +43,5 @@
 
 	public TableCellRenderer getCellRenderer(int row, int column) {
-		TagCorrection tagCorrection = tagCorrectionTableModel.tagCorrections
+		TagCorrection tagCorrection = getTagCorrectionTableModel().tagCorrections
 		        .get(row);
 		if ((column == 2 && tagCorrection.isKeyChanged())
@@ -62,5 +59,5 @@
 
 	public TagCorrectionTableModel getTagCorrectionTableModel() {
-		return tagCorrectionTableModel;
+		return (TagCorrectionTableModel) getModel();
 	}
 
Index: trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java	(revision 763)
+++ trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java	(revision 764)
@@ -4,7 +4,11 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.Dimension;
 import java.awt.GridBagLayout;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.swing.JLabel;
@@ -14,5 +18,7 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.command.ChangePropertyCommand;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
 import org.openstreetmap.josm.gui.JMultilineLabel;
 import org.openstreetmap.josm.tools.GBC;
@@ -20,28 +26,55 @@
 public abstract class TagCorrector<P extends OsmPrimitive> {
 
-	public abstract boolean execute(P primitive);
+	public abstract Collection<ChangePropertyCommand> execute(P primitive);
 
-	protected boolean applyCorrections(List<TagCorrection> tagCorrections,
-	        P primitive, String description) {
+	protected Collection<ChangePropertyCommand> applyCorrections(
+	        Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap,
+	        String description) {
 
-		boolean updated = false;
+		boolean hasCorrections = false;
+		for (List<TagCorrection> tagCorrectionList : tagCorrectionsMap.values()) {
+			if (!tagCorrectionList.isEmpty()) {
+				hasCorrections = true;
+				break;
+			}
+		}
 
-		if (tagCorrections != null && tagCorrections.size() > 0) {
+		if (hasCorrections) {
+			Collection<ChangePropertyCommand> changePropertyCommands = new ArrayList<ChangePropertyCommand>();
+			Map<OsmPrimitive, TagCorrectionTable> tableMap = new HashMap<OsmPrimitive, TagCorrectionTable>();
+			NameVisitor nameVisitor = new NameVisitor();
 
-			final TagCorrectionTable table = TagCorrectionTable
-			        .create(tagCorrections);
-			final JScrollPane scrollPane = new JScrollPane(table);
-
-	    	final JPanel p = new JPanel(new GridBagLayout());
+			final JPanel p = new JPanel(new GridBagLayout());
 
 			final JMultilineLabel label1 = new JMultilineLabel(description);
 			label1.setMaxWidth(400);
 			p.add(label1, GBC.eop());
-			
-			final JMultilineLabel label2 = new JMultilineLabel(tr("Please select which property changes you want to apply."));
+
+			final JMultilineLabel label2 = new JMultilineLabel(
+			        tr("Please select which property changes you want to apply."));
 			label2.setMaxWidth(400);
 			p.add(label2, GBC.eop());
-	    	p.add(scrollPane, GBC.eol());
-			
+
+			for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) {
+				final List<TagCorrection> tagCorrections = tagCorrectionsMap
+				        .get(primitive);
+
+				if (tagCorrections.isEmpty())
+					continue;
+
+				final TagCorrectionTable table = TagCorrectionTable
+				        .create(tagCorrections);
+				final JScrollPane scrollPane = new JScrollPane(table);
+				tableMap.put(primitive, table);
+
+				primitive.visit(nameVisitor);
+
+				final JLabel label3 = new JLabel(nameVisitor.name + ":",
+				        nameVisitor.icon, JLabel.LEFT);
+
+				p.add(label3, GBC.eol());
+				p.add(scrollPane, GBC.eop());
+			}
+
 			int answer = JOptionPane.showConfirmDialog(Main.parent, p,
 			        tr("Automatic tag correction"),
@@ -49,19 +82,28 @@
 
 			if (answer == JOptionPane.OK_OPTION) {
-				for (int i = 0; i < tagCorrections.size(); i++) {
-					if (table.getTagCorrectionTableModel().getApply(i)) {
-						TagCorrection tagCorrection = tagCorrections.get(i);
-						if (tagCorrection.isKeyChanged())
-							primitive.remove(tagCorrection.oldKey);
-						primitive.put(tagCorrection.newKey, tagCorrection
-						        .newValue);
-						updated = true;
+				for (OsmPrimitive primitive : tagCorrectionsMap.keySet()) {
+					List<TagCorrection> tagCorrections = tagCorrectionsMap
+					        .get(primitive);
+					for (int i = 0; i < tagCorrections.size(); i++) {
+						if (tableMap.get(primitive)
+						        .getTagCorrectionTableModel().getApply(i)) {
+							TagCorrection tagCorrection = tagCorrections.get(i);
+							if (tagCorrection.isKeyChanged())
+								changePropertyCommands
+								        .add(new ChangePropertyCommand(
+								                primitive,
+								                tagCorrection.oldKey, null));
+							changePropertyCommands
+							        .add(new ChangePropertyCommand(primitive,
+							                tagCorrection.newKey,
+							                tagCorrection.newValue));
+						}
 					}
 				}
 			}
+			return changePropertyCommands;
 		}
 
-		return updated;
+		return Collections.emptyList();
 	}
-
 }
