Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java	(revision 28029)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java	(revision 28036)
@@ -34,8 +34,12 @@
     protected ConflationCandidate selectedCandidate = null;
     
-    public ConflationLayer(DataSet ds, ConflationCandidateList candidates) {
+    public ConflationLayer(ConflationCandidateList candidates) {
         super(tr("Conflation"));
         MapView.addLayerChangeListener(this);
         this.candidates = candidates;
+    }
+    
+    public ConflationLayer() {
+        this(null);
     }
 
@@ -143,12 +147,15 @@
     }
 
+    @Override
     public void activeLayerChange(Layer layer, Layer layer1) {
         //TODO: possibly change arrow styling depending on active layer?
     }
 
+    @Override
     public void layerAdded(Layer layer) {
         // shouldn't have to do anything here
     }
 
+    @Override
     public void layerRemoved(Layer layer) {
         //TODO: if ref or non-ref layer removed, remove arrows
@@ -164,4 +171,9 @@
     }
     
+    public void setCandidates(ConflationCandidateList candidates) {
+        this.candidates = candidates;
+        // TODO: does repaint automatically occur?
+    }
+    
     public void setSelectedCandidate(ConflationCandidate c) {
         selectedCandidate = c;
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationSettings.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationSettings.java	(revision 28036)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationSettings.java	(revision 28036)
@@ -0,0 +1,107 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.openstreetmap.josm.plugins.conflation;
+
+import java.util.ArrayList;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+
+/**
+ *
+ * @author Josh
+ */
+public class ConflationSettings {
+    private ArrayList<OsmPrimitive> subjectSelection;
+    private ArrayList<OsmPrimitive> referenceSelection;
+    private OsmDataLayer referenceLayer;
+    private DataSet subjectDataSet;
+    private OsmDataLayer subjectLayer;
+    private DataSet referenceDataSet;
+
+    /**
+     * @return the subjectSelection
+     */
+    public ArrayList<OsmPrimitive> getSubjectSelection() {
+        return subjectSelection;
+    }
+
+    /**
+     * @param subjectSelection the subjectSelection to set
+     */
+    public void setSubjectSelection(ArrayList<OsmPrimitive> subjectSelection) {
+        this.subjectSelection = subjectSelection;
+    }
+
+    /**
+     * @return the referenceSelection
+     */
+    public ArrayList<OsmPrimitive> getReferenceSelection() {
+        return referenceSelection;
+    }
+
+    /**
+     * @param referenceSelection the referenceSelection to set
+     */
+    public void setReferenceSelection(ArrayList<OsmPrimitive> referenceSelection) {
+        this.referenceSelection = referenceSelection;
+    }
+
+    /**
+     * @return the referenceLayer
+     */
+    public OsmDataLayer getReferenceLayer() {
+        return referenceLayer;
+    }
+
+    /**
+     * @param referenceLayer the referenceLayer to set
+     */
+    public void setReferenceLayer(OsmDataLayer referenceLayer) {
+        this.referenceLayer = referenceLayer;
+    }
+
+    /**
+     * @return the subjectDataSet
+     */
+    public DataSet getSubjectDataSet() {
+        return subjectDataSet;
+    }
+
+    /**
+     * @param subjectDataSet the subjectDataSet to set
+     */
+    public void setSubjectDataSet(DataSet subjectDataSet) {
+        this.subjectDataSet = subjectDataSet;
+    }
+
+    /**
+     * @return the subjectLayer
+     */
+    public OsmDataLayer getSubjectLayer() {
+        return subjectLayer;
+    }
+
+    /**
+     * @param subjectLayer the subjectLayer to set
+     */
+    public void setSubjectLayer(OsmDataLayer subjectLayer) {
+        this.subjectLayer = subjectLayer;
+    }
+
+    /**
+     * @return the referenceDataSet
+     */
+    public DataSet getReferenceDataSet() {
+        return referenceDataSet;
+    }
+
+    /**
+     * @param referenceDataSet the referenceDataSet to set
+     */
+    public void setReferenceDataSet(DataSet referenceDataSet) {
+        this.referenceDataSet = referenceDataSet;
+    }
+}
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java	(revision 28029)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java	(revision 28036)
@@ -3,7 +3,5 @@
 import java.awt.Component;
 import java.awt.Dialog;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.util.ArrayList;
+import java.awt.event.*;
 import java.util.Arrays;
 import java.util.Collection;
@@ -16,9 +14,7 @@
 import org.openstreetmap.josm.actions.JosmAction;
 import org.openstreetmap.josm.data.SelectionChangedListener;
-import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.event.*;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
-import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
@@ -41,5 +37,6 @@
     MatchTableModel tableModel;
     ConflationCandidateList candidates;
-    ConflationOptionsDialog optionsDialog;
+    ConflationSettings settings;
+    SettingsDialog settingsDialog;
 
     public ConflationToggleDialog(String name, String iconName, String tooltip,
@@ -50,10 +47,15 @@
 //        candidates.addConflationListChangedListener(this);
 
-        optionsDialog = new ConflationOptionsDialog();
-        optionsDialog.setModalityType(Dialog.ModalityType.MODELESS);
+        settingsDialog = new SettingsDialog();
+        settingsDialog.setModalityType(Dialog.ModalityType.MODELESS);
+        settingsDialog.addWindowListener(new WindowAdapter() {
+        public void windowClosed(WindowEvent e) {
+                if (settingsDialog.getValue() == 1) {
+                    settings = settingsDialog.getSettings();
+                    performConflation();
+                }
+        }});
 
         tableModel = new MatchTableModel();
-        tableModel.setCandidates(candidates);
-        candidates.addConflationListChangedListener(tableModel);
 
         resultsTable = new JTable(tableModel);
@@ -96,5 +98,5 @@
         @Override
         public void actionPerformed(ActionEvent e) {
-            optionsDialog.setVisible(true);
+            settingsDialog.setVisible(true);
         }
     }
@@ -159,5 +161,6 @@
 
         @Override
-        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+                boolean hasFocus, int row, int column) {
             Object columnValue = table.getValueAt(row, table.getColumnModel().getColumnIndex(columnName));
 
@@ -195,6 +198,7 @@
         }
     }
-    
+
     class ConflationAction extends JosmAction {
+
         public ConflationAction() {
             super(tr("Replace Geometry"), null, tr("Replace geometry"),
@@ -202,4 +206,5 @@
                     KeyEvent.VK_F, Shortcut.ALT_CTRL), false);
         }
+
         @Override
         public void actionPerformed(ActionEvent e) {
@@ -216,305 +221,4 @@
         }
     }
-    
-    public class ConflationOptionsDialog extends ExtendedDialog {
-
-        private JPanel costsPanel;
-        private JCheckBox distanceCheckBox;
-        private JButton freezeReferenceButton;
-        private JButton freezeSubjectButton;
-        private JPanel jPanel3;
-        private JPanel jPanel5;
-        private JButton restoreReferenceButton;
-        private JButton restoreSubjectButton;
-        private JLabel referenceLayerLabel;
-        private JPanel referencePanel;
-        private JLabel referenceSelectionLabel;
-        private JLabel subjectLayerLabel;
-        private JPanel subjectPanel;
-        private JLabel subjectSelectionLabel;
-        ArrayList<OsmPrimitive> subjectSelection = null;
-        ArrayList<OsmPrimitive> referenceSelection = null;
-        OsmDataLayer referenceLayer;
-        DataSet subjectDataSet;
-        OsmDataLayer subjectLayer;
-        DataSet referenceDataSet;
-
-        public ConflationOptionsDialog() {
-            super(Main.parent,
-                    tr("Configure conflation options"),
-                    new String[]{tr("Conflate"), tr("Cancel")},
-                    false);
-            initComponents();
-        }
-
-        private void initComponents() {
-            referencePanel = new JPanel();
-            referenceLayerLabel = new JLabel();
-            referenceSelectionLabel = new JLabel();
-            jPanel3 = new JPanel();
-            restoreReferenceButton = new JButton(new RestoreReferenceAction());
-            freezeReferenceButton = new JButton(new FreezeReferenceAction());
-            subjectPanel = new JPanel();
-            subjectLayerLabel = new JLabel();
-            subjectSelectionLabel = new JLabel();
-            jPanel5 = new JPanel();
-            restoreSubjectButton = new JButton(new RestoreSubjectAction());
-            freezeSubjectButton = new JButton(new FreezeSubjectAction());
-            costsPanel = new JPanel();
-            distanceCheckBox = new JCheckBox();
-
-            JPanel pnl = new JPanel();
-            pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS));
-
-            referencePanel.setBorder(BorderFactory.createTitledBorder(tr("Reference")));
-            referencePanel.setLayout(new BoxLayout(referencePanel, BoxLayout.PAGE_AXIS));
-
-            referenceLayerLabel.setText("(none)");
-            referencePanel.add(referenceLayerLabel);
-
-            referenceSelectionLabel.setText("Rel.:0 / Ways:0 / Nodes: 0");
-            referencePanel.add(referenceSelectionLabel);
-
-            jPanel3.setLayout(new BoxLayout(jPanel3, BoxLayout.LINE_AXIS));
-
-            restoreReferenceButton.setText(tr("Restore"));
-            jPanel3.add(restoreReferenceButton);
-
-            jPanel3.add(freezeReferenceButton);
-
-            referencePanel.add(jPanel3);
-
-            pnl.add(referencePanel);
-
-            subjectPanel.setBorder(BorderFactory.createTitledBorder(tr("Subject")));
-            subjectPanel.setLayout(new BoxLayout(subjectPanel, BoxLayout.PAGE_AXIS));
-
-            subjectLayerLabel.setText("(none)");
-            subjectPanel.add(subjectLayerLabel);
-
-            subjectSelectionLabel.setText("Rel.:0 / Ways:0 / Nodes: 0");
-            subjectPanel.add(subjectSelectionLabel);
-
-            jPanel5.setLayout(new BoxLayout(jPanel5, BoxLayout.LINE_AXIS));
-
-            restoreSubjectButton.setText(tr("Restore"));
-            jPanel5.add(restoreSubjectButton);
-
-            freezeSubjectButton.setText(tr("Freeze"));
-            jPanel5.add(freezeSubjectButton);
-
-            subjectPanel.add(jPanel5);
-
-            pnl.add(subjectPanel);
-
-            costsPanel.setBorder(BorderFactory.createTitledBorder(tr("Costs")));
-            costsPanel.setLayout(new BoxLayout(costsPanel, BoxLayout.LINE_AXIS));
-
-            distanceCheckBox.setSelected(true);
-            distanceCheckBox.setText(tr("Distance"));
-            distanceCheckBox.setEnabled(false);
-            costsPanel.add(distanceCheckBox);
-
-            pnl.add(costsPanel);
-
-            setContent(pnl);
-            setupDialog();
-        }
-
-        @Override
-        protected void buttonAction(int buttonIndex, ActionEvent evt) {
-            super.buttonAction(buttonIndex, evt);
-            if (buttonIndex == 0) {
-                performConflation();
-            }
-        }
-
-        private void performConflation() {
-
-            // some initialization
-            int n = subjectSelection.size();
-            int m = referenceSelection.size();
-            double cost[][] = new double[n][m];
-
-            // calculate cost matrix
-            for (int i = 0; i < n; i++) {
-                for (int j = 0; j < m; j++) {
-                    cost[i][j] = ConflationUtils.calcCost(subjectSelection.get(i), referenceSelection.get(j));
-                }
-            }
-
-            // perform assignment using Hungarian algorithm
-            int[][] assignment = HungarianAlgorithm.hgAlgorithm(cost, "min");
-            OsmPrimitive subObject, refObject;
-            candidates.clear();
-            for (int i = 0; i < n; i++) {
-                int subIdx = assignment[i][0];
-                int refIdx = assignment[i][1];
-                if (subIdx < n) {
-                    subObject = subjectSelection.get(subIdx);
-                } else {
-                    subObject = null;
-                }
-                if (refIdx < m) {
-                    refObject = referenceSelection.get(refIdx);
-                } else {
-                    refObject = null;
-                }
-
-                if (subObject != null && refObject != null) {
-                    // TODO: do something!
-                    if (!(candidates.hasCandidate(refObject, subObject) || candidates.hasCandidate(subObject, refObject))) {
-                        candidates.add(new ConflationCandidate(refObject, referenceLayer, subObject, subjectLayer, cost[subIdx][refIdx]));
-                    }
-                }
-            }
-
-            // add conflation layer
-            try {
-                conflationLayer = new ConflationLayer(subjectLayer.data, candidates);
-                Main.main.addLayer(conflationLayer);
-            } catch (Exception ex) {
-                JOptionPane.showMessageDialog(Main.parent, ex.toString(),
-                        "Error adding conflation layer", JOptionPane.ERROR_MESSAGE);
-            }
-
-            // print list of matched pairsalong with distance
-            // upon selection of one pair, highlight them and draw arrow
-
-//            if (resultsPanel != null) {
-//                resultsTabPanel.setSelectedComponent(resultsPanel);
-//            }
-        }
-
-        class RestoreSubjectAction extends JosmAction {
-
-            public RestoreSubjectAction() {
-                super(tr("Restore"), null, tr("Restore subject selection"), null, false);
-            }
-
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if (subjectLayer != null && subjectDataSet != null && subjectSelection != null && !subjectSelection.isEmpty()) {
-                    Main.map.mapView.setActiveLayer(subjectLayer);
-                    subjectLayer.setVisible(true);
-                    subjectDataSet.setSelected(subjectSelection);
-                }
-            }
-        }
-
-        class RestoreReferenceAction extends JosmAction {
-
-            public RestoreReferenceAction() {
-                super(tr("Restore"), null, tr("Restore reference selection"), null, false);
-            }
-
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if (referenceLayer != null && referenceDataSet != null && referenceSelection != null && !referenceSelection.isEmpty()) {
-                    Main.map.mapView.setActiveLayer(referenceLayer);
-                    referenceLayer.setVisible(true);
-                    referenceDataSet.setSelected(referenceSelection);
-                }
-            }
-        }
-
-        class FreezeSubjectAction extends JosmAction {
-
-            public FreezeSubjectAction() {
-                super(tr("Freeze"), null, tr("Freeze subject selection"), null, false);
-            }
-
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if (subjectDataSet != null && subjectDataSet == Main.main.getCurrentDataSet()) {
-//                subjectDataSet.removeDataSetListener(this); FIXME:
-                }
-                subjectDataSet = Main.main.getCurrentDataSet();
-//            subjectDataSet.addDataSetListener(tableModel); FIXME:
-                subjectLayer = Main.main.getEditLayer();
-                if (subjectDataSet == null || subjectLayer == null) {
-                    JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."),
-                            tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
-                    return;
-                }
-                subjectSelection = new ArrayList<OsmPrimitive>(subjectDataSet.getSelected());
-                if (subjectSelection.isEmpty()) {
-                    JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."),
-                            tr("Empty selection"), JOptionPane.ERROR_MESSAGE);
-                    return;
-                }
-
-                int numNodes = 0;
-                int numWays = 0;
-                int numRelations = 0;
-                for (OsmPrimitive p : subjectSelection) {
-                    switch (p.getType()) {
-                        case NODE:
-                            numNodes++;
-                            break;
-                        case WAY:
-                            numWays++;
-                            break;
-                        case RELATION:
-                            numRelations++;
-                            break;
-                    }
-                }
-
-                // FIXME: translate correctly
-                subjectLayerLabel.setText(subjectLayer.getName());
-                subjectSelectionLabel.setText(String.format("Rel.: %d / Ways: %d / Nodes: %d", numRelations, numWays, numNodes));
-            }
-        }
-
-        class FreezeReferenceAction extends JosmAction {
-
-            public FreezeReferenceAction() {
-                super(tr("Freeze"), null, tr("Freeze subject selection"), null, false);
-            }
-
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if (referenceDataSet != null && referenceDataSet == Main.main.getCurrentDataSet()) {
-//                referenceDataSet.removeDataSetListener(this); FIXME:
-                }
-                referenceDataSet = Main.main.getCurrentDataSet();
-//            referenceDataSet.addDataSetListener(this); FIXME:
-                referenceLayer = Main.main.getEditLayer();
-                if (referenceDataSet == null || referenceLayer == null) {
-                    JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."),
-                            tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
-                    return;
-                }
-                referenceSelection = new ArrayList<OsmPrimitive>(referenceDataSet.getSelected());
-                if (referenceSelection.isEmpty()) {
-                    JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."),
-                            tr("Empty selection"), JOptionPane.ERROR_MESSAGE);
-                    return;
-                }
-
-                int numNodes = 0;
-                int numWays = 0;
-                int numRelations = 0;
-                for (OsmPrimitive p : referenceSelection) {
-                    switch (p.getType()) {
-                        case NODE:
-                            numNodes++;
-                            break;
-                        case WAY:
-                            numWays++;
-                            break;
-                        case RELATION:
-                            numRelations++;
-                            break;
-                    }
-                }
-
-                // FIXME: translate correctly
-                referenceLayerLabel.setText(referenceLayer.getName());
-                referenceSelectionLabel.setText(String.format("Rel.: %d / Ways: %d / Nodes: %d", numRelations, numWays, numNodes));
-            }
-        }
-    }
 
     @Override
@@ -533,5 +237,4 @@
             }
         }
-        tableModel.fireTableDataChanged();
     }
 
@@ -559,3 +262,67 @@
     public void dataChanged(DataChangedEvent event) {
     }
+
+    private ConflationCandidateList generateCandidates(ConflationSettings settings) {
+        ConflationCandidateList cands = new ConflationCandidateList();
+
+        // some initialization
+        int n = settings.getSubjectSelection().size();
+        int m = settings.getReferenceSelection().size();
+        double[][] cost = new double[n][m];
+        // calculate cost matrix
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < m; j++) {
+                cost[i][j] = ConflationUtils.calcCost(
+                        settings.getSubjectSelection().get(i), settings.getReferenceSelection().get(j));
+            }
+        }
+        // perform assignment using Hungarian algorithm
+        int[][] assignment = HungarianAlgorithm.hgAlgorithm(cost, "min");
+        OsmPrimitive subObject;
+        OsmPrimitive refObject;
+        for (int i = 0; i < n; i++) {
+            int subIdx = assignment[i][0];
+            int refIdx = assignment[i][1];
+            if (subIdx < n) {
+                subObject = settings.getSubjectSelection().get(subIdx);
+            } else {
+                subObject = null;
+            }
+            if (refIdx < m) {
+                refObject = settings.getReferenceSelection().get(refIdx);
+            } else {
+                refObject = null;
+            }
+            if (subObject != null && refObject != null) {
+                // TODO: do something!
+                if (!(cands.hasCandidate(refObject, subObject) || cands.hasCandidate(subObject, refObject))) {
+                    cands.add(new ConflationCandidate(
+                            refObject, settings.getReferenceLayer(),
+                            subObject, settings.getSubjectLayer(), cost[subIdx][refIdx]));
+                }
+            }
+        }
+        return cands;
+    }
+
+    private void performConflation() {
+        candidates = generateCandidates(settings);
+        tableModel.setCandidates(candidates);
+        candidates.addConflationListChangedListener(tableModel);
+        settings.getSubjectDataSet().addDataSetListener(this);
+        settings.getReferenceDataSet().addDataSetListener(this);
+        // add conflation layer
+        try {
+            if (conflationLayer == null) {
+                conflationLayer = new ConflationLayer();
+                Main.main.addLayer(conflationLayer);
+            }
+        } catch (Exception ex) {
+            JOptionPane.showMessageDialog(Main.parent, ex.toString(), "Error adding conflation layer", JOptionPane.ERROR_MESSAGE);
+        }
+        conflationLayer.setCandidates(candidates);
+//        candidates.addConflationListChangedListener(conflationLayer);
+
+                
+    }
 }
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java	(revision 28036)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java	(revision 28036)
@@ -0,0 +1,269 @@
+package org.openstreetmap.josm.plugins.conflation;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import javax.swing.*;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.osm.*;
+import org.openstreetmap.josm.gui.ExtendedDialog;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+/**
+ * Dialog for selecting objects and configuring conflation settings
+ */
+public class SettingsDialog extends ExtendedDialog {
+
+    private JPanel costsPanel;
+    private JCheckBox distanceCheckBox;
+    private JButton freezeReferenceButton;
+    private JButton freezeSubjectButton;
+    private JPanel jPanel3;
+    private JPanel jPanel5;
+    private JButton restoreReferenceButton;
+    private JButton restoreSubjectButton;
+    private JLabel referenceLayerLabel;
+    private JPanel referencePanel;
+    private JLabel referenceSelectionLabel;
+    private JLabel subjectLayerLabel;
+    private JPanel subjectPanel;
+    private JLabel subjectSelectionLabel;
+    ArrayList<OsmPrimitive> subjectSelection = null;
+    ArrayList<OsmPrimitive> referenceSelection = null;
+    OsmDataLayer referenceLayer;
+    DataSet subjectDataSet;
+    OsmDataLayer subjectLayer;
+    DataSet referenceDataSet;
+
+    public SettingsDialog() {
+        super(Main.parent,
+                tr("Configure conflation settings"),
+                new String[]{tr("Conflate"), tr("Cancel")},
+                false);
+        initComponents();
+    }
+
+    /**
+     * Build GUI components
+     */
+    private void initComponents() {
+        referencePanel = new JPanel();
+        referenceLayerLabel = new JLabel();
+        referenceSelectionLabel = new JLabel();
+        jPanel3 = new JPanel();
+        restoreReferenceButton = new JButton(new RestoreReferenceAction());
+        freezeReferenceButton = new JButton(new FreezeReferenceAction());
+        subjectPanel = new JPanel();
+        subjectLayerLabel = new JLabel();
+        subjectSelectionLabel = new JLabel();
+        jPanel5 = new JPanel();
+        restoreSubjectButton = new JButton(new RestoreSubjectAction());
+        freezeSubjectButton = new JButton(new FreezeSubjectAction());
+        costsPanel = new JPanel();
+        distanceCheckBox = new JCheckBox();
+        JPanel pnl = new JPanel();
+        pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS));
+        referencePanel.setBorder(BorderFactory.createTitledBorder(tr("Reference")));
+        referencePanel.setLayout(new BoxLayout(referencePanel, BoxLayout.PAGE_AXIS));
+        referenceLayerLabel.setText("(none)");
+        referencePanel.add(referenceLayerLabel);
+        referenceSelectionLabel.setText("Rel.:0 / Ways:0 / Nodes: 0");
+        referencePanel.add(referenceSelectionLabel);
+        jPanel3.setLayout(new BoxLayout(jPanel3, BoxLayout.LINE_AXIS));
+        restoreReferenceButton.setText(tr("Restore"));
+        jPanel3.add(restoreReferenceButton);
+        jPanel3.add(freezeReferenceButton);
+        referencePanel.add(jPanel3);
+        pnl.add(referencePanel);
+        subjectPanel.setBorder(BorderFactory.createTitledBorder(tr("Subject")));
+        subjectPanel.setLayout(new BoxLayout(subjectPanel, BoxLayout.PAGE_AXIS));
+        subjectLayerLabel.setText("(none)");
+        subjectPanel.add(subjectLayerLabel);
+        subjectSelectionLabel.setText("Rel.:0 / Ways:0 / Nodes: 0");
+        subjectPanel.add(subjectSelectionLabel);
+        jPanel5.setLayout(new BoxLayout(jPanel5, BoxLayout.LINE_AXIS));
+        restoreSubjectButton.setText(tr("Restore"));
+        jPanel5.add(restoreSubjectButton);
+        freezeSubjectButton.setText(tr("Freeze"));
+        jPanel5.add(freezeSubjectButton);
+        subjectPanel.add(jPanel5);
+        pnl.add(subjectPanel);
+        costsPanel.setBorder(BorderFactory.createTitledBorder(tr("Costs")));
+        costsPanel.setLayout(new BoxLayout(costsPanel, BoxLayout.LINE_AXIS));
+        distanceCheckBox.setSelected(true);
+        distanceCheckBox.setText(tr("Distance"));
+        distanceCheckBox.setEnabled(false);
+        costsPanel.add(distanceCheckBox);
+        pnl.add(costsPanel);
+        setContent(pnl);
+        setupDialog();
+    }
+
+    @Override
+    protected void buttonAction(int buttonIndex, ActionEvent evt) {
+        super.buttonAction(buttonIndex, evt);
+        if (buttonIndex == 0) {
+        }
+    }
+
+    /**
+     * @return the settings
+     */
+    public ConflationSettings getSettings() {
+        ConflationSettings settings = new ConflationSettings();
+        settings.setReferenceDataSet(referenceDataSet);
+        settings.setReferenceLayer(referenceLayer);
+        settings.setReferenceSelection(referenceSelection);
+        settings.setSubjectDataSet(subjectDataSet);
+        settings.setSubjectLayer(subjectLayer);
+        settings.setSubjectSelection(subjectSelection);
+        return settings;
+    }
+
+    /**
+     * @param settings the settings to set
+     */
+    public void setSettings(ConflationSettings settings) {
+        referenceDataSet = settings.getReferenceDataSet();
+        referenceLayer = settings.getReferenceLayer();
+        referenceSelection = settings.getReferenceSelection();
+        subjectDataSet = settings.getSubjectDataSet();
+        subjectLayer = settings.getSubjectLayer();
+        subjectSelection = settings.getSubjectSelection();
+        update();
+    }
+
+    class RestoreSubjectAction extends JosmAction {
+
+        public RestoreSubjectAction() {
+            super(tr("Restore"), null, tr("Restore subject selection"), null, false);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (subjectLayer != null && subjectDataSet != null && subjectSelection != null && !subjectSelection.isEmpty()) {
+                Main.map.mapView.setActiveLayer(subjectLayer);
+                subjectLayer.setVisible(true);
+                subjectDataSet.setSelected(subjectSelection);
+            }
+        }
+    }
+
+    class RestoreReferenceAction extends JosmAction {
+
+        public RestoreReferenceAction() {
+            super(tr("Restore"), null, tr("Restore reference selection"), null, false);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (referenceLayer != null && referenceDataSet != null && referenceSelection != null && !referenceSelection.isEmpty()) {
+                Main.map.mapView.setActiveLayer(referenceLayer);
+                referenceLayer.setVisible(true);
+                referenceDataSet.setSelected(referenceSelection);
+            }
+        }
+    }
+
+    class FreezeSubjectAction extends JosmAction {
+
+        public FreezeSubjectAction() {
+            super(tr("Freeze"), null, tr("Freeze subject selection"), null, false);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (subjectDataSet != null && subjectDataSet == Main.main.getCurrentDataSet()) {
+                //                subjectDataSet.removeDataSetListener(this); FIXME:
+                //                subjectDataSet.removeDataSetListener(this); FIXME:
+            }
+            subjectDataSet = Main.main.getCurrentDataSet();
+            //            subjectDataSet.addDataSetListener(tableModel); FIXME:
+            //            subjectDataSet.addDataSetListener(tableModel); FIXME:
+            subjectLayer = Main.main.getEditLayer();
+            if (subjectDataSet == null || subjectLayer == null) {
+                JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."), tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+            subjectSelection = new ArrayList<OsmPrimitive>(subjectDataSet.getSelected());
+            if (subjectSelection.isEmpty()) {
+                JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."), tr("Empty selection"), JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+            update();
+        }
+    }
+
+    class FreezeReferenceAction extends JosmAction {
+
+        public FreezeReferenceAction() {
+            super(tr("Freeze"), null, tr("Freeze subject selection"), null, false);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (referenceDataSet != null && referenceDataSet == Main.main.getCurrentDataSet()) {
+                //                referenceDataSet.removeDataSetListener(this); FIXME:
+                //                referenceDataSet.removeDataSetListener(this); FIXME:
+            }
+            referenceDataSet = Main.main.getCurrentDataSet();
+            //            referenceDataSet.addDataSetListener(this); FIXME:
+            //            referenceDataSet.addDataSetListener(this); FIXME:
+            referenceLayer = Main.main.getEditLayer();
+            if (referenceDataSet == null || referenceLayer == null) {
+                JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."), tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+            referenceSelection = new ArrayList<OsmPrimitive>(referenceDataSet.getSelected());
+            if (referenceSelection.isEmpty()) {
+                JOptionPane.showMessageDialog(Main.parent, tr("Nothing is selected, please try again."), tr("Empty selection"), JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+            update();
+        }
+    }
+
+    /**
+     * Update GUI elements
+     */
+    void update() {
+        int numNodes = 0;
+        int numWays = 0;
+        int numRelations = 0;
+
+        if (subjectSelection != null) {
+            for (OsmPrimitive p : subjectSelection) {
+                if (p instanceof Node) {
+                    numNodes++;
+                } else if (p instanceof Way) {
+                    numWays++;
+                } else if (p instanceof Relation) {
+                    numRelations++;
+                }
+            }
+            // FIXME: translate correctly
+            subjectLayerLabel.setText(subjectLayer.getName());
+            subjectSelectionLabel.setText(String.format("Rel.: %d / Ways: %d / Nodes: %d", numRelations, numWays, numNodes));
+        }
+        numNodes = 0;
+        numWays = 0;
+        numRelations = 0;
+        if (referenceSelection != null) {
+            for (OsmPrimitive p : referenceSelection) {
+                if (p instanceof Node) {
+                    numNodes++;
+                } else if (p instanceof Way) {
+                    numWays++;
+                } else if (p instanceof Relation) {
+                    numRelations++;
+                }
+            }
+
+            // FIXME: translate correctly
+            referenceLayerLabel.setText(referenceLayer.getName());
+            referenceSelectionLabel.setText(String.format("Rel.: %d / Ways: %d / Nodes: %d", numRelations, numWays, numNodes));
+        }
+    }
+}
