Index: /trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/Main.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/Main.java	(revision 1857)
@@ -41,4 +41,5 @@
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.SplashScreen;
 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
@@ -279,5 +280,10 @@
             Main.proj = (Projection)Class.forName(name).newInstance();
         } catch (final Exception e) {
-            JOptionPane.showMessageDialog(null, tr("The projection {0} could not be activated. Using Mercator", name));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("The projection {0} could not be activated. Using Mercator", name),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
             Main.proj = new Mercator();
         }
@@ -416,5 +422,10 @@
             final Bounds b = OsmUrlToBounds.parse(s);
             if (b == null) {
-                JOptionPane.showMessageDialog(Main.parent, tr("Ignoring malformed URL: \"{0}\"", s));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("Ignoring malformed URL: \"{0}\"", s),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE
+                );
             } else {
                 //DownloadTask osmTask = main.menu.download.downloadTasks.get(0);
@@ -429,5 +440,10 @@
                 main.menu.openFile.openFile(new File(new URI(s)));
             } catch (URISyntaxException e) {
-                JOptionPane.showMessageDialog(Main.parent, tr("Ignoring malformed file URL: \"{0}\"", s));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("Ignoring malformed file URL: \"{0}\"", s),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE
+                );
             }
             return;
Index: /trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java	(revision 1857)
@@ -231,5 +231,10 @@
         } catch (IOException x) {
             x.printStackTrace();
-            JOptionPane.showMessageDialog(Main.parent, tr("Error while exporting {0}:\n{1}", fn,x.getMessage()), tr("Error"), JOptionPane.ERROR_MESSAGE);
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("Error while exporting {0}:\n{1}", fn,x.getMessage()),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
         }
     }
@@ -285,5 +290,11 @@
                 l.setVisibleRowCount(4);
                 l.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-                int answer = JOptionPane.showConfirmDialog(Main.parent, new JScrollPane(l),tr("Choose a predefined license"), JOptionPane.OK_CANCEL_OPTION);
+                int answer = OptionPaneUtil.showConfirmationDialog(
+                        Main.parent,
+                        new JScrollPane(l),
+                        tr("Choose a predefined license"),
+                        JOptionPane.OK_CANCEL_OPTION,
+                        JOptionPane.QUESTION_MESSAGE
+                );
                 if (answer != JOptionPane.OK_OPTION || l.getSelectedIndex() == -1)
                     return;
Index: /trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java	(revision 1857)
@@ -37,4 +37,5 @@
 import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.Pair;
@@ -72,5 +73,5 @@
 
         if (selectedNodes.size() < 2) {
-            JOptionPane.showMessageDialog(
+            OptionPaneUtil.showMessageDialog(
                     Main.parent,
                     tr("Please select at least two nodes to merge."),
@@ -249,7 +250,11 @@
                 w.visit(backRefs);
                 if (!backRefs.data.isEmpty()) {
-                    JOptionPane.showMessageDialog(Main.parent,
+                    OptionPaneUtil.showMessageDialog(
+                            Main.parent,
                             tr("Cannot merge nodes: " +
-                            "Would have to delete a way that is still used."));
+                            "Would have to delete a way that is still used."),
+                            tr("Warning"),
+                            JOptionPane.WARNING_MESSAGE
+                    );
                     return null;
                 }
Index: /trunk/src/org/openstreetmap/josm/actions/MirrorAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/MirrorAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/MirrorAction.java	(revision 1857)
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.tools.Shortcut;
 
@@ -49,5 +50,5 @@
 
         if (nodes.size() == 0) {
-            JOptionPane.showMessageDialog(
+            OptionPaneUtil.showMessageDialog(
                     Main.parent,
                     tr("Please select at least one node or way."),
Index: /trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java	(revision 1857)
@@ -106,5 +106,10 @@
                 }
                 if(delta < Math.PI/4) {
-                    JOptionPane.showMessageDialog(Main.parent, tr("Please select ways with almost right angles to orthogonalize."));
+                    OptionPaneUtil.showMessageDialog(
+                            Main.parent,
+                            tr("Please select ways with almost right angles to orthogonalize."),
+                            tr("Information"),
+                            JOptionPane.INFORMATION_MESSAGE
+                    );
                     return;
                 }
Index: /trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java	(revision 1857)
@@ -87,9 +87,14 @@
     public boolean checkSaveConditions(Layer layer) {
         if (layer == null) {
-            JOptionPane.showMessageDialog(Main.parent, tr("Internal Error: cannot check conditions for no layer. Please report this as a bug."));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("Internal Error: cannot check conditions for no layer. Please report this as a bug."),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
             return false;
         }
         if (Main.map == null) {
-            JOptionPane.showMessageDialog(
+            OptionPaneUtil.showMessageDialog(
                     Main.parent,
                     tr("No document open so nothing to save."),
@@ -271,5 +276,10 @@
         } catch (IOException e) {
             e.printStackTrace();
-            JOptionPane.showMessageDialog(Main.parent, tr("An error occurred while saving.")+"\n"+e.getMessage());
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("An error occurred while saving. Error is: {0}", e.getMessage()),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
         }
         try {
Index: /trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java	(revision 1857)
@@ -31,4 +31,5 @@
 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
 import org.openstreetmap.josm.data.osm.visitor.Visitor;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -65,5 +66,10 @@
 
         if (!checkSelection(selection)) {
-            JOptionPane.showMessageDialog(Main.parent, tr("The current selection cannot be used for splitting."));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("The current selection cannot be used for splitting."),
+                    tr("Warning"),
+                    JOptionPane.WARNING_MESSAGE
+            );
             return;
         }
@@ -117,8 +123,10 @@
             }
             if (wayOccurenceCounter.isEmpty()) {
-                JOptionPane.showMessageDialog(Main.parent,
+                OptionPaneUtil.showMessageDialog(Main.parent,
                         trn("The selected node is not in the middle of any way.",
                                 "The selected nodes are not in the middle of any way.",
-                                selectedNodes.size()));
+                                selectedNodes.size()),
+                                tr("Warning"),
+                                JOptionPane.WARNING_MESSAGE);
                 return;
             }
@@ -127,8 +135,10 @@
                 if (entry.getValue().equals(selectedNodes.size())) {
                     if (selectedWay != null) {
-                        JOptionPane.showMessageDialog(Main.parent,
+                        OptionPaneUtil.showMessageDialog(Main.parent,
                                 trn("There is more than one way using the node you selected. Please select the way also.",
                                         "There is more than one way using the nodes you selected. Please select the way also.",
-                                        selectedNodes.size()));
+                                        selectedNodes.size()),
+                                        tr("Warning"),
+                                        JOptionPane.WARNING_MESSAGE);
                         return;
                     }
@@ -138,6 +148,8 @@
 
             if (selectedWay == null) {
-                JOptionPane.showMessageDialog(Main.parent,
-                        tr("The selected nodes do not share the same way."));
+                OptionPaneUtil.showMessageDialog(Main.parent,
+                        tr("The selected nodes do not share the same way."),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE);
                 return;
             }
@@ -151,8 +163,10 @@
             }
             if (!nds.isEmpty()) {
-                JOptionPane.showMessageDialog(Main.parent,
+                OptionPaneUtil.showMessageDialog(Main.parent,
                         trn("The selected way does not contain the selected node.",
                                 "The selected way does not contain all the selected nodes.",
-                                selectedNodes.size()));
+                                selectedNodes.size()),
+                                tr("Warning"),
+                                JOptionPane.WARNING_MESSAGE);
                 return;
             }
@@ -219,5 +233,9 @@
                 && !nodeSet.contains(wayChunks.get(0).get(0))) {
             if (wayChunks.size() == 2) {
-                JOptionPane.showMessageDialog(Main.parent, tr("You must select two or more nodes to split a circular way."));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("You must select two or more nodes to split a circular way."),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE);
                 return;
             }
@@ -230,7 +248,15 @@
         if (wayChunks.size() < 2) {
             if(wayChunks.get(0).get(0) == wayChunks.get(0).get(wayChunks.get(0).size()-1)) {
-                JOptionPane.showMessageDialog(Main.parent, tr("You must select two or more nodes to split a circular way."));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("You must select two or more nodes to split a circular way."),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE);
             } else {
-                JOptionPane.showMessageDialog(Main.parent, tr("The way cannot be split at the selected nodes. (Hint: Select nodes in the middle of the way.)"));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("The way cannot be split at the selected nodes. (Hint: Select nodes in the middle of the way.)"),
+                        tr("Warning"),
+                        JOptionPane.WARNING_MESSAGE);
             }
             return;
@@ -321,7 +347,15 @@
         }
         if(warnmerole) {
-            JOptionPane.showMessageDialog(Main.parent, tr("A role based relation membership was copied to all new ways.\nYou should verify this and correct it when necessary."));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("<html>A role based relation membership was copied to all new ways.<br>You should verify this and correct it when necessary.</html>"),
+                    tr("Warning"),
+                    JOptionPane.WARNING_MESSAGE);
         } else if(warnme) {
-            JOptionPane.showMessageDialog(Main.parent, tr("A relation membership was copied to all new ways.\nYou should verify this and correct it when necessary."));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("<html>A relation membership was copied to all new ways.<br>You should verify this and correct it when necessary.</html>"),
+                    tr("Warning"),
+                    JOptionPane.WARNING_MESSAGE);
         }
 
Index: /trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java	(revision 1857)
@@ -27,4 +27,5 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.tools.Shortcut;
 
@@ -131,5 +132,9 @@
 
         if(errMsg != null) {
-            JOptionPane.showMessageDialog(Main.parent, errMsg);
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    errMsg,
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE);
         }
 
Index: /trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java	(revision 1857)
@@ -15,4 +15,5 @@
 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTaskList;
 import org.openstreetmap.josm.data.osm.DataSource;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
@@ -73,5 +74,5 @@
 
         if(bboxCount == 0) {
-            JOptionPane.showMessageDialog(
+            OptionPaneUtil.showMessageDialog(
                     Main.parent,
                     tr("No data to update found. Have you already opened or downloaded a data layer?"),
Index: /trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java	(revision 1857)
@@ -17,4 +17,5 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -205,5 +206,5 @@
         Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
         if (selection.size() == 0) {
-            JOptionPane.showMessageDialog(
+            OptionPaneUtil.showMessageDialog(
                     Main.parent,
                     tr("There are no selected primitives to update."),
Index: /trunk/src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 1857)
@@ -26,4 +26,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
@@ -174,5 +175,10 @@
         ConflictCollection conflicts = Main.map.mapView.getEditLayer().getConflicts();
         if (conflicts !=null && !conflicts.isEmpty()) {
-            JOptionPane.showMessageDialog(Main.parent,tr("There are unresolved conflicts. You have to resolve these first."));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("There are unresolved conflicts. You have to resolve these first."),
+                    tr("Warning"),
+                    JOptionPane.WARNING_MESSAGE
+            );
             Main.map.conflictDialog.action.button.setSelected(true);
             Main.map.conflictDialog.action.actionPerformed(null);
Index: /trunk/src/org/openstreetmap/josm/actions/search/SelectionWebsiteLoader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/search/SelectionWebsiteLoader.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/actions/search/SelectionWebsiteLoader.java	(revision 1857)
@@ -20,4 +20,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.io.OsmIdReader;
@@ -59,20 +60,31 @@
         } catch (IOException e) {
             e.printStackTrace();
-            JOptionPane.showMessageDialog(Main.parent, tr("Could not read from URL: \"{0}\"",url));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("Could not read from URL: \"{0}\"",url),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
         } catch (SAXException e) {
             e.printStackTrace();
-            JOptionPane.showMessageDialog(Main.parent,tr("Parsing error in URL: \"{0}\"",url));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("Parsing error in URL: \"{0}\"",url),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
         } catch(OsmTransferException e) {
             e.printStackTrace();
             if (e.getCause() != null) {
                 if (e.getCause() instanceof IOException ) {
-                    JOptionPane.showMessageDialog(Main.parent, tr("Could not read from URL: \"{0}\"",url),
+                    OptionPaneUtil.showMessageDialog(
+                            Main.parent, tr("Could not read from URL: \"{0}\"",url),
                             tr("Error"), JOptionPane.ERROR_MESSAGE);
                 } else if (e.getCause() instanceof SAXException) {
-                    JOptionPane.showMessageDialog(Main.parent,tr("Parsing error in URL: \"{0}\"",url),
+                    OptionPaneUtil.showMessageDialog(Main.parent,tr("Parsing error in URL: \"{0}\"",url),
                             tr("Error"), JOptionPane.ERROR_MESSAGE);
                 }
             } else {
-                JOptionPane.showMessageDialog(Main.parent,tr("Error while communicating with server.",url),
+                OptionPaneUtil.showMessageDialog(Main.parent,tr("Error while communicating with server.",url),
                         tr("Error"), JOptionPane.ERROR_MESSAGE);
             }
Index: /trunk/src/org/openstreetmap/josm/command/AddCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/AddCommand.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/command/AddCommand.java	(revision 1857)
@@ -13,4 +13,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.tools.ImageProvider;
 
@@ -35,4 +36,12 @@
     public AddCommand(OsmPrimitive osm) {
         super();
+        this.osm = osm;
+    }
+
+    /**
+     * Create the command and specify the element to add.
+     */
+    public AddCommand(OsmDataLayer layer, OsmPrimitive osm) {
+        super(layer);
         this.osm = osm;
     }
Index: /trunk/src/org/openstreetmap/josm/command/ConflictAddCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/ConflictAddCommand.java	(revision 1857)
+++ /trunk/src/org/openstreetmap/josm/command/ConflictAddCommand.java	(revision 1857)
@@ -0,0 +1,80 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.command;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.Collection;
+
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.text.html.Option;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.MutableTreeNode;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.conflict.Conflict;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
+import org.openstreetmap.josm.gui.PrimitiveNameFormatter;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.tools.ImageProvider;
+
+public class ConflictAddCommand extends Command {
+    private Conflict<? extends OsmPrimitive> conflict;
+
+    public ConflictAddCommand(OsmDataLayer layer, Conflict<? extends OsmPrimitive> conflict) {
+        super(layer);
+        this.conflict  = conflict;
+    }
+
+    protected void warnBecauseOfDoubleConflict() {
+        OptionPaneUtil.showMessageDialog(
+                Main.parent,
+                tr("<html>Layer ''{0}'' already has a conflict for primitive<br>"
+                        + "''{1}''.<br>"
+                        + "This conflict can't be added.</html>",
+                        getLayer().getName(),
+                        new PrimitiveNameFormatter().getName(conflict.getMy())
+                ),
+                tr("Double conflict"),
+                JOptionPane.ERROR_MESSAGE
+        );
+    }
+    @Override public boolean executeCommand() {
+        try {
+            getLayer().getConflicts().add(conflict);
+        } catch(IllegalStateException e) {
+            e.printStackTrace();
+            warnBecauseOfDoubleConflict();
+        }
+        return true;
+    }
+
+    @Override public void undoCommand() {
+        if (! Main.map.mapView.hasLayer(getLayer())) {
+            System.out.println(tr("Warning: layer ''{0}'' doesn't exist anymore. Can't remove conflict for primitmive ''{1}''",
+                    getLayer().getName(),
+                    new PrimitiveNameFormatter().getName(conflict.getMy())
+            ));
+            return;
+        }
+        getLayer().getConflicts().remove(conflict);
+    }
+
+    @Override public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) {
+        // nothing to fill
+    }
+
+    @Override public MutableTreeNode description() {
+        return new DefaultMutableTreeNode(
+                new JLabel(
+                        tr("Add conflict for ''{0}''",
+                                new PrimitiveNameFormatter().getName(conflict.getMy())
+                        ),
+                        ImageProvider.get(OsmPrimitiveType.from(conflict.getMy())),
+                        JLabel.HORIZONTAL
+                )
+        );
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java	(revision 1857)
@@ -29,4 +29,5 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.JMultilineLabel;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.PrimitiveNameFormatter;
 import org.openstreetmap.josm.tools.GBC;
@@ -140,8 +141,13 @@
             }
 
-            int answer = JOptionPane.showOptionDialog(Main.parent, p,
-                    tr("Automatic tag correction"), JOptionPane.YES_NO_CANCEL_OPTION,
-                    JOptionPane.PLAIN_MESSAGE, null,
-                    applicationOptions, applicationOptions[0]);
+            int answer = OptionPaneUtil.showOptionDialog(
+                    Main.parent,
+                    p,
+                    tr("Automatic tag correction"),
+                    JOptionPane.YES_NO_CANCEL_OPTION,
+                    JOptionPane.PLAIN_MESSAGE,
+                    applicationOptions,
+                    applicationOptions[0]
+            );
 
             if (answer == JOptionPane.YES_OPTION) {
Index: /trunk/src/org/openstreetmap/josm/data/DataSetChecker.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/DataSetChecker.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/data/DataSetChecker.java	(revision 1857)
@@ -9,6 +9,9 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+
+// FIXME: class still needed?
 
 public class DataSetChecker {
@@ -23,5 +26,11 @@
                 for (OsmPrimitive osm : ((OsmDataLayer)l).data.allPrimitives()) {
                     if (s.contains(osm)) {
-                        JOptionPane.showMessageDialog(Main.parent, "cross references");
+                        // FIXME: better message
+                        // FIXME: translate message and title
+                        OptionPaneUtil.showMessageDialog(
+                                Main.parent,
+                                "cross references",
+                                "Information",
+                                JOptionPane.INFORMATION_MESSAGE);
                         return;
                     }
@@ -34,10 +43,16 @@
             OsmDataLayer l = (OsmDataLayer)Main.map.mapView.getActiveLayer();
             if (l.data != Main.main.getCurrentDataSet()) {
-                JOptionPane.showMessageDialog(Main.parent, "Main.ds / active layer mismatch");
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        "Main.ds / active layer mismatch",
+                        "Error",
+                        JOptionPane.ERROR_MESSAGE
+                );
                 return;
             }
         }
 
-        JOptionPane.showMessageDialog(Main.parent, "working");
+        OptionPaneUtil.showMessageDialog(
+                Main.parent, "working", "", JOptionPane.INFORMATION_MESSAGE);
     }
 }
Index: /trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 1857)
@@ -31,4 +31,5 @@
 import org.openstreetmap.josm.actions.AboutAction;
 import org.openstreetmap.josm.data.projection.Mercator;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.preferences.ProxyPreferences;
 import org.openstreetmap.josm.tools.ColorHelper;
@@ -45,8 +46,8 @@
 
     /**
-    * Internal storage for the preferenced directory.
-    * Do not access this variable directly!
-    * @see #getPreferencesDirFile()
-    */
+     * Internal storage for the preferenced directory.
+     * Do not access this variable directly!
+     * @see #getPreferencesDirFile()
+     */
     private File preferencesDirFile = null;
 
@@ -131,11 +132,13 @@
         String s;
         if ((s = System.getenv("JOSM_RESOURCES")) != null) {
-            if (!s.endsWith(File.separator))
+            if (!s.endsWith(File.separator)) {
                 s = s + File.separator;
+            }
             locations.add(s);
         }
         if ((s = System.getProperty("josm.resources")) != null) {
-            if (!s.endsWith(File.separator))
+            if (!s.endsWith(File.separator)) {
                 s = s + File.separator;
+            }
             locations.add(s);
         }
@@ -180,12 +183,14 @@
         final Map<String,String> all = new TreeMap<String,String>();
         for (final Entry<String,String> e : properties.entrySet())
-            if (e.getKey().startsWith(prefix))
+            if (e.getKey().startsWith(prefix)) {
                 all.put(e.getKey(), e.getValue());
+            }
         for (final Entry<String,String> e : override.entrySet())
             if (e.getKey().startsWith(prefix))
-                if (e.getValue() == null)
+                if (e.getValue() == null) {
                     all.remove(e.getKey());
-                else
+                } else {
                     all.put(e.getKey(), e.getValue());
+                }
         return all;
     }
@@ -194,15 +199,18 @@
         final TreeMap<String,String> all = new TreeMap<String,String>();
         for (final Entry<String,String> e : defaults.entrySet())
-            if (e.getKey().startsWith("color.") && e.getValue() != null)
+            if (e.getKey().startsWith("color.") && e.getValue() != null) {
                 all.put(e.getKey().substring(6), e.getValue());
+            }
         for (final Entry<String,String> e : properties.entrySet())
-            if (e.getKey().startsWith("color."))
+            if (e.getKey().startsWith("color.")) {
                 all.put(e.getKey().substring(6), e.getValue());
+            }
         for (final Entry<String,String> e : override.entrySet())
             if (e.getKey().startsWith("color."))
-                if (e.getValue() == null)
+                if (e.getValue() == null) {
                     all.remove(e.getKey().substring(6));
-                else
+                } else {
                     all.put(e.getKey().substring(6), e.getValue());
+                }
         return all;
     }
@@ -213,8 +221,9 @@
 
     synchronized public void putDefault(final String key, final String def) {
-        if(!defaults.containsKey(key) || defaults.get(key) == null)
+        if(!defaults.containsKey(key) || defaults.get(key) == null) {
             defaults.put(key, def);
-        else if(def != null && !defaults.get(key).equals(def))
+        } else if(def != null && !defaults.get(key).equals(def)) {
             System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key));
+        }
     }
 
@@ -235,13 +244,15 @@
     synchronized public boolean put(final String key, String value) {
         String oldvalue = properties.get(key);
-        if(value != null && value.length() == 0)
+        if(value != null && value.length() == 0) {
             value = null;
+        }
         if(!((oldvalue == null && (value == null || value.equals(defaults.get(key))))
-        || (value != null && oldvalue != null && oldvalue.equals(value))))
+                || (value != null && oldvalue != null && oldvalue.equals(value))))
         {
-            if (value == null)
+            if (value == null) {
                 properties.remove(key);
-            else
+            } else {
                 properties.put(key, value);
+            }
             save();
             firePreferenceChanged(key, value);
@@ -268,6 +279,7 @@
 
     private final void firePreferenceChanged(final String key, final String value) {
-        for (final PreferenceChangedListener l : listener)
+        for (final PreferenceChangedListener l : listener) {
             l.preferenceChanged(key, value);
+        }
     }
 
@@ -282,10 +294,11 @@
             setSystemProperties();
             final PrintWriter out = new PrintWriter(new OutputStreamWriter(
-            new FileOutputStream(getPreferencesDir() + "preferences"), "utf-8"), false);
+                    new FileOutputStream(getPreferencesDir() + "preferences"), "utf-8"), false);
             for (final Entry<String, String> e : properties.entrySet()) {
                 String s = defaults.get(e.getKey());
                 /* don't save default values */
-                if(s == null || !s.equals(e.getValue()))
+                if(s == null || !s.equals(e.getValue())) {
                     out.println(e.getKey() + "=" + e.getValue());
+                }
             }
             out.close();
@@ -300,5 +313,5 @@
         properties.clear();
         final BufferedReader in = new BufferedReader(new InputStreamReader(
-        new FileInputStream(getPreferencesDir()+"preferences"), "utf-8"));
+                new FileInputStream(getPreferencesDir()+"preferences"), "utf-8"));
         int lineNumber = 0;
         ArrayList<Integer> errLines = new ArrayList<Integer>();
@@ -322,23 +335,35 @@
         if (prefDir.exists()) {
             if(!prefDir.isDirectory()) {
-                JOptionPane.showMessageDialog(null, tr("Cannot open preferences directory: {0}",Main.pref.getPreferencesDir()));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("Cannot open preferences directory: {0}",Main.pref.getPreferencesDir()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
                 return;
             }
-        }
-        else
+        } else {
             prefDir.mkdirs();
-
-        if (!new File(getPreferencesDir()+"preferences").exists())
+        }
+
+        if (!new File(getPreferencesDir()+"preferences").exists()) {
             resetToDefault();
+        }
 
         try {
-            if (reset)
+            if (reset) {
                 resetToDefault();
-            else
+            } else {
                 load();
+            }
         } catch (final IOException e1) {
             e1.printStackTrace();
             String backup = getPreferencesDir() + "preferences.bak";
-            JOptionPane.showMessageDialog(null, tr("Preferences file had errors. Making backup of old one to {0}.", backup));
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("Preferences file had errors. Making backup of old one to {0}.", backup),
+                    tr("Error"),
+                    JOptionPane.ERROR_MESSAGE
+            );
             new File(getPreferencesDir() + "preferences").renameTo(new File(backup));
             save();
@@ -362,8 +387,9 @@
     public Collection<Bookmark> loadBookmarks() throws IOException {
         File bookmarkFile = new File(getPreferencesDir()+"bookmarks");
-        if (!bookmarkFile.exists())
+        if (!bookmarkFile.exists()) {
             bookmarkFile.createNewFile();
+        }
         BufferedReader in = new BufferedReader(new InputStreamReader(
-        new FileInputStream(bookmarkFile), "utf-8"));
+                new FileInputStream(bookmarkFile), "utf-8"));
 
         LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
@@ -375,6 +401,7 @@
                 Bookmark b = new Bookmark();
                 b.name = m.group(1);
-                for (int i = 0; i < b.latlon.length; ++i)
+                for (int i = 0; i < b.latlon.length; ++i) {
                     b.latlon[i] = Double.parseDouble(m.group(i+2));
+                }
                 bookmarks.add(b);
             }
@@ -387,12 +414,14 @@
     public void saveBookmarks(Collection<Bookmark> bookmarks) throws IOException {
         File bookmarkFile = new File(Main.pref.getPreferencesDir()+"bookmarks");
-        if (!bookmarkFile.exists())
+        if (!bookmarkFile.exists()) {
             bookmarkFile.createNewFile();
+        }
         PrintWriter out = new PrintWriter(new OutputStreamWriter(
-        new FileOutputStream(bookmarkFile), "utf-8"));
+                new FileOutputStream(bookmarkFile), "utf-8"));
         for (Bookmark b : bookmarks) {
             out.print(b.name+"\u001e");
-            for (int i = 0; i < b.latlon.length; ++i)
+            for (int i = 0; i < b.latlon.length; ++i) {
                 out.print(b.latlon[i]+(i<b.latlon.length-1?"\u001e":""));
+            }
             out.println();
         }
@@ -422,6 +451,7 @@
         putDefault("color."+colName, ColorHelper.color2html(def));
         String colStr = specName != null ? get("color."+specName) : "";
-        if(colStr.equals(""))
+        if(colStr.equals("")) {
             colStr = get("color."+colName);
+        }
         return colStr.equals("") ? def : ColorHelper.html2color(colStr);
     }
@@ -481,6 +511,7 @@
         putDefault(key, def);
         String v = get(key);
-        if(v != null && v.length() != 0)
+        if(v != null && v.length() != 0) {
             try { return Double.parseDouble(v); } catch(NumberFormatException e) {}
+        }
         try { return Double.parseDouble(def); } catch(NumberFormatException e) {}
         return 0.0;
@@ -494,8 +525,9 @@
             for(String a : def)
             {
-                if(d != null)
+                if(d != null) {
                     d += "\u001e" + a;
-                else
+                } else {
                     d = a;
+                }
             }
             putDefault(key, d);
@@ -506,8 +538,9 @@
             {
                 String r =s;
-                if(r.indexOf("§§§") > 0) /* history dialog */
+                if(r.indexOf("§§§") > 0) {
                     r = r.replaceAll("§§§","\u001e");
-                else /* old style ';' separation */
+                } else {
                     r = r.replace(';','\u001e');
+                }
                 if(!r.equals(s)) /* save the converted string */
                 {
@@ -534,8 +567,9 @@
             for(String a : val)
             {
-                if(s != null)
+                if(s != null) {
                     s += "\u001e" + a;
-                else
+                } else {
                     s = a;
+                }
             }
         }
Index: /trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java	(revision 1857)
@@ -24,4 +24,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.io.OsmConnection;
 import org.openstreetmap.josm.io.XmlWriter;
@@ -48,5 +49,7 @@
                 System.out.println("reading preferences from "+serverUrl);
                 URLConnection con = serverUrl.openConnection();
-                if (con instanceof HttpURLConnection) addAuth((HttpURLConnection) con);
+                if (con instanceof HttpURLConnection) {
+                    addAuth((HttpURLConnection) con);
+                }
                 con.connect();
                 BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
@@ -56,5 +59,7 @@
                     b.append("\n");
                 }
-                if (con instanceof HttpURLConnection) ((HttpURLConnection) con).disconnect();
+                if (con instanceof HttpURLConnection) {
+                    ((HttpURLConnection) con).disconnect();
+                }
                 return b.toString();
             } catch (IOException e) {
@@ -77,8 +82,18 @@
                 con.getInputStream().close();
                 con.disconnect();
-                JOptionPane.showMessageDialog(Main.parent, tr("Preferences stored on {0}", u.getHost()));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("Preferences stored on {0}", u.getHost()),
+                        tr("Information"),
+                        JOptionPane.INFORMATION_MESSAGE
+                );
             } catch (Exception e) {
                 e.printStackTrace();
-                JOptionPane.showMessageDialog(Main.parent, tr("Could not upload preferences. Reason: {0}", e.getMessage()));
+                OptionPaneUtil.showMessageDialog(
+                        Main.parent,
+                        tr("Could not upload preferences. Reason: {0}", e.getMessage()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
             }
         }
@@ -119,8 +134,10 @@
     public void download(String userName, String password) {
         resetToDefault();
-        if (!properties.containsKey("osm-server.username") && userName != null)
+        if (!properties.containsKey("osm-server.username") && userName != null) {
             properties.put("osm-server.username", userName);
-        if (!properties.containsKey("osm-server.password") && password != null)
+        }
+        if (!properties.containsKey("osm-server.password") && password != null) {
             properties.put("osm-server.password", password);
+        }
         String cont = connection.download();
         if (cont == null) return;
@@ -128,6 +145,7 @@
         try {
             XmlObjectParser.Uniform<Prop> parser = new XmlObjectParser.Uniform<Prop>(in, "tag", Prop.class);
-            for (Prop p : parser)
+            for (Prop p : parser) {
                 properties.put(p.key, p.value);
+            }
         } catch (RuntimeException e) {
             e.printStackTrace();
@@ -144,6 +162,7 @@
         StringBuilder b = new StringBuilder("<preferences>\n");
         for (Entry<String, String> p : properties.entrySet()) {
-            if (p.getKey().equals("osm-server.password"))
+            if (p.getKey().equals("osm-server.password")) {
                 continue; // do not upload password. It would get stored in plain!
+            }
             b.append("<tag key='");
             b.append(XmlWriter.encode(p.getKey()));
@@ -163,11 +182,13 @@
             for (String line = in.readLine(); line != null; line = in.readLine()) {
                 StringTokenizer st = new StringTokenizer(line, ",");
-                if (st.countTokens() < 5)
+                if (st.countTokens() < 5) {
                     continue;
+                }
                 Bookmark b = new Bookmark();
                 b.name = st.nextToken();
                 try {
-                    for (int i = 0; i < b.latlon.length; ++i)
+                    for (int i = 0; i < b.latlon.length; ++i) {
                         b.latlon[i] = Double.parseDouble(st.nextToken());
+                    }
                     bookmarks.add(b);
                 } catch (NumberFormatException x) {
Index: /trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java	(revision 1857)
@@ -67,5 +67,12 @@
     }
 
-    protected void addConflict(Conflict<?> conflict) {
+    /**
+     * Adds a conflict to the collection
+     * 
+     * @param conflict the conflict
+     * @exception IllegalStateException thrown, if this collection already includes a
+     * conflict for conflict.getMy()
+     */
+    protected void addConflict(Conflict<?> conflict) throws IllegalStateException {
         if (hasConflictForMy(conflict.getMy()))
             throw new IllegalStateException(tr("already registered a conflict for primitive ''{0}''", conflict.getMy().toString()));
Index: /trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/Lambert.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/data/projection/Lambert.java	(revision 1857)
@@ -13,4 +13,5 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 
 public class Lambert implements Projection {
@@ -52,7 +53,7 @@
 
     public static final double zoneLimits[] = { Math.toRadians(53.5 * 0.9), // between Zone 1 and Zone 2 (in grad *0.9)
-            Math.toRadians(50.5 * 0.9), // between Zone 2 and Zone 3
-            Math.toRadians(47.51963 * 0.9), // between Zone 3 and Zone 4
-            Math.toRadians(46.17821 * 0.9) };// lowest latitude of Zone 4
+        Math.toRadians(50.5 * 0.9), // between Zone 2 and Zone 3
+        Math.toRadians(47.51963 * 0.9), // between Zone 3 and Zone 4
+        Math.toRadians(46.17821 * 0.9) };// lowest latitude of Zone 4
 
     public static final double cMinLonZones = Math.toRadians(-4.9074074074074059 * 0.9);
@@ -84,21 +85,19 @@
         if (lt >= zoneLimits[3] && lt <= cMaxLatZone1 && lg >= cMinLonZones && lg <= cMaxLonZones) {
             // zone I
-            if (lt > zoneLimits[0])
+            if (lt > zoneLimits[0]) {
                 currentZone = 0;
-            // zone II
-            else if (lt > zoneLimits[1])
+            } else if (lt > zoneLimits[1]) {
                 currentZone = 1;
-            // zone III
-            else if (lt > zoneLimits[2])
+            } else if (lt > zoneLimits[2]) {
                 currentZone = 2;
-            // zone III or IV
-            else if (lt > zoneLimits[3])
+            } else if (lt > zoneLimits[3])
                 // Note: zone IV is dedicated to Corsica island and extends from 47.8 to
                 // 45.9 degrees of latitude. There is an overlap with zone III that can be
                 // solved only with longitude (covers Corsica if lon > 7.2 degree)
-                if (lg < Math.toRadians(8 * 0.9))
+                if (lg < Math.toRadians(8 * 0.9)) {
                     currentZone = 2;
-                else
+                } else {
                     currentZone = 3;
+                }
         } else {
             outOfLambertZones = true; // possible when MAX_LAT is used
@@ -109,11 +108,13 @@
             } else if (layoutZone != currentZone) {
                 if ((currentZone < layoutZone && Math.abs(zoneLimits[currentZone] - lt) > cMaxOverlappingZones)
-                || (currentZone > layoutZone && Math.abs(zoneLimits[layoutZone] - lt) > cMaxOverlappingZones)) {
-                    JOptionPane.showMessageDialog(Main.parent,
-                    tr("IMPORTANT : data positioned far away from\n"
-                    + "the current Lambert zone limits.\n"
-                    + "Do not upload any data after this message.\n"
-                    + "Undo your last action, save your work\n"
-                    + "and start a new layer on the new zone."));
+                        || (currentZone > layoutZone && Math.abs(zoneLimits[layoutZone] - lt) > cMaxOverlappingZones)) {
+                    OptionPaneUtil.showMessageDialog(Main.parent,
+                            tr("IMPORTANT : data positioned far away from\n"
+                                    + "the current Lambert zone limits.\n"
+                                    + "Do not upload any data after this message.\n"
+                                    + "Undo your last action, save your work\n"
+                                    + "and start a new layer on the new zone."),
+                                    tr("Warning"),
+                                    JOptionPane.WARNING_MESSAGE);
                     layoutZone = -1;
                 } else {
@@ -130,9 +131,10 @@
     public LatLon eastNorth2latlon(EastNorth p) {
         LatLon geo;
-        if (layoutZone == -1)
+        if (layoutZone == -1) {
             // possible until the Lambert zone is determined by latlon2eastNorth() with a valid LatLon
             geo = Geographic(p, Xs[currentZone], Ys[currentZone], c[currentZone], n[currentZone]);
-        else
+        } else {
             geo = Geographic(p, Xs[layoutZone], Ys[layoutZone], c[layoutZone], n[layoutZone]);
+        }
         // translate ellipsoid Clark => GRS80 (WGS83)
         LatLon wgs = Clark2GRS80(geo);
@@ -197,5 +199,5 @@
             double eslt = Ellipsoid.clarke.e * Math.sin(lat);
             double nlt = 2.0 * Math.atan(Math.pow((1.0 + eslt) / (1.0 - eslt), Ellipsoid.clarke.e / 2.0) * l) - Math.PI
-                    / 2.0;
+            / 2.0;
             delta = Math.abs(nlt - lat);
             lat = nlt;
@@ -261,5 +263,5 @@
             s2 *= s2;
             double l = Math.atan((Z / norm)
-                / (1.0 - (ell.a * ell.e2 * Math.cos(lt) / (norm * Math.sqrt(1.0 - ell.e2 * s2)))));
+                    / (1.0 - (ell.a * ell.e2 * Math.cos(lt) / (norm * Math.sqrt(1.0 - ell.e2 * s2)))));
             delta = Math.abs(l - lt);
             lt = l;
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java	(revision 1857)
@@ -98,4 +98,5 @@
         if (isVisible){
             restorePositionAndDimension();
+            toFront();
         } else {
             rememberPositionAndDimension();
@@ -130,4 +131,9 @@
     protected void build() {
         setTitle(tr("Resolve conflicts"));
+        try {
+            setAlwaysOnTop(true);
+        } catch(SecurityException e) {
+            System.out.println(tr("Warning: couldn't setAlwaysOnTop(true) for ConflictResolution Dialog. Exception: {0}", e.toString()));
+        }
         getContentPane().setLayout(new BorderLayout());
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 1857)
@@ -52,7 +52,7 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.actions.DeleteAction;
 import org.openstreetmap.josm.command.AddCommand;
 import org.openstreetmap.josm.command.ChangeCommand;
+import org.openstreetmap.josm.command.ConflictAddCommand;
 import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -604,4 +604,7 @@
         // --- copy relation action
         buttonPanel.add(new SideButton(new DuplicateRelationAction()));
+
+        // --- apply relation action
+        buttonPanel.add(new SideButton(new ApplyAction()));
 
         // --- delete relation action
@@ -1002,5 +1005,5 @@
     }
 
-    class OKAction extends AbstractAction {
+    abstract class SavingAction extends AbstractAction {
         /**
          * apply updates to a new relation
@@ -1014,55 +1017,152 @@
             tagEditorModel.applyToPrimitive(newRelation);
             memberTableModel.applyToRelation(newRelation);
-            Main.main.undoRedo.add(new AddCommand(newRelation));
+            Main.main.undoRedo.add(new AddCommand(getLayer(),newRelation));
+
+            // make sure everybody is notified about the changes
+            //
             DataSet.fireSelectionChanged(getLayer().data.getSelected());
+            getLayer().fireDataChange();
+            GenericRelationEditor.this.setRelation(newRelation);
+            RelationDialogManager.getRelationDialogManager().updateContext(
+                    getLayer(),
+                    getRelation(),
+                    GenericRelationEditor.this
+            );
         }
 
         /**
-         * apply updates to an existing relation
+         * Apply the updates for an existing relation which has not been changed
+         * outside of the relation editor.
+         * 
          */
-        protected void applyExistingRelation() {
+        protected void applyExistingConflictingRelation() {
             Relation editedRelation = new Relation(getRelation());
             tagEditorModel.applyToPrimitive(editedRelation);
             memberTableModel.applyToRelation(editedRelation);
-            if (isDirtyRelation()) {
-                Conflict<Relation> conflict = new Conflict<Relation>(getRelation(), editedRelation);
-                getLayer().getConflicts().add(conflict);
-                OptionPaneUtil.showMessageDialog(
-                        Main.parent,
-                        tr("<html>The relation has changed outside of the editor.<br>"
-                                + "Your edits can't be applied directly, a conflict has been created instead.</html>"),
-                                tr("Warning"),
-                                JOptionPane.WARNING_MESSAGE
-                );
-            } else {
-                tagEditorModel.applyToPrimitive(editedRelation);
-                memberTableModel.applyToRelation(editedRelation);
-                Main.main.undoRedo.add(new ChangeCommand(getRelation(), editedRelation));
-                DataSet.fireSelectionChanged(getLayer().data.getSelected());
-            }
+            Conflict<Relation> conflict = new Conflict<Relation>(getRelation(), editedRelation);
+            Main.main.undoRedo.add(new ConflictAddCommand(getLayer(),conflict));
         }
 
         /**
-         * Applies updates
+         * Apply the updates for an existing relation which has been changed
+         * outside of the relation editor.
+         * 
          */
-        protected void applyChanges() {
+        protected void applyExistingNonConflictingRelation() {
+            Relation editedRelation = new Relation(getRelation());
+            tagEditorModel.applyToPrimitive(editedRelation);
+            memberTableModel.applyToRelation(editedRelation);
+            Main.main.undoRedo.add(new ChangeCommand(getRelation(), editedRelation));
+            DataSet.fireSelectionChanged(getLayer().data.getSelected());
+            getLayer().fireDataChange();
+            // this will refresh the snapshot and update the dialog title
+            //
+            setRelation(getRelation());
+        }
+
+        protected boolean confirmClosingBecauseOfDirtyState() {
+            String [] options = new String[] {
+                    tr("Yes, create a conflict and close"),
+                    tr("No, continue editing")
+            };
+            int ret = OptionPaneUtil.showOptionDialog(
+                    Main.parent,
+                    tr("<html>This relation has been changed outside of the editor.<br>"
+                            + "You can't apply your changes and continue editing.<br>"
+                            + "<br>"
+                            + "Do you want to create a conflict and close the editor?</html>"),
+                            tr("Conflict in data"),
+                            JOptionPane.YES_NO_OPTION,
+                            JOptionPane.WARNING_MESSAGE,
+                            options,
+                            options[0]
+            );
+            switch(ret) {
+            case JOptionPane.CANCEL_OPTION: return false;
+            case JOptionPane.YES_OPTION: return true;
+            case JOptionPane.NO_OPTION: return false;
+            }
+            return false;
+        }
+
+        protected void warnDoubleConflict() {
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    tr("<html>Layer ''{0}'' already has a conflict for primitive<br>"
+                            + "''{1}''.<br>"
+                            + "Please resolve this conflict first, then try again.</html>",
+                            getLayer().getName(),
+                            new PrimitiveNameFormatter().getName(getRelation())
+                    ),
+                    tr("Double conflict"),
+                    JOptionPane.WARNING_MESSAGE
+            );
+        }
+    }
+
+    class ApplyAction extends SavingAction {
+        public ApplyAction() {
+            putValue(SHORT_DESCRIPTION, tr("Apply the current updates"));
+            putValue(SMALL_ICON, ImageProvider.get("save"));
+            putValue(NAME, tr("Apply"));
+            setEnabled(true);
+        }
+
+        public void run() {
             if (getRelation() == null) {
                 applyNewRelation();
             } else if (!memberTableModel.hasSameMembersAs(getRelationSnapshot())
                     || tagEditorModel.isDirty()) {
-                applyExistingRelation();
-            }
-        }
-
+                if (isDirtyRelation()) {
+                    if (confirmClosingBecauseOfDirtyState()) {
+                        if (getLayer().getConflicts().hasConflictForMy(getRelation())) {
+                            warnDoubleConflict();
+                            return;
+                        }
+                        applyExistingConflictingRelation();
+                        setVisible(false);
+                    }
+                } else {
+                    applyExistingNonConflictingRelation();
+                }
+            }
+        }
+
+        public void actionPerformed(ActionEvent e) {
+            run();
+        }
+    }
+
+    class OKAction extends SavingAction {
         public OKAction() {
             putValue(SHORT_DESCRIPTION, tr("Apply the updates and close the dialog"));
             putValue(SMALL_ICON, ImageProvider.get("ok"));
-            putValue(NAME, tr("Apply"));
+            putValue(NAME, tr("OK"));
             setEnabled(true);
         }
 
-        public void actionPerformed(ActionEvent e) {
-            applyChanges();
+        public void run() {
+            if (getRelation() == null) {
+                applyNewRelation();
+            } else if (!memberTableModel.hasSameMembersAs(getRelationSnapshot())
+                    || tagEditorModel.isDirty()) {
+                if (isDirtyRelation()) {
+                    if (confirmClosingBecauseOfDirtyState()) {
+                        if (getLayer().getConflicts().hasConflictForMy(getRelation())) {
+                            warnDoubleConflict();
+                            return;
+                        }
+                        applyExistingConflictingRelation();
+                    } else
+                        return;
+                } else {
+                    applyExistingNonConflictingRelation();
+                }
+            }
             setVisible(false);
+        }
+
+        public void actionPerformed(ActionEvent e) {
+            run();
         }
     }
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java	(revision 1857)
@@ -440,4 +440,39 @@
     }
 
+    /**
+     * get a node we can link against when sorting members
+     * @param element the element we want to link against
+     * @param linked_element already linked against element
+     * @return the unlinked node if element is a way, the node itself if element is a node, null otherwise
+     */
+    private static Node getUnusedNode(RelationMember element, RelationMember linked_element)
+    {
+        Node    result = null;
+
+        if (element.member instanceof Way) {
+            Way w = (Way) element.member;
+            if (linked_element.member instanceof Way) {
+                Way x = (Way) linked_element.member;
+                if ((w.firstNode() == x.firstNode()) || (w.firstNode() == x.lastNode())) {
+                    result = w.lastNode();
+                } else {
+                    result = w.firstNode();
+                }
+            } else if (linked_element.member instanceof Node) {
+                Node m = (Node) linked_element.member;
+                if (w.firstNode() == m) {
+                    result = w.lastNode();
+                } else {
+                    result = w.firstNode();
+                }
+            }
+        } else if (element.member instanceof Node) {
+            Node n = (Node) element.member;
+            result = n;
+        }
+
+        return result;
+    }
+
     void sort() {
         RelationNodeMap map = new RelationNodeMap(members);
@@ -450,10 +485,10 @@
         /*
          * sort any 2 or more connected elements together may be slow with many unconnected members
-         * TODO: cleanup again, too much code in 1 method
          */
 
-        if (map.isEmpty())
+        if (map.isEmpty()) {
             // empty relation or incomplete members
             return;
+        }
         segments = new Vector<LinkedList<Integer>>();
 
@@ -482,9 +517,13 @@
                 endSearchNode = null;
                 if (segment.size() == 1) {
+                    // only one element in segment, so try to link against each linkable node of element
                     RelationMember m = members.get(segment.getFirst());
                     if (m.member instanceof Way) {
                         Way w = (Way) m.member;
                         endSearchNode = w.lastNode();
-                        startSearchNode = w.firstNode();
+                        if (w.lastNode() != w.firstNode())
+                        {
+                            startSearchNode = w.firstNode();
+                        }
                     } else if (m.member instanceof Node) {
                         Node n = (Node) m.member;
@@ -493,55 +532,9 @@
                 } else {
                     // add unused node of first element and unused node of last element
-                    // start with the first element
-                    RelationMember element = members.get(segment.getFirst());
-                    RelationMember other_element = members.get(segment.get(1));
-
-                    if (element.member instanceof Way) {
-                        Way w = (Way) element.member;
-                        if (other_element.member instanceof Way) {
-                            Way x = (Way) other_element.member;
-                            if ((w.firstNode() == x.firstNode()) || (w.firstNode() == x.lastNode())) {
-                                startSearchNode = w.lastNode();
-                            } else {
-                                startSearchNode = w.firstNode();
-                            }
-                        } else if (other_element.member instanceof Node) {
-                            Node m = (Node) other_element.member;
-                            if (w.firstNode() == m) {
-                                startSearchNode = w.lastNode();
-                            } else {
-                                startSearchNode = w.firstNode();
-                            }
-                        }
-                    } else if (element.member instanceof Node) {
-                        Node n = (Node) element.member;
-                        startSearchNode = n;
-                    }
-
-                    // now the same for the last element
-                    element = members.get(segment.getLast());
-                    other_element = members.get(segment.get(segment.size() - 2));
-
-                    if (element.member instanceof Way) {
-                        Way w = (Way) element.member;
-                        if (other_element.member instanceof Way) {
-                            Way x = (Way) other_element.member;
-                            if ((w.firstNode() == x.firstNode()) || (w.firstNode() == x.lastNode())) {
-                                endSearchNode = w.lastNode();
-                            } else {
-                                endSearchNode = w.firstNode();
-                            }
-                        } else if (other_element.member instanceof Node) {
-                            Node m = (Node) other_element.member;
-                            if (w.firstNode() == m) {
-                                endSearchNode = w.lastNode();
-                            } else {
-                                endSearchNode = w.firstNode();
-                            }
-                        }
-                    } else if (element.member instanceof Node) {
-                        Node n = (Node) element.member;
-                        endSearchNode = n;
-                    }
+                    // start with the first element (compared to next element)
+                    startSearchNode = getUnusedNode(members.get(segment.getFirst()), members.get(segment.get(1)));
+
+                    // now the same for the last element (compared to previous element)
+                    endSearchNode = getUnusedNode(members.get(segment.getLast()), members.get(segment.get(segment.size() - 2)));
                 }
 
@@ -566,4 +559,5 @@
 
         }
+
         if (segments.size() > 0) {
             // append map.remaining() to segments list (as a single segment)
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 1857)
@@ -119,4 +119,19 @@
         openDialogs.put(context, editor);
         editor.addWindowListener(this);
+    }
+
+    public void updateContext(OsmDataLayer layer, Relation relation, RelationEditor editor) {
+        // lookup the entry for editor and remove it
+        //
+        for (DialogContext context: openDialogs.keySet()) {
+            if (openDialogs.get(context) == editor) {
+                openDialogs.remove(context);
+                break;
+            }
+        }
+        // don't add a window listener. Editor is already known to the relation dialog manager
+        //
+        DialogContext context = new DialogContext(layer, relation);
+        openDialogs.put(context, editor);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java	(revision 1857)
@@ -89,23 +89,27 @@
     }
 
-    protected RelationEditor(OsmDataLayer layer, Relation relation, Collection<RelationMember> selectedMembers)
-    {
+    protected RelationEditor(OsmDataLayer layer, Relation relation, Collection<RelationMember> selectedMembers) {
         // Initalizes ExtendedDialog
         super(Main.parent,
-                relation == null
-                ? tr("Create new relation in layer ''{0}''", layer.getName())
-                        : (relation.id == 0
-                                ? tr ("Edit new relation in layer ''{0}''", layer.getName())
-                                        : tr("Edit relation #{0} in layer ''{1}''", relation.id, layer.getName())
-                        ),
-                        new String[] { tr("Apply Changes"), tr("Cancel")},
-                        false
+                "",
+                new String[] { tr("Apply Changes"), tr("Cancel")},
+                false
         );
-
-        this.relationSnapshot = (relation == null) ? null : new Relation(relation);
-        this.relation = relation;
         this.layer = layer;
+        setRelation(relation);
     }
 
+    /**
+     * updates the title of the relation editor
+     */
+    protected void updateTitle() {
+        if (getRelation() == null) {
+            setTitle(tr("Create new relation in layer ''{0}''", layer.getName()));
+        } else if (getRelation().id == 0) {
+            setTitle(tr("Edit new relation in layer ''{0}''", layer.getName()));
+        } else {
+            setTitle(tr("Edit relation #{0} in layer ''{1}''", relation.id, layer.getName()));
+        }
+    }
     /**
      * Replies the currently edited relation
@@ -115,4 +119,16 @@
     protected Relation getRelation() {
         return relation;
+    }
+
+    /**
+     * Sets the currently edited relation. Creates a snapshot of the current
+     * state of the relation. See {@see #getRelationSnapshot()}
+     * 
+     * @param relation the relation
+     */
+    protected void setRelation(Relation relation) {
+        this.relationSnapshot = (relation == null) ? null : new Relation(relation);
+        this.relation = relation;
+        updateTitle();
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationNodeMap.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationNodeMap.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationNodeMap.java	(revision 1857)
@@ -57,13 +57,20 @@
         if (m.member instanceof Way) {
             Way w = (Way) m.member;
-            if (!points.containsKey(w.firstNode())) {
-                points.put(w.firstNode(), new java.util.TreeSet<Integer>());
+            if (w.lastNode() == w.firstNode())
+            {
+                nodes.put(w.firstNode(), Integer.valueOf(n));
             }
-            points.get(w.firstNode()).add(Integer.valueOf(n));
+            else
+            {
+                if (!points.containsKey(w.firstNode())) {
+                    points.put(w.firstNode(), new java.util.TreeSet<Integer>());
+                }
+                points.get(w.firstNode()).add(Integer.valueOf(n));
 
-            if (!points.containsKey(w.lastNode())) {
-                points.put(w.lastNode(), new java.util.TreeSet<Integer>());
+                if (!points.containsKey(w.lastNode())) {
+                    points.put(w.lastNode(), new java.util.TreeSet<Integer>());
+                }
+                points.get(w.lastNode()).add(Integer.valueOf(n));
             }
-            points.get(w.lastNode()).add(Integer.valueOf(n));
         } else if (m.member instanceof Node) {
             Node node = (Node) m.member;
@@ -77,6 +84,14 @@
         boolean result;
         if (a.member instanceof Way) {
-            result = points.get(((Way) a.member).firstNode()).remove(n);
-            result &= points.get(((Way) a.member).lastNode()).remove(n);
+            Way w = (Way) a.member;
+            if (w.firstNode() == w.lastNode())
+            {
+                result = (nodes.remove(w.firstNode()) != null);
+            }
+            else
+            {
+                result = points.get(w.firstNode()).remove(n);
+                result &= points.get(w.lastNode()).remove(n);
+            }
         } else {
             result = (nodes.remove(a.member) != null);
Index: /trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java	(revision 1857)
@@ -190,6 +190,11 @@
                 catch (Exception x)
                 {
-                    JOptionPane.showMessageDialog(Main.parent,tr("Cannot read place search results from server"));
                     x.printStackTrace();
+                    OptionPaneUtil.showMessageDialog(
+                            Main.parent,
+                            tr("Cannot read place search results from server"),
+                            tr("Error"),
+                            JOptionPane.ERROR_MESSAGE
+                    );
                 }
                 component.setCursor(oldCursor);
Index: /trunk/src/org/openstreetmap/josm/io/NMEAImporter.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/NMEAImporter.java	(revision 1856)
+++ /trunk/src/org/openstreetmap/josm/io/NMEAImporter.java	(revision 1857)
@@ -12,4 +12,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.ExtensionFileFilter;
+import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
@@ -42,12 +43,17 @@
     private void showNmeaInfobox(boolean success, NmeaReader r) {
         String msg = tr("Coordinates imported: ") + r.getNumberOfCoordinates() + "\n" + tr("Malformed sentences: ")
-                + r.getParserMalformed() + "\n" + tr("Checksum errors: ") + r.getParserChecksumErrors() + "\n";
-        if (!success) // don't scare the user unneccessarily
+        + r.getParserMalformed() + "\n" + tr("Checksum errors: ") + r.getParserChecksumErrors() + "\n";
+        if (!success) {
             msg += tr("Unknown sentences: ") + r.getParserUnknown() + "\n";
+        }
         msg += tr("Zero coordinates: ") + r.getParserZeroCoordinates();
         if (success) {
-            JOptionPane.showMessageDialog(Main.parent, msg, tr("NMEA import success"), JOptionPane.INFORMATION_MESSAGE);
+            OptionPaneUtil.showMessageDialog(
+                    Main.parent,
+                    msg,
+                    tr("NMEA import success"),
+                    JOptionPane.INFORMATION_MESSAGE);
         } else {
-            JOptionPane.showMessageDialog(Main.parent, msg, tr("NMEA import faliure!"), JOptionPane.ERROR_MESSAGE);
+            OptionPaneUtil.showMessageDialog(Main.parent, msg, tr("NMEA import faliure!"), JOptionPane.ERROR_MESSAGE);
         }
     }
