Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 1782)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 1783)
@@ -50,5 +50,4 @@
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.SideButton;
-import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache;
 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList;
@@ -536,4 +535,5 @@
      */
     private void applyChanges() {
+        System.out.println("applying changes ...");
         if (getRelation()== null) {
             // If the user wanted to create a new relation, but hasn't added any members or
@@ -880,3 +880,11 @@
         Main.worker.submit(new DownloadTask());
     }
+
+    @Override
+    public void setVisible(boolean visible) {
+        super.setVisible(visible);
+        if (!visible) {
+            dispose();
+        }
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 1782)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 1783)
@@ -17,5 +17,11 @@
  *
  */
-public class RelationDialogManager extends WindowAdapter implements LayerChangeListener {
+public class RelationDialogManager extends WindowAdapter implements LayerChangeListener{
+
+    /**
+     * Helper class for keeping the context of a relation editor. A relation editor
+     * is open for a specific relation managed by a specific {@see OsmDataLayer}
+     *
+     */
     static private class DialogContext {
         public Relation relation;
@@ -61,12 +67,30 @@
             return this.layer.equals(layer);
         }
+
+        @Override
+        public String toString() {
+            return "[Context: layer=" + layer.getName() + ",relation=" + relation.id + "]";
+        }
     }
 
+    /** the map of open dialogs */
     private HashMap<DialogContext, RelationEditor> openDialogs;
 
+    /**
+     * constructor
+     */
     public RelationDialogManager(){
+        System.out.println("RelationDialogManager: creating");
         openDialogs = new HashMap<DialogContext, RelationEditor>();
     }
 
+    /**
+     * Register the relation editor for a relation managed by a
+     * {@see OsmDataLayer}.
+     * 
+     * @param layer the layer
+     * @param relation the relation
+     * @param editor the editor
+     */
     public void register(OsmDataLayer layer, Relation relation, RelationEditor editor) {
         DialogContext context = new DialogContext(layer, relation);
@@ -75,9 +99,30 @@
     }
 
+    /**
+     * Replies true if there is an open relation editor for the relation managed
+     * by the given layer
+     * 
+     * @param layer  the layer
+     * @param relation  the relation
+     * @return true if there is an open relation editor for the relation managed
+     * by the given layer; false otherwise
+     */
     public boolean isOpenInEditor(OsmDataLayer layer, Relation relation) {
         DialogContext context = new DialogContext(layer, relation);
         return openDialogs.keySet().contains(context);
+
     }
 
+    /**
+     * Replies the editor for the relation managed by layer. Null, if no such editor
+     * is currently open.
+     * 
+     * @param layer the layer
+     * @param relation the relation
+     * @return the editor for the relation managed by layer. Null, if no such editor
+     * is currently open.
+     * 
+     * @see #isOpenInEditor(OsmDataLayer, Relation)
+     */
     public RelationEditor getEditorForRelation(OsmDataLayer layer, Relation relation) {
         DialogContext context = new DialogContext(layer, relation);
@@ -85,19 +130,8 @@
     }
 
-    @Override
-    public void windowClosed(WindowEvent e) {
-        RelationEditor editor = ((RelationEditor)e.getWindow());
-        DialogContext context = null;
-        for (DialogContext c : openDialogs.keySet()) {
-            if (openDialogs.get(c).equals(editor)) {
-                context = c;
-                break;
-            }
-        }
-        if (context != null) {
-            openDialogs.remove(context);
-        }
-    }
-
+    /**
+     * called when a layer is removed
+     * 
+     */
     public void layerRemoved(Layer oldLayer) {
         if (oldLayer == null || ! (oldLayer instanceof OsmDataLayer))
@@ -124,3 +158,18 @@
         // do nothing
     }
+
+    @Override
+    public void windowClosed(WindowEvent e) {
+        RelationEditor editor = (RelationEditor)e.getWindow();
+        DialogContext context = null;
+        for (DialogContext c : openDialogs.keySet()) {
+            if (openDialogs.get(c).equals(editor)) {
+                context = c;
+                break;
+            }
+        }
+        if (context != null) {
+            openDialogs.remove(context);
+        }
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java	(revision 1782)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java	(revision 1783)
@@ -10,6 +10,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
