Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationAction.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationAction.java	(revision 26019)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationAction.java	(revision 26023)
@@ -8,6 +8,4 @@
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import javax.swing.JOptionPane;
@@ -15,12 +13,4 @@
 
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
-import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
-import org.openstreetmap.josm.actions.search.SearchCompiler;
-import org.openstreetmap.josm.data.conflict.ConflictCollection;
-import org.openstreetmap.josm.data.coor.EastNorth;
-import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -28,6 +18,4 @@
 //@SuppressWarnings("serial")
 public class ConflationAction extends JosmAction {
-    ConflictCollection conflicts;
-
     public ConflationAction() {
         super(tr("Conflation"), "conflation", tr("Conflation tool for merging data"),
@@ -38,5 +26,4 @@
         //DataSet.selListeners.add(this);
 
-        conflicts = new ConflictCollection();
     }
 
@@ -57,145 +44,4 @@
         ConflationOptionsDialog conflationDialog = new ConflationOptionsDialog(Main.parent, layerList);
         conflationDialog.setVisible(true);
-
-        if (conflationDialog.isCanceled()) {
-            return;
-        }
-
-        // get layer and filter settings
-        final OsmDataLayer refLayer = conflationDialog.getPanel().getRefLayer();
-        final OsmDataLayer nonRefLayer = conflationDialog.getPanel().getNonRefLayer();
-        SearchSetting refSearchSetting = conflationDialog.getPanel().getRefSearchSetting();
-        SearchSetting nonRefSearchSetting = conflationDialog.getPanel().getNonRefSearchSetting();
-
-        // apply filter criteria to each layer
-        Collection<OsmPrimitive> refColl = getSelection(refSearchSetting, refLayer.data);
-        Collection<OsmPrimitive> nonRefColl = getSelection(nonRefSearchSetting, nonRefLayer.data);
-
-        if (refColl.isEmpty() || nonRefColl.isEmpty()) {
-            JOptionPane.showMessageDialog(Main.parent, tr("At least one layer has no primitives given current filter settings."),
-                    tr("Cannot perform conflation"), JOptionPane.ERROR_MESSAGE);
-            return;
-        }
-
-        ArrayList<OsmPrimitive> refList = new ArrayList<OsmPrimitive>(refColl);
-        ArrayList<OsmPrimitive> nonRefList = new ArrayList<OsmPrimitive>(nonRefColl);
-
-        int n = refList.size();
-        int m = nonRefList.size();
-        int maxLen = Math.max(n, m);
-        double cost[][] = new double[maxLen][maxLen];
-
-        // calculate cost matrix
-        for (int i = 0; i < n; i++) {
-            for (int j = 0; j < m; j++) {
-                cost[i][j] = calcCost(refList.get(i), nonRefList.get(j));
-            }
-        }
-
-        // perform assignment using Hungarian algorithm
-        int[][] assignment = new int[maxLen][2];
-        assignment = HungarianAlgorithm.hgAlgorithm(cost, "min");
-
-        // create array of primitives based on indices from assignment
-        OsmPrimitive[][] pairs = new OsmPrimitive[maxLen][2];
-        for (int i = 0; i < maxLen; i++) {
-            if (assignment[i][0] < n)
-                pairs[i][0] = refList.get(assignment[i][0]);
-            else
-                pairs[i][0] = null;
-            if (assignment[i][1] < m)
-                pairs[i][1] = nonRefList.get(assignment[i][1]);
-            else
-                pairs[i][1] = null;
-
-            if (pairs[i][0] != null && pairs[i][1] != null) {
-                conflicts.add(pairs[i][0], pairs[i][1]);
-            }
-        }
-
-        // add conflation layer
-        try {
-            ConflationLayer conflationLayer = new ConflationLayer(refLayer.data, conflicts);
-            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
-
-
-    }
-
-    /**
-     * Get selection of primitives for a given layer based on filter settings.
-     *
-     * @param   s    the given <code>SearchSetting</code>'s.
-     * @param   ds   the <code>DataSet</code> of the selected <code>Layer</code>.
-     */
-    public static Collection<OsmPrimitive> getSelection(SearchSetting s, DataSet ds) {
-        Collection<OsmPrimitive> sel = new ArrayList<OsmPrimitive>();
-        try {
-            String searchText = s.text;
-            SearchCompiler.Match matcher = SearchCompiler.compile(searchText, s.caseSensitive, s.regexSearch);
-
-            Collection<OsmPrimitive> all;
-            if (s.allElements)
-                all = ds.allPrimitives();
-            else
-                all = ds.allNonDeletedCompletePrimitives();
-
-            if (s.mode != SearchMode.replace)
-                sel = ds.getSelected();
-
-            for (OsmPrimitive osm : all) {
-                if (s.mode == SearchMode.replace) {
-                    if (matcher.match(osm)) {
-                        sel.add(osm);
-                    }
-                } else if (s.mode == SearchMode.add && !ds.isSelected(osm) && matcher.match(osm)) {
-                    sel.add(osm);
-                } else if (s.mode == SearchMode.remove && ds.isSelected(osm) && matcher.match(osm)) {
-                    sel.remove(osm);
-                } else if (s.mode == SearchMode.in_selection && ds.isSelected(osm)&& !matcher.match(osm)) {
-                    sel.remove(osm);
-                }
-            }
-        } catch (SearchCompiler.ParseError e) {
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    e.getMessage(),
-                    tr("Error"),
-                    JOptionPane.ERROR_MESSAGE
-
-            );
-        }
-        return sel;
-    }
-
-    public static EastNorth getCenter(OsmPrimitive prim) {
-            LatLon center = prim.getBBox().getTopLeft().getCenter(prim.getBBox().getBottomRight());
-            return Main.map.mapView.getProjection().latlon2eastNorth(center);
-    }
-
-    /**
-     * Calculate the cost of a pair of <code>OsmPrimitive</code>'s. A
-     * simple cost consisting of the Euclidean distance is used
-     * now, later we can also use dissimilarity between tags.
-     *
-     * @param   refPrim      the reference <code>OsmPrimitive</code>.
-     * @param   nonRefPrim   the non-reference <code>OsmPrimitive</code>.
-     */
-    public double calcCost(OsmPrimitive refPrim, OsmPrimitive nonRefPrim) {
-        double dist;
-        try {
-            dist = getCenter(refPrim).distance(getCenter(nonRefPrim));
-        } catch (Exception e) {
-            dist = 1000; // FIXME: what number to use?
-        }
-
-        // TODO: use other "distance" measures, i.e. matching tags
-        return dist;
     }
 }
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 26019)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationLayer.java	(revision 26023)
@@ -67,7 +67,7 @@
             OsmPrimitive q = c.getTheir();
             if (p != null && q != null) {
-                // we have a pair, so draw line between them
-                Point p1 = mv.getPoint(ConflationAction.getCenter(p));
-                Point p2 = mv.getPoint(ConflationAction.getCenter(q));
+                // we have a pair, so draw line between them, FIXME: not good to use getCenter() from here, move to utils?
+                Point p1 = mv.getPoint(ConflationOptionsPanel.getCenter(p));
+                Point p2 = mv.getPoint(ConflationOptionsPanel.getCenter(q));
                 path.moveTo(p1.x, p1.y);
                 path.lineTo(p2.x, p2.y);
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsDialog.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsDialog.java	(revision 26019)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsDialog.java	(revision 26023)
@@ -26,5 +26,5 @@
 
     public ConflationOptionsDialog(Component parent, List<OsmDataLayer> layers) {
-        super(JOptionPane.getFrameForComponent(parent),tr("Conflation Options"), ModalityType.DOCUMENT_MODAL);
+        super(JOptionPane.getFrameForComponent(parent),tr("Conflation Options"), ModalityType.MODELESS);
         getContentPane().setLayout(new BorderLayout());
         panel = new ConflationOptionsPanel(this, layers);
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form	(revision 26019)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.form	(revision 26023)
@@ -1,11 +1,5 @@
 <?xml version="1.1" encoding="UTF-8" ?>
 
-<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
-  <NonVisualComponents>
-    <Component class="javax.swing.ButtonGroup" name="refSearchModeButtonGroup">
-    </Component>
-    <Component class="javax.swing.ButtonGroup" name="nonRefSearchModeButtonGroup">
-    </Component>
-  </NonVisualComponents>
+<Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
   <AuxValues>
     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
@@ -18,5 +12,5 @@
     <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
     <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-46,0,0,1,86"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,4,0,0,2,-102"/>
   </AuxValues>
 
@@ -75,5 +69,5 @@
                 <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
                   <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
-                    <TitledBorder title="Reference Set"/>
+                    <TitledBorder title="My Set"/>
                   </Border>
                 </Property>
@@ -83,195 +77,122 @@
                 <DimensionLayout dim="0">
                   <Group type="103" groupAlignment="0" attributes="0">
-                      <Component id="jPanel4" alignment="0" max="32767" attributes="0"/>
+                      <Group type="102" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Group type="102" attributes="0">
+                                  <Component id="freezeMySetButton" min="-2" max="-2" attributes="0"/>
+                                  <EmptySpace pref="387" max="32767" attributes="0"/>
+                                  <Component id="restoreMySetButton" min="-2" max="-2" attributes="0"/>
+                              </Group>
+                              <Group type="102" alignment="0" attributes="0">
+                                  <Group type="103" groupAlignment="0" attributes="0">
+                                      <Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                                  </Group>
+                                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                                  <Group type="103" groupAlignment="0" attributes="0">
+                                      <Component id="myLayerLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="myNodeCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="myWayCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="myRelationCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                  </Group>
+                              </Group>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                      </Group>
                   </Group>
                 </DimensionLayout>
                 <DimensionLayout dim="1">
                   <Group type="103" groupAlignment="0" attributes="0">
-                      <Component id="jPanel4" min="-2" max="-2" attributes="0"/>
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="freezeMySetButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="restoreMySetButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="myLayerLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="myNodeCountLabel" alignment="3" min="-2" pref="14" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="myWayCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="myRelationCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace pref="38" max="32767" attributes="0"/>
+                      </Group>
                   </Group>
                 </DimensionLayout>
               </Layout>
               <SubComponents>
-                <Container class="javax.swing.JPanel" name="jPanel4">
-
-                  <Layout>
-                    <DimensionLayout dim="0">
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Group type="102" attributes="0">
-                              <Group type="103" groupAlignment="0" attributes="0">
-                                  <Group type="102" attributes="0">
-                                      <EmptySpace max="-2" attributes="0"/>
-                                      <Group type="103" groupAlignment="0" attributes="0">
-                                          <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
-                                          <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      </Group>
-                                      <EmptySpace type="separate" max="-2" attributes="0"/>
-                                      <Group type="103" groupAlignment="0" attributes="0">
-                                          <Component id="refLayerComboBox" pref="246" max="32767" attributes="0"/>
-                                          <Component id="refFilterTextField" alignment="0" pref="246" max="32767" attributes="0"/>
-                                      </Group>
-                                  </Group>
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <Component id="jPanel5" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                                      <Group type="103" groupAlignment="0" attributes="0">
-                                          <Component id="refCaseSensitiveCheckBox" min="-2" max="-2" attributes="0"/>
-                                          <Component id="refAllObjectsCheckBox" min="-2" max="-2" attributes="0"/>
-                                          <Component id="refRegExCheckBox" min="-2" max="-2" attributes="0"/>
-                                      </Group>
-                                  </Group>
-                              </Group>
-                              <EmptySpace max="-2" attributes="0"/>
-                          </Group>
-                      </Group>
-                    </DimensionLayout>
-                    <DimensionLayout dim="1">
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Group type="102" alignment="0" attributes="0">
-                              <EmptySpace max="32767" attributes="0"/>
-                              <Group type="103" groupAlignment="3" attributes="0">
-                                  <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
-                                  <Component id="refLayerComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <EmptySpace max="-2" attributes="0"/>
-                              <Group type="103" groupAlignment="3" attributes="0">
-                                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
-                                  <Component id="refFilterTextField" alignment="3" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <EmptySpace max="-2" attributes="0"/>
-                              <Group type="103" groupAlignment="0" attributes="0">
-                                  <Component id="jPanel5" min="-2" max="-2" attributes="0"/>
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <Component id="refCaseSensitiveCheckBox" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="refAllObjectsCheckBox" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="refRegExCheckBox" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                              </Group>
-                          </Group>
-                      </Group>
-                    </DimensionLayout>
-                  </Layout>
-                  <SubComponents>
-                    <Component class="javax.swing.JLabel" name="jLabel1">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Layer"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JComboBox" name="refLayerComboBox">
-                      <Properties>
-                        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
-                          <StringArray count="4">
-                            <StringItem index="0" value="Item 1"/>
-                            <StringItem index="1" value="Item 2"/>
-                            <StringItem index="2" value="Item 3"/>
-                            <StringItem index="3" value="Item 4"/>
-                          </StringArray>
-                        </Property>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JLabel" name="jLabel2">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Filter"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JTextField" name="refFilterTextField">
-                    </Component>
-                    <Container class="javax.swing.JPanel" name="jPanel5">
-                      <Properties>
-                        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
-                          <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
-                            <EtchetBorder/>
-                          </Border>
-                        </Property>
-                      </Properties>
-
-                      <Layout>
-                        <DimensionLayout dim="0">
-                          <Group type="103" groupAlignment="0" attributes="0">
-                              <Group type="102" attributes="0">
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Group type="103" groupAlignment="0" attributes="0">
-                                      <Component id="refReplaceRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="refAddRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="refRemoveRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="refInSelectionRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                                  <EmptySpace max="32767" attributes="0"/>
-                              </Group>
-                          </Group>
-                        </DimensionLayout>
-                        <DimensionLayout dim="1">
-                          <Group type="103" groupAlignment="0" attributes="0">
-                              <Group type="102" alignment="0" attributes="0">
-                                  <EmptySpace max="32767" attributes="0"/>
-                                  <Component id="refReplaceRadio" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Component id="refAddRadio" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Component id="refRemoveRadio" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Component id="refInSelectionRadio" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                          </Group>
-                        </DimensionLayout>
-                      </Layout>
-                      <SubComponents>
-                        <Component class="javax.swing.JRadioButton" name="refReplaceRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="refSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="selected" type="boolean" value="true"/>
-                            <Property name="text" type="java.lang.String" value="Replace selection"/>
-                          </Properties>
-                        </Component>
-                        <Component class="javax.swing.JRadioButton" name="refAddRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="refSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="text" type="java.lang.String" value="Add to selection"/>
-                          </Properties>
-                          <Events>
-                            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="refAddRadioActionPerformed"/>
-                          </Events>
-                        </Component>
-                        <Component class="javax.swing.JRadioButton" name="refRemoveRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="refSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="text" type="java.lang.String" value="Remove from selection"/>
-                          </Properties>
-                        </Component>
-                        <Component class="javax.swing.JRadioButton" name="refInSelectionRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="refSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="text" type="java.lang.String" value="Find in selection"/>
-                          </Properties>
-                        </Component>
-                      </SubComponents>
-                    </Container>
-                    <Component class="javax.swing.JCheckBox" name="refCaseSensitiveCheckBox">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Case sensitive"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JCheckBox" name="refAllObjectsCheckBox">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="All objects"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JCheckBox" name="refRegExCheckBox">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Regular expression"/>
-                      </Properties>
-                    </Component>
-                  </SubComponents>
-                </Container>
+                <Component class="javax.swing.JButton" name="freezeMySetButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Freeze Selection"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="freezeMySetButtonActionPerformed"/>
+                  </Events>
+                </Component>
+                <Component class="javax.swing.JButton" name="restoreMySetButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Restore Selection"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="restoreMySetButtonActionPerformed"/>
+                  </Events>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel1">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Nodes"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel2">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Layer"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel3">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Ways"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel4">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Relations"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="myRelationCountLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="0"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="myWayCountLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="0"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="myNodeCountLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="0"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="myLayerLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="(invalid)"/>
+                  </Properties>
+                </Component>
               </SubComponents>
             </Container>
@@ -280,5 +201,5 @@
                 <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
                   <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
-                    <TitledBorder title="Non-Reference Set"/>
+                    <TitledBorder title="Their Set"/>
                   </Border>
                 </Property>
@@ -288,195 +209,122 @@
                 <DimensionLayout dim="0">
                   <Group type="103" groupAlignment="0" attributes="0">
-                      <Component id="jPanel7" alignment="0" max="32767" attributes="0"/>
+                      <Group type="102" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Group type="102" alignment="1" attributes="0">
+                                  <Component id="freezeTheirSelectionButton" min="-2" max="-2" attributes="0"/>
+                                  <EmptySpace pref="387" max="32767" attributes="0"/>
+                                  <Component id="restoreTheirSetButton" min="-2" max="-2" attributes="0"/>
+                              </Group>
+                              <Group type="102" alignment="0" attributes="0">
+                                  <Group type="103" groupAlignment="0" attributes="0">
+                                      <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="jLabel9" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="jLabel6" alignment="0" min="-2" max="-2" attributes="0"/>
+                                  </Group>
+                                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                                  <Group type="103" groupAlignment="0" attributes="0">
+                                      <Component id="theirLayerLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="theirNodeCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="theirWayCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                      <Component id="theirRelationCountLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                                  </Group>
+                              </Group>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                      </Group>
                   </Group>
                 </DimensionLayout>
                 <DimensionLayout dim="1">
                   <Group type="103" groupAlignment="0" attributes="0">
-                      <Component id="jPanel7" min="-2" max="-2" attributes="0"/>
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="freezeTheirSelectionButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="restoreTheirSetButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="theirLayerLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="theirNodeCountLabel" alignment="3" min="-2" pref="14" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="theirWayCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="theirRelationCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace pref="32" max="32767" attributes="0"/>
+                      </Group>
                   </Group>
                 </DimensionLayout>
               </Layout>
               <SubComponents>
-                <Container class="javax.swing.JPanel" name="jPanel7">
-
-                  <Layout>
-                    <DimensionLayout dim="0">
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Group type="102" alignment="0" attributes="0">
-                              <Group type="103" groupAlignment="0" attributes="0">
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <EmptySpace max="-2" attributes="0"/>
-                                      <Group type="103" groupAlignment="0" attributes="0">
-                                          <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
-                                          <Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      </Group>
-                                      <EmptySpace type="separate" max="-2" attributes="0"/>
-                                      <Group type="103" groupAlignment="0" attributes="0">
-                                          <Component id="nonRefLayerComboBox" alignment="0" pref="246" max="32767" attributes="0"/>
-                                          <Component id="nonRefFilterTextField" alignment="0" pref="246" max="32767" attributes="0"/>
-                                      </Group>
-                                  </Group>
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <Component id="jPanel8" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                                      <Group type="103" groupAlignment="0" attributes="0">
-                                          <Component id="nonRefCaseSensitiveCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
-                                          <Component id="nonRefAllObjectsCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
-                                          <Component id="nonRefRegExCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      </Group>
-                                  </Group>
-                              </Group>
-                              <EmptySpace max="-2" attributes="0"/>
-                          </Group>
-                      </Group>
-                    </DimensionLayout>
-                    <DimensionLayout dim="1">
-                      <Group type="103" groupAlignment="0" attributes="0">
-                          <Group type="102" alignment="0" attributes="0">
-                              <EmptySpace max="32767" attributes="0"/>
-                              <Group type="103" groupAlignment="3" attributes="0">
-                                  <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
-                                  <Component id="nonRefLayerComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <EmptySpace max="-2" attributes="0"/>
-                              <Group type="103" groupAlignment="3" attributes="0">
-                                  <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
-                                  <Component id="nonRefFilterTextField" alignment="3" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                              <EmptySpace max="-2" attributes="0"/>
-                              <Group type="103" groupAlignment="0" attributes="0">
-                                  <Component id="jPanel8" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <Component id="nonRefCaseSensitiveCheckBox" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="nonRefAllObjectsCheckBox" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="nonRefRegExCheckBox" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                              </Group>
-                          </Group>
-                      </Group>
-                    </DimensionLayout>
-                  </Layout>
-                  <SubComponents>
-                    <Component class="javax.swing.JLabel" name="jLabel3">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Layer"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JComboBox" name="nonRefLayerComboBox">
-                      <Properties>
-                        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
-                          <StringArray count="4">
-                            <StringItem index="0" value="Item 1"/>
-                            <StringItem index="1" value="Item 2"/>
-                            <StringItem index="2" value="Item 3"/>
-                            <StringItem index="3" value="Item 4"/>
-                          </StringArray>
-                        </Property>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JLabel" name="jLabel4">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Filter"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JTextField" name="nonRefFilterTextField">
-                    </Component>
-                    <Container class="javax.swing.JPanel" name="jPanel8">
-                      <Properties>
-                        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
-                          <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
-                            <EtchetBorder/>
-                          </Border>
-                        </Property>
-                      </Properties>
-
-                      <Layout>
-                        <DimensionLayout dim="0">
-                          <Group type="103" groupAlignment="0" attributes="0">
-                              <Group type="102" alignment="0" attributes="0">
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Group type="103" groupAlignment="0" attributes="0">
-                                      <Component id="nonRefReplaceRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="nonRefAddRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="nonRefRemoveRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                      <Component id="nonRefInSelectionRadio" alignment="0" min="-2" max="-2" attributes="0"/>
-                                  </Group>
-                                  <EmptySpace max="32767" attributes="0"/>
-                              </Group>
-                          </Group>
-                        </DimensionLayout>
-                        <DimensionLayout dim="1">
-                          <Group type="103" groupAlignment="0" attributes="0">
-                              <Group type="102" alignment="0" attributes="0">
-                                  <EmptySpace max="32767" attributes="0"/>
-                                  <Component id="nonRefReplaceRadio" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Component id="nonRefAddRadio" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Component id="nonRefRemoveRadio" min="-2" max="-2" attributes="0"/>
-                                  <EmptySpace max="-2" attributes="0"/>
-                                  <Component id="nonRefInSelectionRadio" min="-2" max="-2" attributes="0"/>
-                              </Group>
-                          </Group>
-                        </DimensionLayout>
-                      </Layout>
-                      <SubComponents>
-                        <Component class="javax.swing.JRadioButton" name="nonRefReplaceRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="nonRefSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="selected" type="boolean" value="true"/>
-                            <Property name="text" type="java.lang.String" value="Replace selection"/>
-                          </Properties>
-                        </Component>
-                        <Component class="javax.swing.JRadioButton" name="nonRefAddRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="nonRefSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="text" type="java.lang.String" value="Add to selection"/>
-                          </Properties>
-                          <Events>
-                            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="nonRefAddRadioActionPerformed"/>
-                          </Events>
-                        </Component>
-                        <Component class="javax.swing.JRadioButton" name="nonRefRemoveRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="nonRefSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="text" type="java.lang.String" value="Remove from selection"/>
-                          </Properties>
-                        </Component>
-                        <Component class="javax.swing.JRadioButton" name="nonRefInSelectionRadio">
-                          <Properties>
-                            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
-                              <ComponentRef name="nonRefSearchModeButtonGroup"/>
-                            </Property>
-                            <Property name="text" type="java.lang.String" value="Find in selection"/>
-                          </Properties>
-                        </Component>
-                      </SubComponents>
-                    </Container>
-                    <Component class="javax.swing.JCheckBox" name="nonRefCaseSensitiveCheckBox">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Case sensitive"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JCheckBox" name="nonRefAllObjectsCheckBox">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="All objects"/>
-                      </Properties>
-                    </Component>
-                    <Component class="javax.swing.JCheckBox" name="nonRefRegExCheckBox">
-                      <Properties>
-                        <Property name="text" type="java.lang.String" value="Regular expression"/>
-                      </Properties>
-                    </Component>
-                  </SubComponents>
-                </Container>
+                <Component class="javax.swing.JButton" name="freezeTheirSelectionButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Freeze Selection"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="freezeTheirSelectionButtonActionPerformed"/>
+                  </Events>
+                </Component>
+                <Component class="javax.swing.JButton" name="restoreTheirSetButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Restore Selection"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="restoreTheirSetButtonActionPerformed"/>
+                  </Events>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel5">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Relations"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel6">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Layer"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel7">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Nodes"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel9">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Ways"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="theirNodeCountLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="0"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="theirLayerLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="(invalid)"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="theirWayCountLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="0"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="theirRelationCountLabel">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="0"/>
+                  </Properties>
+                </Component>
               </SubComponents>
             </Container>
@@ -513,7 +361,12 @@
               <Group type="103" groupAlignment="0" attributes="0">
                   <Group type="102" alignment="1" attributes="0">
-                      <EmptySpace pref="254" max="32767" attributes="0"/>
+                      <EmptySpace pref="578" max="32767" attributes="0"/>
                       <Component id="criteriaTabConflateButton" min="-2" max="-2" attributes="0"/>
                       <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace pref="292" max="32767" attributes="0"/>
                   </Group>
               </Group>
@@ -522,5 +375,7 @@
               <Group type="103" groupAlignment="0" attributes="0">
                   <Group type="102" alignment="1" attributes="0">
-                      <EmptySpace pref="404" max="32767" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace pref="217" max="32767" attributes="0"/>
                       <Component id="criteriaTabConflateButton" min="-2" max="-2" attributes="0"/>
                       <EmptySpace max="-2" attributes="0"/>
@@ -539,7 +394,48 @@
               </Events>
             </Component>
+            <Container class="javax.swing.JPanel" name="jPanel2">
+              <Properties>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
+                    <EtchetBorder/>
+                  </Border>
+                </Property>
+              </Properties>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace pref="282" max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace pref="192" max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Component class="javax.swing.JCheckBox" name="jCheckBox1">
+                  <Properties>
+                    <Property name="selected" type="boolean" value="true"/>
+                    <Property name="text" type="java.lang.String" value="Distance"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBox1ActionPerformed"/>
+                  </Events>
+                </Component>
+              </SubComponents>
+            </Container>
           </SubComponents>
         </Container>
-        <Container class="javax.swing.JPanel" name="jPanel1">
+        <Container class="javax.swing.JPanel" name="resultsPanel">
           <Constraints>
             <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
@@ -550,16 +446,129 @@
           </Constraints>
 
-          <Layout>
-            <DimensionLayout dim="0">
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <EmptySpace min="0" pref="337" max="32767" attributes="0"/>
-              </Group>
-            </DimensionLayout>
-            <DimensionLayout dim="1">
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <EmptySpace min="0" pref="438" max="32767" attributes="0"/>
-              </Group>
-            </DimensionLayout>
+          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
+            <Property name="axis" type="int" value="3"/>
           </Layout>
+          <SubComponents>
+            <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+              <AuxValues>
+                <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+              </AuxValues>
+
+              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+              <SubComponents>
+                <Component class="javax.swing.JTable" name="resultsTable">
+                  <Properties>
+                    <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+                      <Table columnCount="5" rowCount="4">
+                        <Column editable="true" title="Mine" type="java.lang.Object"/>
+                        <Column editable="true" title="Theirs" type="java.lang.Object"/>
+                        <Column editable="true" title="Distance (m)" type="java.lang.Object"/>
+                        <Column editable="true" title="Cost" type="java.lang.Object"/>
+                        <Column editable="true" title="Tags" type="java.lang.Object"/>
+                      </Table>
+                    </Property>
+                    <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
+                      <JTableSelectionModel selectionMode="2"/>
+                    </Property>
+                  </Properties>
+                </Component>
+              </SubComponents>
+            </Container>
+            <Container class="javax.swing.JPanel" name="jPanel1">
+              <Properties>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
+                    <EtchetBorder/>
+                  </Border>
+                </Property>
+              </Properties>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="jLabel8" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Component id="useMyTagsButton" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Component id="useTheirTagsButton" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Component id="jButton1" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace pref="300" max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="useMyTagsButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="useTheirTagsButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Component class="javax.swing.JButton" name="useMyTagsButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="My Tags"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="useMyTagsButtonActionPerformed"/>
+                  </Events>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel8">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Resolve using:"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JButton" name="useTheirTagsButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Their Tags"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JButton" name="jButton1">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Not a match"/>
+                    <Property name="enabled" type="boolean" value="false"/>
+                  </Properties>
+                </Component>
+              </SubComponents>
+            </Container>
+            <Container class="javax.swing.JPanel" name="tagMergerPlaceholderPanel">
+              <Properties>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[661, 250]"/>
+                </Property>
+              </Properties>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <EmptySpace min="0" pref="661" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <EmptySpace min="0" pref="150" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+            </Container>
+            <Component class="javax.swing.JButton" name="resolveButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Resolve"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resolveButtonActionPerformed"/>
+              </Events>
+            </Component>
+          </SubComponents>
         </Container>
       </SubComponents>
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java	(revision 26019)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationOptionsPanel.java	(revision 26023)
@@ -10,12 +10,34 @@
 
 import java.awt.Component;
+import java.util.ArrayList;
+import java.util.HashSet;
 
 import java.util.List;
+import java.util.Set;
 import javax.swing.DefaultListCellRenderer;
 import javax.swing.Icon;
 import javax.swing.JLabel;
 import javax.swing.JList;
-import org.openstreetmap.josm.actions.search.SearchAction;
-import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableCellRenderer;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.data.conflict.Conflict;
+import org.openstreetmap.josm.data.conflict.ConflictCollection;
+import org.openstreetmap.josm.data.conflict.IConflictListener;
+import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.TagCollection;
+import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
+import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
@@ -25,6 +47,18 @@
  * @author Josh
  */
-public class ConflationOptionsPanel extends javax.swing.JPanel {
+public class ConflationOptionsPanel extends javax.swing.JPanel implements IConflictListener {
     ConflationOptionsDialog dlg = null;
+    ConflationLayer conflationLayer = null;
+    DataSet myDataSet = null;
+    DataSet theirDataSet = null;
+    ArrayList<OsmPrimitive> mySelection = null;
+    ArrayList<OsmPrimitive> theirSelection = null;
+    OsmDataLayer myLayer = null;
+    OsmDataLayer theirLayer = null;
+    ConflictCollection conflicts = null;
+    ConflictResolver conflictResolver;
+    OsmPrimitive[][] pairs;
+    int[][] assignment;
+    MatchTableModel tableModel;
 
     /** Creates new form ConflationPanel */
@@ -32,13 +66,36 @@
         initComponents();
 
+        // add selection handler, to change ConflictResolver contents and center/zoom view
+        resultsTable.getSelectionModel().addListSelectionListener(
+                new MatchListSelectionHandler());
+        resultsTable.getColumnModel().getSelectionModel().addListSelectionListener(
+                new MatchListSelectionHandler());
+
+        // FIXME: doesn't work right now
+        ColorTableCellRenderer cr = new ColorTableCellRenderer("Tags");
+        resultsTable.getColumnModel().getColumn(4).setCellRenderer(cr);
+
+        // replace dummy panel with conflictResolver
+        conflictResolver = new ConflictResolver();
+        for (int i = 0; i < resultsPanel.getComponentCount(); i++) {
+            if (resultsPanel.getComponent(i) == tagMergerPlaceholderPanel) {
+                resultsPanel.add(conflictResolver, i);
+                resultsPanel.remove(tagMergerPlaceholderPanel);
+                break;
+            }
+        }
+        resultsPanel.validate();
+
         this.dlg = dlg;
 
+        conflicts = new ConflictCollection();
+
         // set layer names to comboboxes
-        if (layers != null && layers.size() > 0) {
-            refLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(layers.toArray()));
-            refLayerComboBox.setRenderer(new LayerListCellRenderer());
-            nonRefLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(layers.toArray()));
-            nonRefLayerComboBox.setRenderer(new LayerListCellRenderer());
-        }
+//        if (layers != null && layers.size() > 0) {
+//            refLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(layers.toArray()));
+//            refLayerComboBox.setRenderer(new LayerListCellRenderer());
+//            nonRefLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(layers.toArray()));
+//            nonRefLayerComboBox.setRenderer(new LayerListCellRenderer());
+//        }
 
     }
@@ -53,149 +110,78 @@
     private void initComponents() {
 
-        refSearchModeButtonGroup = new javax.swing.ButtonGroup();
-        nonRefSearchModeButtonGroup = new javax.swing.ButtonGroup();
         resultsTabPanel = new javax.swing.JTabbedPane();
         objectTabPanel = new javax.swing.JPanel();
         refSetPanel = new javax.swing.JPanel();
-        jPanel4 = new javax.swing.JPanel();
+        freezeMySetButton = new javax.swing.JButton();
+        restoreMySetButton = new javax.swing.JButton();
         jLabel1 = new javax.swing.JLabel();
-        refLayerComboBox = new javax.swing.JComboBox();
         jLabel2 = new javax.swing.JLabel();
-        refFilterTextField = new javax.swing.JTextField();
-        jPanel5 = new javax.swing.JPanel();
-        refReplaceRadio = new javax.swing.JRadioButton();
-        refAddRadio = new javax.swing.JRadioButton();
-        refRemoveRadio = new javax.swing.JRadioButton();
-        refInSelectionRadio = new javax.swing.JRadioButton();
-        refCaseSensitiveCheckBox = new javax.swing.JCheckBox();
-        refAllObjectsCheckBox = new javax.swing.JCheckBox();
-        refRegExCheckBox = new javax.swing.JCheckBox();
+        jLabel3 = new javax.swing.JLabel();
+        jLabel4 = new javax.swing.JLabel();
+        myRelationCountLabel = new javax.swing.JLabel();
+        myWayCountLabel = new javax.swing.JLabel();
+        myNodeCountLabel = new javax.swing.JLabel();
+        myLayerLabel = new javax.swing.JLabel();
         nonRefSetPanel = new javax.swing.JPanel();
-        jPanel7 = new javax.swing.JPanel();
-        jLabel3 = new javax.swing.JLabel();
-        nonRefLayerComboBox = new javax.swing.JComboBox();
-        jLabel4 = new javax.swing.JLabel();
-        nonRefFilterTextField = new javax.swing.JTextField();
-        jPanel8 = new javax.swing.JPanel();
-        nonRefReplaceRadio = new javax.swing.JRadioButton();
-        nonRefAddRadio = new javax.swing.JRadioButton();
-        nonRefRemoveRadio = new javax.swing.JRadioButton();
-        nonRefInSelectionRadio = new javax.swing.JRadioButton();
-        nonRefCaseSensitiveCheckBox = new javax.swing.JCheckBox();
-        nonRefAllObjectsCheckBox = new javax.swing.JCheckBox();
-        nonRefRegExCheckBox = new javax.swing.JCheckBox();
+        freezeTheirSelectionButton = new javax.swing.JButton();
+        restoreTheirSetButton = new javax.swing.JButton();
+        jLabel5 = new javax.swing.JLabel();
+        jLabel6 = new javax.swing.JLabel();
+        jLabel7 = new javax.swing.JLabel();
+        jLabel9 = new javax.swing.JLabel();
+        theirNodeCountLabel = new javax.swing.JLabel();
+        theirLayerLabel = new javax.swing.JLabel();
+        theirWayCountLabel = new javax.swing.JLabel();
+        theirRelationCountLabel = new javax.swing.JLabel();
         objectTabCancelButton = new javax.swing.JButton();
         objectTabNextButton = new javax.swing.JButton();
         criteriaTabPanel = new javax.swing.JPanel();
         criteriaTabConflateButton = new javax.swing.JButton();
+        jPanel2 = new javax.swing.JPanel();
+        jCheckBox1 = new javax.swing.JCheckBox();
+        resultsPanel = new javax.swing.JPanel();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        resultsTable = new javax.swing.JTable();
         jPanel1 = new javax.swing.JPanel();
+        useMyTagsButton = new javax.swing.JButton();
+        jLabel8 = new javax.swing.JLabel();
+        useTheirTagsButton = new javax.swing.JButton();
+        jButton1 = new javax.swing.JButton();
+        tagMergerPlaceholderPanel = new javax.swing.JPanel();
+        resolveButton = new javax.swing.JButton();
 
         setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));
 
-        refSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Reference Set"));
-
-        jLabel1.setText("Layer");
-
-        refLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
-
-        jLabel2.setText("Filter");
-
-        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
-        refSearchModeButtonGroup.add(refReplaceRadio);
-        refReplaceRadio.setSelected(true);
-        refReplaceRadio.setText("Replace selection");
-
-        refSearchModeButtonGroup.add(refAddRadio);
-        refAddRadio.setText("Add to selection");
-        refAddRadio.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                refAddRadioActionPerformed(evt);
-            }
-        });
-
-        refSearchModeButtonGroup.add(refRemoveRadio);
-        refRemoveRadio.setText("Remove from selection");
-
-        refSearchModeButtonGroup.add(refInSelectionRadio);
-        refInSelectionRadio.setText("Find in selection");
-
-        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
-        jPanel5.setLayout(jPanel5Layout);
-        jPanel5Layout.setHorizontalGroup(
-            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel5Layout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(refReplaceRadio)
-                    .addComponent(refAddRadio)
-                    .addComponent(refRemoveRadio)
-                    .addComponent(refInSelectionRadio))
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-        );
-        jPanel5Layout.setVerticalGroup(
-            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel5Layout.createSequentialGroup()
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(refReplaceRadio)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(refAddRadio)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(refRemoveRadio)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(refInSelectionRadio))
-        );
-
-        refCaseSensitiveCheckBox.setText("Case sensitive");
-
-        refAllObjectsCheckBox.setText("All objects");
-
-        refRegExCheckBox.setText("Regular expression");
-
-        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
-        jPanel4.setLayout(jPanel4Layout);
-        jPanel4Layout.setHorizontalGroup(
-            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel4Layout.createSequentialGroup()
-                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(jPanel4Layout.createSequentialGroup()
-                        .addContainerGap()
-                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(jLabel1)
-                            .addComponent(jLabel2))
-                        .addGap(18, 18, 18)
-                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(refLayerComboBox, 0, 246, Short.MAX_VALUE)
-                            .addComponent(refFilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)))
-                    .addGroup(jPanel4Layout.createSequentialGroup()
-                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(refCaseSensitiveCheckBox)
-                            .addComponent(refAllObjectsCheckBox)
-                            .addComponent(refRegExCheckBox))))
-                .addContainerGap())
-        );
-        jPanel4Layout.setVerticalGroup(
-            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel4Layout.createSequentialGroup()
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel1)
-                    .addComponent(refLayerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
-                    .addComponent(jLabel2)
-                    .addComponent(refFilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addGroup(jPanel4Layout.createSequentialGroup()
-                        .addComponent(refCaseSensitiveCheckBox)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(refAllObjectsCheckBox)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(refRegExCheckBox))))
-        );
+        refSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("My Set"));
+
+        freezeMySetButton.setText("Freeze Selection");
+        freezeMySetButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                freezeMySetButtonActionPerformed(evt);
+            }
+        });
+
+        restoreMySetButton.setText("Restore Selection");
+        restoreMySetButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                restoreMySetButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel1.setText("Nodes");
+
+        jLabel2.setText("Layer");
+
+        jLabel3.setText("Ways");
+
+        jLabel4.setText("Relations");
+
+        myRelationCountLabel.setText("0");
+
+        myWayCountLabel.setText("0");
+
+        myNodeCountLabel.setText("0");
+
+        myLayerLabel.setText("(invalid)");
 
         javax.swing.GroupLayout refSetPanelLayout = new javax.swing.GroupLayout(refSetPanel);
@@ -203,116 +189,82 @@
         refSetPanelLayout.setHorizontalGroup(
             refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+            .addGroup(refSetPanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(refSetPanelLayout.createSequentialGroup()
+                        .addComponent(freezeMySetButton)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 387, Short.MAX_VALUE)
+                        .addComponent(restoreMySetButton))
+                    .addGroup(refSetPanelLayout.createSequentialGroup()
+                        .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(jLabel4)
+                            .addComponent(jLabel3)
+                            .addComponent(jLabel1)
+                            .addComponent(jLabel2))
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(myLayerLabel)
+                            .addComponent(myNodeCountLabel)
+                            .addComponent(myWayCountLabel)
+                            .addComponent(myRelationCountLabel))))
+                .addContainerGap())
         );
         refSetPanelLayout.setVerticalGroup(
             refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-        );
-
-        nonRefSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Non-Reference Set"));
-
-        jLabel3.setText("Layer");
-
-        nonRefLayerComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
-
-        jLabel4.setText("Filter");
-
-        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
-        nonRefSearchModeButtonGroup.add(nonRefReplaceRadio);
-        nonRefReplaceRadio.setSelected(true);
-        nonRefReplaceRadio.setText("Replace selection");
-
-        nonRefSearchModeButtonGroup.add(nonRefAddRadio);
-        nonRefAddRadio.setText("Add to selection");
-        nonRefAddRadio.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                nonRefAddRadioActionPerformed(evt);
-            }
-        });
-
-        nonRefSearchModeButtonGroup.add(nonRefRemoveRadio);
-        nonRefRemoveRadio.setText("Remove from selection");
-
-        nonRefSearchModeButtonGroup.add(nonRefInSelectionRadio);
-        nonRefInSelectionRadio.setText("Find in selection");
-
-        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
-        jPanel8.setLayout(jPanel8Layout);
-        jPanel8Layout.setHorizontalGroup(
-            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel8Layout.createSequentialGroup()
-                .addContainerGap()
-                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(nonRefReplaceRadio)
-                    .addComponent(nonRefAddRadio)
-                    .addComponent(nonRefRemoveRadio)
-                    .addComponent(nonRefInSelectionRadio))
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-        );
-        jPanel8Layout.setVerticalGroup(
-            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel8Layout.createSequentialGroup()
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addComponent(nonRefReplaceRadio)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(nonRefAddRadio)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(nonRefRemoveRadio)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(nonRefInSelectionRadio))
-        );
-
-        nonRefCaseSensitiveCheckBox.setText("Case sensitive");
-
-        nonRefAllObjectsCheckBox.setText("All objects");
-
-        nonRefRegExCheckBox.setText("Regular expression");
-
-        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
-        jPanel7.setLayout(jPanel7Layout);
-        jPanel7Layout.setHorizontalGroup(
-            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel7Layout.createSequentialGroup()
-                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addGroup(jPanel7Layout.createSequentialGroup()
-                        .addContainerGap()
-                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(jLabel3)
-                            .addComponent(jLabel4))
-                        .addGap(18, 18, 18)
-                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(nonRefLayerComboBox, 0, 246, Short.MAX_VALUE)
-                            .addComponent(nonRefFilterTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)))
-                    .addGroup(jPanel7Layout.createSequentialGroup()
-                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(nonRefCaseSensitiveCheckBox)
-                            .addComponent(nonRefAllObjectsCheckBox)
-                            .addComponent(nonRefRegExCheckBox))))
-                .addContainerGap())
-        );
-        jPanel7Layout.setVerticalGroup(
-            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(jPanel7Layout.createSequentialGroup()
-                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+            .addGroup(refSetPanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(freezeMySetButton)
+                    .addComponent(restoreMySetButton))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel2)
+                    .addComponent(myLayerLabel))
+                .addGap(11, 11, 11)
+                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel1)
+                    .addComponent(myNodeCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jLabel3)
-                    .addComponent(nonRefLayerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(myWayCountLabel))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(refSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(jLabel4)
-                    .addComponent(nonRefFilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                    .addGroup(jPanel7Layout.createSequentialGroup()
-                        .addComponent(nonRefCaseSensitiveCheckBox)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(nonRefAllObjectsCheckBox)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(nonRefRegExCheckBox))))
-        );
+                    .addComponent(myRelationCountLabel))
+                .addContainerGap(38, Short.MAX_VALUE))
+        );
+
+        nonRefSetPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Their Set"));
+
+        freezeTheirSelectionButton.setText("Freeze Selection");
+        freezeTheirSelectionButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                freezeTheirSelectionButtonActionPerformed(evt);
+            }
+        });
+
+        restoreTheirSetButton.setText("Restore Selection");
+        restoreTheirSetButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                restoreTheirSetButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel5.setText("Relations");
+
+        jLabel6.setText("Layer");
+
+        jLabel7.setText("Nodes");
+
+        jLabel9.setText("Ways");
+
+        theirNodeCountLabel.setText("0");
+
+        theirLayerLabel.setText("(invalid)");
+
+        theirWayCountLabel.setText("0");
+
+        theirRelationCountLabel.setText("0");
 
         javax.swing.GroupLayout nonRefSetPanelLayout = new javax.swing.GroupLayout(nonRefSetPanel);
@@ -320,9 +272,49 @@
         nonRefSetPanelLayout.setHorizontalGroup(
             nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+            .addGroup(nonRefSetPanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, nonRefSetPanelLayout.createSequentialGroup()
+                        .addComponent(freezeTheirSelectionButton)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 387, Short.MAX_VALUE)
+                        .addComponent(restoreTheirSetButton))
+                    .addGroup(nonRefSetPanelLayout.createSequentialGroup()
+                        .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(jLabel5)
+                            .addComponent(jLabel9)
+                            .addComponent(jLabel7)
+                            .addComponent(jLabel6))
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(theirLayerLabel)
+                            .addComponent(theirNodeCountLabel)
+                            .addComponent(theirWayCountLabel)
+                            .addComponent(theirRelationCountLabel))))
+                .addContainerGap())
         );
         nonRefSetPanelLayout.setVerticalGroup(
             nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+            .addGroup(nonRefSetPanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(freezeTheirSelectionButton)
+                    .addComponent(restoreTheirSetButton))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel6)
+                    .addComponent(theirLayerLabel))
+                .addGap(11, 11, 11)
+                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel7)
+                    .addComponent(theirNodeCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel9)
+                    .addComponent(theirWayCountLabel))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(nonRefSetPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel5)
+                    .addComponent(theirRelationCountLabel))
+                .addContainerGap(32, Short.MAX_VALUE))
         );
 
@@ -380,4 +372,31 @@
         });
 
+        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+
+        jCheckBox1.setSelected(true);
+        jCheckBox1.setText("Distance");
+        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jCheckBox1ActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+        jPanel2.setLayout(jPanel2Layout);
+        jPanel2Layout.setHorizontalGroup(
+            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(jPanel2Layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(jCheckBox1)
+                .addContainerGap(282, Short.MAX_VALUE))
+        );
+        jPanel2Layout.setVerticalGroup(
+            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(jPanel2Layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(jCheckBox1)
+                .addContainerGap(192, Short.MAX_VALUE))
+        );
+
         javax.swing.GroupLayout criteriaTabPanelLayout = new javax.swing.GroupLayout(criteriaTabPanel);
         criteriaTabPanel.setLayout(criteriaTabPanelLayout);
@@ -385,12 +404,18 @@
             criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, criteriaTabPanelLayout.createSequentialGroup()
-                .addContainerGap(254, Short.MAX_VALUE)
+                .addContainerGap(578, Short.MAX_VALUE)
                 .addComponent(criteriaTabConflateButton)
                 .addContainerGap())
+            .addGroup(criteriaTabPanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(292, Short.MAX_VALUE))
         );
         criteriaTabPanelLayout.setVerticalGroup(
             criteriaTabPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, criteriaTabPanelLayout.createSequentialGroup()
-                .addContainerGap(404, Short.MAX_VALUE)
+                .addContainerGap()
+                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 217, Short.MAX_VALUE)
                 .addComponent(criteriaTabConflateButton)
                 .addContainerGap())
@@ -398,4 +423,38 @@
 
         resultsTabPanel.addTab("Matching criteria", criteriaTabPanel);
+
+        resultsPanel.setLayout(new javax.swing.BoxLayout(resultsPanel, javax.swing.BoxLayout.PAGE_AXIS));
+
+        resultsTable.setModel(new javax.swing.table.DefaultTableModel(
+            new Object [][] {
+                {null, null, null, null, null},
+                {null, null, null, null, null},
+                {null, null, null, null, null},
+                {null, null, null, null, null}
+            },
+            new String [] {
+                "Mine", "Theirs", "Distance (m)", "Cost", "Tags"
+            }
+        ));
+        resultsTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+        jScrollPane1.setViewportView(resultsTable);
+
+        resultsPanel.add(jScrollPane1);
+
+        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+
+        useMyTagsButton.setText("My Tags");
+        useMyTagsButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                useMyTagsButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel8.setText("Resolve using:");
+
+        useTheirTagsButton.setText("Their Tags");
+
+        jButton1.setText("Not a match");
+        jButton1.setEnabled(false);
 
         javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
@@ -403,23 +462,56 @@
         jPanel1Layout.setHorizontalGroup(
             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGap(0, 337, Short.MAX_VALUE)
+            .addGroup(jPanel1Layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(jLabel8)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(useMyTagsButton)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(useTheirTagsButton)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(jButton1)
+                .addContainerGap(300, Short.MAX_VALUE))
         );
         jPanel1Layout.setVerticalGroup(
             jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGap(0, 438, Short.MAX_VALUE)
-        );
-
-        resultsTabPanel.addTab("Results", jPanel1);
+            .addGroup(jPanel1Layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(jLabel8)
+                    .addComponent(useMyTagsButton)
+                    .addComponent(useTheirTagsButton)
+                    .addComponent(jButton1))
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        resultsPanel.add(jPanel1);
+
+        tagMergerPlaceholderPanel.setPreferredSize(new java.awt.Dimension(661, 250));
+
+        javax.swing.GroupLayout tagMergerPlaceholderPanelLayout = new javax.swing.GroupLayout(tagMergerPlaceholderPanel);
+        tagMergerPlaceholderPanel.setLayout(tagMergerPlaceholderPanelLayout);
+        tagMergerPlaceholderPanelLayout.setHorizontalGroup(
+            tagMergerPlaceholderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 661, Short.MAX_VALUE)
+        );
+        tagMergerPlaceholderPanelLayout.setVerticalGroup(
+            tagMergerPlaceholderPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 150, Short.MAX_VALUE)
+        );
+
+        resultsPanel.add(tagMergerPlaceholderPanel);
+
+        resolveButton.setText("Resolve");
+        resolveButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                resolveButtonActionPerformed(evt);
+            }
+        });
+        resultsPanel.add(resolveButton);
+
+        resultsTabPanel.addTab("Results", resultsPanel);
 
         add(resultsTabPanel);
     }// </editor-fold>//GEN-END:initComponents
-
-    private void refAddRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refAddRadioActionPerformed
-        // TODO add your handling code here:
-    }//GEN-LAST:event_refAddRadioActionPerformed
-
-    private void nonRefAddRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nonRefAddRadioActionPerformed
-        // TODO add your handling code here:
-    }//GEN-LAST:event_nonRefAddRadioActionPerformed
 
     private void objectTabCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_objectTabCancelButtonActionPerformed
@@ -429,5 +521,54 @@
 
     private void criteriaTabConflateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_criteriaTabConflateButtonActionPerformed
-        dlg.setVisible(false);
+
+        // some initialization
+        int n = mySelection.size();
+        int m = theirSelection.size();
+        int maxLen = Math.max(n, m);
+        double cost[][] = new double[maxLen][maxLen];
+
+        // calculate cost matrix
+        for (int i = 0; i < n; i++) {
+            for (int j = 0; j < m; j++) {
+                cost[i][j] = calcCost(mySelection.get(i), theirSelection.get(j));
+            }
+        }
+
+        // perform assignment using Hungarian algorithm
+        assignment = new int[maxLen][2];
+        assignment = HungarianAlgorithm.hgAlgorithm(cost, "min");
+
+        // create array of primitives based on indices from assignment
+        pairs = new OsmPrimitive[maxLen][2];
+        for (int i = 0; i < maxLen; i++) {
+            if (assignment[i][0] < n)
+                pairs[i][0] = mySelection.get(assignment[i][0]);
+            else
+                pairs[i][0] = null;
+            if (assignment[i][1] < m)
+                pairs[i][1] = theirSelection.get(assignment[i][1]);
+            else
+                pairs[i][1] = null;
+
+            if (pairs[i][0] != null && pairs[i][1] != null) {
+                // TODO: do something!
+                conflicts.add(pairs[i][0], pairs[i][1]);
+            }
+        }
+
+        // add conflation layer
+        try {
+            conflationLayer = new ConflationLayer(myLayer.data, conflicts);
+            Main.main.addLayer(conflationLayer);
+        } catch (Exception ex) {
+            JOptionPane.showMessageDialog(Main.parent, ex.toString(),
+                    "Error adding conflation layer", JOptionPane.ERROR_MESSAGE);
+        }
+        tableModel = new MatchTableModel();
+        resultsTable.setModel(tableModel);
+
+        conflictResolver.populate(conflicts.get(0));
+        // print list of matched pairsalong with distance
+        // upon selection of one pair, highlight them and draw arrow
     }//GEN-LAST:event_criteriaTabConflateButtonActionPerformed
 
@@ -436,4 +577,102 @@
             resultsTabPanel.setSelectedComponent(criteriaTabPanel);
     }//GEN-LAST:event_objectTabNextButtonActionPerformed
+
+    private void restoreMySetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restoreMySetButtonActionPerformed
+        if (myLayer != null && myDataSet != null && mySelection != null && !mySelection.isEmpty()) {
+            Main.map.mapView.setActiveLayer(myLayer);
+            myLayer.setVisible(true);
+            myDataSet.setSelected(mySelection);
+        }
+    }//GEN-LAST:event_restoreMySetButtonActionPerformed
+
+    private void restoreTheirSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_restoreTheirSetButtonActionPerformed
+        if (theirLayer != null && theirDataSet != null && theirSelection != null && !theirSelection.isEmpty()) {
+            Main.map.mapView.setActiveLayer(theirLayer);
+            theirLayer.setVisible(true);
+            theirDataSet.setSelected(theirSelection);
+        }
+    }//GEN-LAST:event_restoreTheirSetButtonActionPerformed
+
+    private void freezeMySetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeMySetButtonActionPerformed
+        myDataSet = Main.main.getCurrentDataSet();
+        myLayer = Main.main.getEditLayer();
+        if (myDataSet == null || myLayer == null) {
+            JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."),
+                    tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
+            return;
+        }
+        mySelection = new ArrayList<OsmPrimitive>(myDataSet.getSelected());
+        if (mySelection.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: mySelection) {
+            switch(p.getType()) {
+            case NODE: numNodes++; break;
+            case WAY: numWays++; break;
+            case RELATION: numRelations++; break;
+            }
+        }
+
+        myLayerLabel.setText(myLayer.getName());
+        myNodeCountLabel.setText(Integer.toString(numNodes));
+        myWayCountLabel.setText(Integer.toString(numWays));
+        myRelationCountLabel.setText(Integer.toString(numRelations));
+    }//GEN-LAST:event_freezeMySetButtonActionPerformed
+
+    private void freezeTheirSelectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_freezeTheirSelectionButtonActionPerformed
+        theirDataSet = Main.main.getCurrentDataSet();
+        theirLayer = Main.main.getEditLayer();
+        if (theirDataSet == null || theirLayer == null) {
+            JOptionPane.showMessageDialog(Main.parent, tr("No valid OSM data layer present."),
+                    tr("Error freezing selection"), JOptionPane.ERROR_MESSAGE);
+            return;
+        }
+        theirSelection = new ArrayList<OsmPrimitive>(theirDataSet.getSelected());
+        if (theirSelection.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: mySelection) {
+            switch(p.getType()) {
+            case NODE: numNodes++; break;
+            case WAY: numWays++; break;
+            case RELATION: numRelations++; break;
+            }
+        }
+
+        theirLayerLabel.setText(theirLayer.getName());
+        theirNodeCountLabel.setText(Integer.toString(numNodes));
+        theirWayCountLabel.setText(Integer.toString(numWays));
+        theirRelationCountLabel.setText(Integer.toString(numRelations));
+    }//GEN-LAST:event_freezeTheirSelectionButtonActionPerformed
+
+    private void useMyTagsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useMyTagsButtonActionPerformed
+        int[] rows = resultsTable.getSelectedRows();
+    }//GEN-LAST:event_useMyTagsButtonActionPerformed
+
+    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
+        // TODO add your handling code here:
+    }//GEN-LAST:event_jCheckBox1ActionPerformed
+
+    private void resolveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resolveButtonActionPerformed
+        if (!conflictResolver.isResolvedCompletely()) {
+            JOptionPane.showMessageDialog(Main.parent, tr("Unresolved differences remain, please fix remaining differences."),
+                    tr("Conflict not resolved completely"), JOptionPane.ERROR_MESSAGE);
+                    return;
+        }
+        Command cmd = conflictResolver.buildResolveCommand();
+        Main.main.undoRedo.add(cmd);
+    }//GEN-LAST:event_resolveButtonActionPerformed
 
     static public class LayerListCellRenderer extends DefaultListCellRenderer {
@@ -451,34 +690,149 @@
     }
 
-    public OsmDataLayer getRefLayer() {
-        return (OsmDataLayer) refLayerComboBox.getModel().getSelectedItem();
-    }
-
-    public OsmDataLayer getNonRefLayer() {
-        return (OsmDataLayer) nonRefLayerComboBox.getModel().getSelectedItem();
-    }
-
-    public SearchSetting getRefSearchSetting() {
-        SearchSetting s = new SearchSetting();
-        s.text = refFilterTextField.getText();
-        s.allElements = refAllObjectsCheckBox.isSelected();
-        s.caseSensitive = refCaseSensitiveCheckBox.isSelected();
-        s.regexSearch = refRegExCheckBox.isSelected();
-        s.mode = refReplaceRadio.isSelected() ? SearchAction.SearchMode.replace
-                : (refAddRadio.isSelected() ? SearchAction.SearchMode.add
-                : (refRemoveRadio.isSelected() ? SearchAction.SearchMode.remove : SearchAction.SearchMode.in_selection));
-        return s;
-    }
-
-    public SearchSetting getNonRefSearchSetting() {
-        SearchSetting s = new SearchSetting();
-        s.text = nonRefFilterTextField.getText();
-        s.allElements = nonRefAllObjectsCheckBox.isSelected();
-        s.caseSensitive = nonRefCaseSensitiveCheckBox.isSelected();
-        s.regexSearch = nonRefRegExCheckBox.isSelected();
-        s.mode = nonRefReplaceRadio.isSelected() ? SearchAction.SearchMode.replace
-                : (nonRefAddRadio.isSelected() ? SearchAction.SearchMode.add
-                : (nonRefRemoveRadio.isSelected() ? SearchAction.SearchMode.remove : SearchAction.SearchMode.in_selection));
-        return s;
+
+    public static EastNorth getCenter(OsmPrimitive prim) {
+            LatLon center = prim.getBBox().getTopLeft().getCenter(prim.getBBox().getBottomRight());
+            return Main.map.mapView.getProjection().latlon2eastNorth(center);
+    }
+
+    /**
+     * Calculate the cost of a pair of <code>OsmPrimitive</code>'s. A
+     * simple cost consisting of the Euclidean distance is used
+     * now, later we can also use dissimilarity between tags.
+     *
+     * @param   refPrim      the reference <code>OsmPrimitive</code>.
+     * @param   nonRefPrim   the non-reference <code>OsmPrimitive</code>.
+     */
+    public double calcCost(OsmPrimitive refPrim, OsmPrimitive nonRefPrim) {
+        double dist;
+        try {
+            dist = getCenter(refPrim).distance(getCenter(nonRefPrim));
+        } catch (Exception e) {
+            dist = 1000; // FIXME: what number to use?
+        }
+
+        // TODO: use other "distance" measures, i.e. matching tags
+        return dist;
+    }
+
+    class MatchTableModel extends AbstractTableModel {
+
+        private String[] columnNames = {"Mine", "Theirs", "Distance (m)", "Cost", "Tags"};
+
+        public int getColumnCount() {
+            return columnNames.length;
+        }
+
+        public int getRowCount() {
+            return conflicts.size();
+        }
+
+        @Override
+        public String getColumnName(int col) {
+            return columnNames[col];
+        }
+
+        public Object getValueAt(int row, int col) {
+            if (col == 0)
+                return conflicts.get(row).getMy();
+            if (col == 1)
+                return conflicts.get(row).getTheir();
+            if (col == 4) {
+                HashSet<OsmPrimitive> set = new HashSet<OsmPrimitive>();
+                set.add(conflicts.get(row).getMy());
+                set.add(conflicts.get(row).getTheir());
+                TagCollection tags = TagCollection.unionOfAllPrimitives(set);
+                Set<String> keys = tags.getKeysWithMultipleValues();
+                if (keys.isEmpty())
+                    return "No conflicts!";
+                else
+                    return "Conflicts!";
+
+            }
+            else
+                return 0;
+        }
+
+        @Override
+        public Class getColumnClass(int c) {
+            return getValueAt(0, c).getClass();
+        }
+    }
+
+    class ColorTableCellRenderer extends JLabel implements TableCellRenderer {
+        private String columnName;
+
+        public ColorTableCellRenderer(String column) {
+            this.columnName = column;
+            setOpaque(true);
+        }
+
+        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+            Object columnValue = table.getValueAt(row, table.getColumnModel().getColumnIndex(columnName));
+
+            if (value != null) {
+                setText(value.toString());
+            }
+            if (isSelected) {
+                setBackground(table.getSelectionBackground());
+                setForeground(table.getSelectionForeground());
+            } else {
+                setBackground(table.getBackground());
+                setForeground(table.getForeground());
+                if (columnValue.equals("Conflicts!")) {
+                    setBackground(java.awt.Color.red);
+                }
+                else {
+                    setBackground(java.awt.Color.green);
+                }
+            }
+            return this;
+        }
+    }
+
+    class MatchListSelectionHandler implements ListSelectionListener {
+
+        public void valueChanged(ListSelectionEvent e) {
+            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
+
+            int firstIndex = lsm.getMinSelectionIndex();
+            int lastIndex = lsm.getMaxSelectionIndex();
+            boolean isAdjusting = e.getValueIsAdjusting();
+            if (isAdjusting)
+                return;
+
+            // only one item selected, show tags and zoom/center map
+            if (!lsm.isSelectionEmpty() && firstIndex == lastIndex) {
+                Conflict<?> c = conflicts.get(firstIndex);
+                conflictResolver.populate(c);
+                
+                ArrayList<OsmPrimitive> sel = new ArrayList<OsmPrimitive>();
+                sel.add(c.getMy());
+                sel.add(c.getTheir());
+
+                BoundingXYVisitor box = new BoundingXYVisitor();
+                box.computeBoundingBox(sel);
+                if (box.getBounds() == null) {
+                    return;
+                }
+                box.enlargeBoundingBox();
+                Main.map.mapView.recalculateCenterScale(box);
+            }
+
+        }
+    }
+
+    public final void refreshView() {
+        // TODO: should tell what rows changed
+        tableModel.fireTableDataChanged();
+    }
+
+    public void onConflictsAdded(ConflictCollection conflicts) {
+        refreshView();
+    }
+
+    public void onConflictsRemoved(ConflictCollection conflicts) {
+        System.err.println("1 conflict has been resolved.");
+        refreshView();
     }
 
@@ -486,39 +840,42 @@
     private javax.swing.JButton criteriaTabConflateButton;
     private javax.swing.JPanel criteriaTabPanel;
+    private javax.swing.JButton freezeMySetButton;
+    private javax.swing.JButton freezeTheirSelectionButton;
+    private javax.swing.JButton jButton1;
+    private javax.swing.JCheckBox jCheckBox1;
     private javax.swing.JLabel jLabel1;
     private javax.swing.JLabel jLabel2;
     private javax.swing.JLabel jLabel3;
     private javax.swing.JLabel jLabel4;
+    private javax.swing.JLabel jLabel5;
+    private javax.swing.JLabel jLabel6;
+    private javax.swing.JLabel jLabel7;
+    private javax.swing.JLabel jLabel8;
+    private javax.swing.JLabel jLabel9;
     private javax.swing.JPanel jPanel1;
-    private javax.swing.JPanel jPanel4;
-    private javax.swing.JPanel jPanel5;
-    private javax.swing.JPanel jPanel7;
-    private javax.swing.JPanel jPanel8;
-    private javax.swing.JRadioButton nonRefAddRadio;
-    private javax.swing.JCheckBox nonRefAllObjectsCheckBox;
-    private javax.swing.JCheckBox nonRefCaseSensitiveCheckBox;
-    private javax.swing.JTextField nonRefFilterTextField;
-    private javax.swing.JRadioButton nonRefInSelectionRadio;
-    private javax.swing.JComboBox nonRefLayerComboBox;
-    private javax.swing.JCheckBox nonRefRegExCheckBox;
-    private javax.swing.JRadioButton nonRefRemoveRadio;
-    private javax.swing.JRadioButton nonRefReplaceRadio;
-    private javax.swing.ButtonGroup nonRefSearchModeButtonGroup;
+    private javax.swing.JPanel jPanel2;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JLabel myLayerLabel;
+    private javax.swing.JLabel myNodeCountLabel;
+    private javax.swing.JLabel myRelationCountLabel;
+    private javax.swing.JLabel myWayCountLabel;
     private javax.swing.JPanel nonRefSetPanel;
     private javax.swing.JButton objectTabCancelButton;
     private javax.swing.JButton objectTabNextButton;
     private javax.swing.JPanel objectTabPanel;
-    private javax.swing.JRadioButton refAddRadio;
-    private javax.swing.JCheckBox refAllObjectsCheckBox;
-    private javax.swing.JCheckBox refCaseSensitiveCheckBox;
-    private javax.swing.JTextField refFilterTextField;
-    private javax.swing.JRadioButton refInSelectionRadio;
-    private javax.swing.JComboBox refLayerComboBox;
-    private javax.swing.JCheckBox refRegExCheckBox;
-    private javax.swing.JRadioButton refRemoveRadio;
-    private javax.swing.JRadioButton refReplaceRadio;
-    private javax.swing.ButtonGroup refSearchModeButtonGroup;
     private javax.swing.JPanel refSetPanel;
+    private javax.swing.JButton resolveButton;
+    private javax.swing.JButton restoreMySetButton;
+    private javax.swing.JButton restoreTheirSetButton;
+    private javax.swing.JPanel resultsPanel;
     private javax.swing.JTabbedPane resultsTabPanel;
+    private javax.swing.JTable resultsTable;
+    private javax.swing.JPanel tagMergerPlaceholderPanel;
+    private javax.swing.JLabel theirLayerLabel;
+    private javax.swing.JLabel theirNodeCountLabel;
+    private javax.swing.JLabel theirRelationCountLabel;
+    private javax.swing.JLabel theirWayCountLabel;
+    private javax.swing.JButton useMyTagsButton;
+    private javax.swing.JButton useTheirTagsButton;
     // End of variables declaration//GEN-END:variables
 
