Index: /applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java
===================================================================
--- /applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java	(revision 20740)
+++ /applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java	(revision 20741)
@@ -61,20 +61,4 @@
 public class StopImporterAction extends JosmAction
 {  
-
-  private class TracksLSL implements ListSelectionListener
-  {
-    StopImporterAction root = null;
-    
-    public TracksLSL(StopImporterAction sia)
-    {
-      root = sia;
-    }
-    
-    public void valueChanged(ListSelectionEvent e)
-    {
-      root.tracksSelectionChanged();
-    }
-  };
-  
   private class TrackReference
     implements Comparable< TrackReference >, TableModelListener
@@ -150,5 +134,5 @@
       if (e.getType() == TableModelEvent.UPDATE)
       {
-	double time = parseTime
+	double time = StopImporterDialog.parseTime
 	    ((String)stoplistTM.getValueAt(e.getFirstRow(), 0));
 	if (time < 0)
@@ -183,9 +167,9 @@
     public LatLon computeCoor(double time)
     {
-      double gpsSyncTime = parseTime(this.gpsSyncTime);
-      double dGpsStartTime = parseTime(gpsStartTime);
+      double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);
+      double dGpsStartTime = StopImporterDialog.parseTime(gpsStartTime);
       if (gpsSyncTime < dGpsStartTime - 12*60*60)
 	gpsSyncTime += 24*60*60;
-      double timeDelta = gpsSyncTime - parseTime(stopwatchStart);
+      double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);
       time += timeDelta;
 	
@@ -202,5 +186,5 @@
 	  wayPoint = witer.next();
 	  String startTime = wayPoint.getString("time");
-	  wayPointTime = parseTime(startTime.substring(11, 19));
+	  wayPointTime = StopImporterDialog.parseTime(startTime.substring(11, 19));
 	  if (startTime.substring(11, 19).compareTo(gpsStartTime.substring(11, 19)) == -1)
 	    wayPointTime += 24*60*60;
@@ -242,5 +226,5 @@
 	  continue;
 	
-	double time = parseTime
+	double time = StopImporterDialog.parseTime
 	      ((String)stoplistTM.getValueAt(i, 0));
 	LatLon latLon = computeCoor(time);
@@ -270,9 +254,10 @@
       int i = 0;
       double time = -48*60*60;
-      double dGpsStartTime = parseTime(gpsStartTime);
+      double dGpsStartTime = StopImporterDialog.parseTime(gpsStartTime);
       while ((i < wayPoints.size()) && (time < dGpsStartTime + timeWindow/2))
       {
 	if (wayPoints.elementAt(i).getString("time") != null)
-	  time = parseTime(wayPoints.elementAt(i).getString("time").substring(11,19));
+	  time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
+	      .getString("time").substring(11,19));
 	if (time < dGpsStartTime)
 	  time += 24*60*60;
@@ -288,5 +273,6 @@
 	  --j;
 	  if (wayPoints.elementAt(j).getString("time") != null)
-	    time2 = parseTime(wayPoints.elementAt(j).getString("time").substring(11,19));
+	    time2 = StopImporterDialog.parseTime(wayPoints.elementAt(j)
+		.getString("time").substring(11,19));
 	  if (time2 < dGpsStartTime)
 	    time2 += 24*60*60;
@@ -297,5 +283,6 @@
 	{
 	  if (wayPoints.elementAt(k).getString("time") != null)
-	    time2 = parseTime(wayPoints.elementAt(k).getString("time").substring(11,19));
+	    time2 = StopImporterDialog.parseTime(wayPoints.elementAt(k)
+		.getString("time").substring(11,19));
 	  if (time2 < dGpsStartTime)
 	    time2 += 24*60*60;
@@ -319,5 +306,6 @@
 	
 	if (wayPoints.elementAt(i).getString("time") != null)
-	  time = parseTime(wayPoints.elementAt(i).getString("time").substring(11,19));
+	  time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
+	      .getString("time").substring(11,19));
 	if (time < dGpsStartTime)
 	  time += 24*60*60;
@@ -356,9 +344,10 @@
 	if (wayPoints.elementAt(i).getString("time") != null)
 	{
-	  time = parseTime(wayPoints.elementAt(i).getString("time").substring(11,19));
-	  double gpsSyncTime = parseTime(this.gpsSyncTime);
+	  time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
+	      .getString("time").substring(11,19));
+	  double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);
 	  if (gpsSyncTime < dGpsStartTime - 12*60*60)
 	    gpsSyncTime += 24*60*60;
-	  double timeDelta = gpsSyncTime - parseTime(stopwatchStart);
+	  double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);
 	  time -= timeDelta;
 	  stoplistTM.insertRow(-1, timeOf(time));
@@ -388,9 +377,9 @@
     public int compareTo(NodeSortEntry nse)
     {
-      double time = parseTime(this.time);
+      double time = StopImporterDialog.parseTime(this.time);
       if (time - startTime > 12*60*60)
 	time -= 24*60*60;
       
-      double nseTime = parseTime(nse.time);
+      double nseTime = StopImporterDialog.parseTime(nse.time);
       if (nseTime - startTime > 12*60*60)
 	nseTime -= 24*60*60;
@@ -541,15 +530,6 @@
   };
   
-  private static JDialog jDialog = null;
-  private static JTabbedPane tabbedPane = null;
+  private static StopImporterDialog dialog = null;
   private static DefaultListModel tracksListModel = null;
-  private static JComboBox cbStoptype = null;
-  private static JList tracksList = null;
-  private static JTextField tfGPSTimeStart = null;
-  private static JTextField tfStopwatchStart = null;
-  private static JTextField tfTimeWindow = null;
-  private static JTextField tfThreshold = null;
-  private static JTable stoplistTable = null;
-  private static JTable waypointTable = null;
   private static GpxData data = null;
   private static TrackReference currentTrack = null;
@@ -562,467 +542,19 @@
   }
 
+  public DefaultListModel getTracksListModel()
+  {
+    if (tracksListModel == null)
+      tracksListModel = new DefaultListModel();
+    return tracksListModel;
+  }
+  
   public void actionPerformed(ActionEvent event)
   {
-    Frame frame = JOptionPane.getFrameForComponent(Main.parent);
     DataSet mainDataSet = Main.main.getCurrentDataSet();
     
-    if (jDialog == null)
-    {
-      jDialog = new JDialog(frame, "Create Stops from GPX", false);
-      tabbedPane = new JTabbedPane();
-      JPanel tabTracks = new JPanel();
-      tabbedPane.addTab(marktr("Tracks"), tabTracks);
-      JPanel tabSettings = new JPanel();
-      tabbedPane.addTab(marktr("Settings"), tabSettings);
-      JPanel tabStops = new JPanel();
-      tabbedPane.addTab(marktr("Stops"), tabStops);
-      JPanel tabWaypoints = new JPanel();
-      tabbedPane.addTab(marktr("Waypoints"), tabWaypoints);
-      tabbedPane.setEnabledAt(0, true);
-      tabbedPane.setEnabledAt(1, true);
-      tabbedPane.setEnabledAt(2, false);
-      tabbedPane.setEnabledAt(3, true);
-      jDialog.add(tabbedPane);
-      
-      //Tracks Tab
-      Container contentPane = tabTracks;
-      GridBagLayout gridbag = new GridBagLayout();
-      GridBagConstraints layoutCons = new GridBagConstraints();
-      contentPane.setLayout(gridbag);
-      
-      JLabel label = new JLabel("Tracks in this GPX file:");
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 0;
-      layoutCons.gridwidth = 3;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      tracksListModel = new DefaultListModel();
-      tracksList = new JList(tracksListModel);
-      JScrollPane rpListSP = new JScrollPane(tracksList);
-      String[] data = {"1", "2", "3", "4", "5", "6"};
-      tracksListModel.copyInto(data);
-      tracksList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-      tracksList.addListSelectionListener(new TracksLSL(this));
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 1;
-      layoutCons.gridwidth = 3;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 1.0;
-      layoutCons.fill = GridBagConstraints.BOTH;      
-      gridbag.setConstraints(rpListSP, layoutCons);
-      contentPane.add(rpListSP);
-      
-      //Settings Tab
-      /*Container*/ contentPane = tabSettings;
-      /*GridBagLayout*/ gridbag = new GridBagLayout();
-      /*GridBagConstraints*/ layoutCons = new GridBagConstraints();
-      contentPane.setLayout(gridbag);
-      
-      /*JLabel*/ label = new JLabel("Type of stops to add");
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 0;
-      layoutCons.gridwidth = 2;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      cbStoptype = new JComboBox();
-      cbStoptype.setEditable(false);
-      cbStoptype.addItem("bus");
-      cbStoptype.addItem("tram");
-      cbStoptype.addItem("light_rail");
-      cbStoptype.addItem("subway");
-      cbStoptype.addItem("rail");
-      cbStoptype.setActionCommand("stopImporter.settingsStoptype");
-      cbStoptype.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(cbStoptype, layoutCons);
-      contentPane.add(cbStoptype);
-      
-      /*JLabel*/ label = new JLabel("Time on your GPS device");
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 2;
-      layoutCons.gridwidth = 2;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      tfGPSTimeStart = new JTextField("00:00:00", 15);
-      tfGPSTimeStart.setActionCommand("stopImporter.settingsGPSTimeStart");
-      tfGPSTimeStart.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 3;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(tfGPSTimeStart, layoutCons);
-      contentPane.add(tfGPSTimeStart);
-      
-      /*JLabel*/ label = new JLabel("HH:MM:SS.sss");
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 3;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-            
-      /*JLabel*/ label = new JLabel("Time on your stopwatch");
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 4;
-      layoutCons.gridwidth = 2;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      tfStopwatchStart = new JTextField("00:00:00", 15);
-      tfStopwatchStart.setActionCommand("stopImporter.settingsStopwatchStart");
-      tfStopwatchStart.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 5;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(tfStopwatchStart, layoutCons);
-      contentPane.add(tfStopwatchStart);
-      
-      /*JLabel*/ label = new JLabel("HH:MM:SS.sss");
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 5;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      /*JLabel*/ label = new JLabel("Time window");
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 6;
-      layoutCons.gridwidth = 2;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      tfTimeWindow = new JTextField("15", 4);
-      tfTimeWindow.setActionCommand("stopImporter.settingsTimeWindow");
-      tfTimeWindow.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 7;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(tfTimeWindow, layoutCons);
-      contentPane.add(tfTimeWindow);
-      
-      /*JLabel*/ label = new JLabel("seconds");
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 7;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      /*JLabel*/ label = new JLabel("Move Threshold");
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 8;
-      layoutCons.gridwidth = 2;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      tfThreshold = new JTextField("20", 4);
-      tfThreshold.setActionCommand("stopImporter.settingsThreshold");
-      tfThreshold.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 9;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(tfThreshold, layoutCons);
-      contentPane.add(tfThreshold);
-      
-      /*JLabel*/ label = new JLabel("meters");
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 9;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 0.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(label, layoutCons);
-      contentPane.add(label);
-      
-      JButton bSuggestStops = new JButton("Suggest Stops");
-      bSuggestStops.setActionCommand("stopImporter.settingsSuggestStops");
-      bSuggestStops.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 10;
-      layoutCons.gridwidth = 3;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bSuggestStops, layoutCons);
-      contentPane.add(bSuggestStops);
-      
-      //Stops Tab
-      contentPane = tabStops;
-      gridbag = new GridBagLayout();
-      layoutCons = new GridBagConstraints();
-      contentPane.setLayout(gridbag);
-      
-      stoplistTable = new JTable();
-      JScrollPane tableSP = new JScrollPane(stoplistTable);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 0;
-      layoutCons.gridwidth = 4;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 1.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(tableSP, layoutCons);
-      contentPane.add(tableSP);
-      
-      JButton bFind = new JButton("Find");
-      bFind.setActionCommand("stopImporter.stoplistFind");
-      bFind.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bFind, layoutCons);
-      contentPane.add(bFind);
-      
-      JButton bShow = new JButton("Show");
-      bShow.setActionCommand("stopImporter.stoplistShow");
-      bShow.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 2;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bShow, layoutCons);
-      contentPane.add(bShow);
-      
-      JButton bMark = new JButton("Mark");
-      bMark.setActionCommand("stopImporter.stoplistMark");
-      bMark.addActionListener(this);
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 1;
-      layoutCons.gridheight = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bMark, layoutCons);
-      contentPane.add(bMark);
-      
-      JButton bDetach = new JButton("Detach");
-      bDetach.setActionCommand("stopImporter.stoplistDetach");
-      bDetach.addActionListener(this);
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 2;
-      layoutCons.gridheight = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bDetach, layoutCons);
-      contentPane.add(bDetach);
-      
-      JButton bAdd = new JButton("Add");
-      bAdd.setActionCommand("stopImporter.stoplistAdd");
-      bAdd.addActionListener(this);
-      
-      layoutCons.gridx = 2;
-      layoutCons.gridy = 1;
-      layoutCons.gridheight = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bAdd, layoutCons);
-      contentPane.add(bAdd);
-      
-      JButton bDelete = new JButton("Delete");
-      bDelete.setActionCommand("stopImporter.stoplistDelete");
-      bDelete.addActionListener(this);
-      
-      layoutCons.gridx = 2;
-      layoutCons.gridy = 2;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bDelete, layoutCons);
-      contentPane.add(bDelete);
-      
-      JButton bSort = new JButton("Sort");
-      bSort.setActionCommand("stopImporter.stoplistSort");
-      bSort.addActionListener(this);
-      
-      layoutCons.gridx = 3;
-      layoutCons.gridy = 1;
-      layoutCons.gridheight = 2;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bSort, layoutCons);
-      contentPane.add(bSort);
-      
-      //Waypoints Tab
-      contentPane = tabWaypoints;
-      gridbag = new GridBagLayout();
-      layoutCons = new GridBagConstraints();
-      contentPane.setLayout(gridbag);
-      
-      waypointTable = new JTable();
-      /*JScrollPane*/ tableSP = new JScrollPane(waypointTable);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 0;
-      layoutCons.gridwidth = 3;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 1.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(tableSP, layoutCons);
-      contentPane.add(tableSP);
-      
-      /*JButton*/ bFind = new JButton("Find");
-      bFind.setActionCommand("stopImporter.waypointsFind");
-      bFind.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bFind, layoutCons);
-      contentPane.add(bFind);
-      
-      /*JButton*/ bShow = new JButton("Show");
-      bShow.setActionCommand("stopImporter.waypointsShow");
-      bShow.addActionListener(this);
-      
-      layoutCons.gridx = 0;
-      layoutCons.gridy = 2;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bShow, layoutCons);
-      contentPane.add(bShow);
-      
-      /*JButton*/ bMark = new JButton("Mark");
-      bMark.setActionCommand("stopImporter.waypointsMark");
-      bMark.addActionListener(this);
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 1;
-      layoutCons.gridheight = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bMark, layoutCons);
-      contentPane.add(bMark);
-      
-      /*JButton*/ bDetach = new JButton("Detach");
-      bDetach.setActionCommand("stopImporter.waypointsDetach");
-      bDetach.addActionListener(this);
-      
-      layoutCons.gridx = 1;
-      layoutCons.gridy = 2;
-      layoutCons.gridheight = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bDetach, layoutCons);
-      contentPane.add(bDetach);
-      
-      /*JButton*/ bAdd = new JButton("Enable");
-      bAdd.setActionCommand("stopImporter.waypointsAdd");
-      bAdd.addActionListener(this);
-      
-      layoutCons.gridx = 2;
-      layoutCons.gridy = 1;
-      layoutCons.gridheight = 1;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bAdd, layoutCons);
-      contentPane.add(bAdd);
-      
-      /*JButton*/ bDelete = new JButton("Disable");
-      bDelete.setActionCommand("stopImporter.waypointsDelete");
-      bDelete.addActionListener(this);
-      
-      layoutCons.gridx = 2;
-      layoutCons.gridy = 2;
-      layoutCons.gridwidth = 1;
-      layoutCons.weightx = 1.0;
-      layoutCons.weighty = 0.0;
-      layoutCons.fill = GridBagConstraints.BOTH;
-      gridbag.setConstraints(bDelete, layoutCons);
-      contentPane.add(bDelete);
-      
-      jDialog.pack();
-      jDialog.setLocationRelativeTo(frame);
-    }
-
-    jDialog.setVisible(true);
+    if (dialog == null)
+      dialog = new StopImporterDialog(this);
+    
+    dialog.setVisible(true);
 
     if (tr("Create Stops from GPX ...").equals(event.getActionCommand()))
@@ -1047,38 +579,15 @@
       
       refreshData();
-      
-/*      Iterator< GpxTrack > iter = data.tracks.iterator();
-      while (iter.hasNext())
-      {
-	GpxTrack track = iter.next();
-	System.out.println("");
-	System.out.println(track.getAttributes().get("name"));
-	Iterator< GpxTrackSegment > siter = track.getSegments().iterator();
-	while (siter.hasNext())
-	{
-	  Iterator< WayPoint > witer = siter.next().getWayPoints().iterator();
-	  while (witer.hasNext())
-	  {
-	    System.out.println(witer.next());
-	  }
-	}
-      }*/
     }
     else if ("stopImporter.settingsGPSTimeStart"
       .equals(event.getActionCommand()))
     {
-      if (parseTime(tfGPSTimeStart.getText()) >= 0)
+      if (dialog.gpsTimeStartValid())
       {
 	if (currentTrack != null)
 	{
-	  currentTrack.gpsSyncTime = tfGPSTimeStart.getText();
+	  currentTrack.gpsSyncTime = dialog.getGpsTimeStart();
 	  currentTrack.relocateNodes();
 	}
-      }
-      else
-      {
-	JOptionPane.showMessageDialog
-	(null, "Can't parse a time from this string.", "Invalid value",
-	 JOptionPane.ERROR_MESSAGE);
       }
     }
@@ -1086,9 +595,9 @@
       .equals(event.getActionCommand()))
     {
-      if (parseTime(tfStopwatchStart.getText()) >= 0)
+      if (dialog.stopwatchStartValid())
       {
 	if (currentTrack != null)
 	{
-	  currentTrack.stopwatchStart = tfStopwatchStart.getText();
+	  currentTrack.stopwatchStart = dialog.getStopwatchStart();
 	  currentTrack.relocateNodes();
 	}
@@ -1102,10 +611,10 @@
     {
       if (currentTrack != null)
-	currentTrack.timeWindow = Double.parseDouble(tfTimeWindow.getText());
+	currentTrack.timeWindow = dialog.getTimeWindow();
     }
     else if ("stopImporter.settingsThreshold".equals(event.getActionCommand()))
     {
       if (currentTrack != null)
-	currentTrack.threshold = Double.parseDouble(tfThreshold.getText());
+	currentTrack.threshold = dialog.getThreshold();
     }
     else if ("stopImporter.settingsSuggestStops".equals(event.getActionCommand()))
@@ -1118,5 +627,5 @@
 	return;
       
-      stoplistTable.clearSelection();
+      dialog.getStoplistTable().clearSelection();
       
       for (int i = 0; i < currentTrack.stoplistTM.getRowCount(); ++i)
@@ -1124,5 +633,5 @@
 	if ((currentTrack.stoplistTM.nodes.elementAt(i) != null) &&
 		    (Main.main.getCurrentDataSet().isSelected(currentTrack.stoplistTM.nodes.elementAt(i))))
-	  stoplistTable.addRowSelectionInterval(i, i);
+	  dialog.getStoplistTable().addRowSelectionInterval(i, i);
       }
     }
@@ -1130,9 +639,9 @@
     {
       BoundingXYVisitor box = new BoundingXYVisitor();
-      if (stoplistTable.getSelectedRowCount() > 0)
+      if (dialog.getStoplistTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < currentTrack.stoplistTM.getRowCount(); ++i)
 	{
-	  if ((stoplistTable.isRowSelected(i)) &&
+	  if ((dialog.getStoplistTable().isRowSelected(i)) &&
 		      (currentTrack.stoplistTM.nodes.elementAt(i) != null))
 	  {
@@ -1158,9 +667,9 @@
       OsmPrimitive[] osmp = { null };
       Main.main.getCurrentDataSet().setSelected(osmp);
-      if (stoplistTable.getSelectedRowCount() > 0)
+      if (dialog.getStoplistTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < currentTrack.stoplistTM.getRowCount(); ++i)
 	{
-	  if ((stoplistTable.isRowSelected(i)) &&
+	  if ((dialog.getStoplistTable().isRowSelected(i)) &&
 	    (currentTrack.stoplistTM.nodes.elementAt(i) != null))
 	  {
@@ -1180,9 +689,9 @@
     else if ("stopImporter.stoplistDetach".equals(event.getActionCommand()))
     {
-      if (stoplistTable.getSelectedRowCount() > 0)
+      if (dialog.getStoplistTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < currentTrack.stoplistTM.getRowCount(); ++i)
 	{
-	  if ((stoplistTable.isRowSelected(i)) &&
+	  if ((dialog.getStoplistTable().isRowSelected(i)) &&
 		      (currentTrack.stoplistTM.nodes.elementAt(i) != null))
 	  {
@@ -1199,9 +708,9 @@
 	}
       }
-      stoplistTable.clearSelection();
+      dialog.getStoplistTable().clearSelection();
     }
     else if ("stopImporter.stoplistAdd".equals(event.getActionCommand()))
     {
-      int insPos = stoplistTable.getSelectedRow();
+      int insPos = dialog.getStoplistTable().getSelectedRow();
       if (currentTrack != null)
 	currentTrack.stoplistTM.insertRow(insPos, "00:00:00");
@@ -1214,5 +723,5 @@
       for (int i = currentTrack.stoplistTM.getRowCount()-1; i >=0; --i)
       {
-	if (stoplistTable.isRowSelected(i))
+	if (dialog.getStoplistTable().isRowSelected(i))
 	{
 	  if ((Node)currentTrack.stoplistTM.nodes.elementAt(i) != null)
@@ -1231,13 +740,13 @@
     else if ("stopImporter.stoplistSort".equals(event.getActionCommand()))
     {
-      int insPos = stoplistTable.getSelectedRow();
+      int insPos = dialog.getStoplistTable().getSelectedRow();
       Vector< NodeSortEntry > nodesToSort = new Vector< NodeSortEntry >();
       if (currentTrack == null)
 	return;
-      if (stoplistTable.getSelectedRowCount() > 0)
+      if (dialog.getStoplistTable().getSelectedRowCount() > 0)
       {
 	for (int i = currentTrack.stoplistTM.getRowCount()-1; i >=0; --i)
 	{
-	  if (stoplistTable.isRowSelected(i))
+	  if (dialog.getStoplistTable().isRowSelected(i))
 	  {
 	    nodesToSort.add(new NodeSortEntry
@@ -1245,5 +754,5 @@
 		 (String)currentTrack.stoplistTM.getValueAt(i, 0),
 		  (String)currentTrack.stoplistTM.getValueAt(i, 1),
-		   parseTime(currentTrack.stopwatchStart)));
+		   StopImporterDialog.parseTime(currentTrack.stopwatchStart)));
 	    currentTrack.stoplistTM.nodes.removeElementAt(i);
 	    currentTrack.stoplistTM.removeRow(i);
@@ -1259,5 +768,5 @@
 	       (String)currentTrack.stoplistTM.getValueAt(i, 0),
 		(String)currentTrack.stoplistTM.getValueAt(i, 1),
-		 parseTime(currentTrack.stopwatchStart)));
+		 StopImporterDialog.parseTime(currentTrack.stopwatchStart)));
 	}
 	currentTrack.stoplistTM.clear();
@@ -1281,5 +790,5 @@
 	return;
       
-      waypointTable.clearSelection();
+      dialog.getWaypointsTable().clearSelection();
       
       for (int i = 0; i < waypointTM.getRowCount(); ++i)
@@ -1287,5 +796,5 @@
 	if ((waypointTM.nodes.elementAt(i) != null) &&
 		    (Main.main.getCurrentDataSet().isSelected(waypointTM.nodes.elementAt(i))))
-	  waypointTable.addRowSelectionInterval(i, i);
+	  dialog.getWaypointsTable().addRowSelectionInterval(i, i);
       }
     }
@@ -1293,9 +802,9 @@
     {
       BoundingXYVisitor box = new BoundingXYVisitor();
-      if (waypointTable.getSelectedRowCount() > 0)
+      if (dialog.getWaypointsTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < waypointTM.getRowCount(); ++i)
 	{
-	  if ((waypointTable.isRowSelected(i)) &&
+	  if ((dialog.getWaypointsTable().isRowSelected(i)) &&
 		      (waypointTM.nodes.elementAt(i) != null))
 	  {
@@ -1321,9 +830,9 @@
       OsmPrimitive[] osmp = { null };
       Main.main.getCurrentDataSet().setSelected(osmp);
-      if (waypointTable.getSelectedRowCount() > 0)
+      if (dialog.getWaypointsTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < waypointTM.getRowCount(); ++i)
 	{
-	  if ((waypointTable.isRowSelected(i)) &&
+	  if ((dialog.getWaypointsTable().isRowSelected(i)) &&
 		      (waypointTM.nodes.elementAt(i) != null))
 	  {
@@ -1343,9 +852,9 @@
     else if ("stopImporter.waypointsDetach".equals(event.getActionCommand()))
     {
-      if (waypointTable.getSelectedRowCount() > 0)
+      if (dialog.getWaypointsTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < waypointTM.getRowCount(); ++i)
 	{
-	  if ((waypointTable.isRowSelected(i)) &&
+	  if ((dialog.getWaypointsTable().isRowSelected(i)) &&
 		      (waypointTM.nodes.elementAt(i) != null))
 	  {
@@ -1362,13 +871,13 @@
 	}
       }
-      waypointTable.clearSelection();
+      dialog.getWaypointsTable().clearSelection();
     }
     else if ("stopImporter.waypointsAdd".equals(event.getActionCommand()))
     {
-      if (waypointTable.getSelectedRowCount() > 0)
+      if (dialog.getWaypointsTable().getSelectedRowCount() > 0)
       {
 	for (int i = 0; i < waypointTM.getRowCount(); ++i)
 	{
-	  if ((waypointTable.isRowSelected(i)) &&
+	  if ((dialog.getWaypointsTable().isRowSelected(i)) &&
 		      (waypointTM.nodes.elementAt(i) == null))
 	  {
@@ -1393,5 +902,5 @@
       for (int i = waypointTM.getRowCount()-1; i >=0; --i)
       {
-	if (waypointTable.isRowSelected(i))
+	if (dialog.getWaypointsTable().isRowSelected(i))
 	{
 	  if ((Node)waypointTM.nodes.elementAt(i) != null)
@@ -1416,13 +925,13 @@
 	  node.remove("highway");
 	  node.remove("railway");
-          if ("bus".equals((String)cbStoptype.getSelectedItem()))
+          if ("bus".equals(dialog.getStoptype()))
             node.put("highway", "bus_stop");
-          else if ("tram".equals((String)cbStoptype.getSelectedItem()))
+	  else if ("tram".equals(dialog.getStoptype()))
             node.put("railway", "tram_stop");
-          else if ("light_rail".equals((String)cbStoptype.getSelectedItem()))
+	  else if ("light_rail".equals(dialog.getStoptype()))
             node.put("railway", "station");
-          else if ("subway".equals((String)cbStoptype.getSelectedItem()))
+	  else if ("subway".equals(dialog.getStoptype()))
             node.put("railway", "station");
-          else if ("rail".equals((String)cbStoptype.getSelectedItem()))
+	  else if ("rail".equals(dialog.getStoptype()))
             node.put("railway", "station");
         }
@@ -1438,13 +947,13 @@
 	    node.remove("highway");
 	    node.remove("railway");
-	    if ("bus".equals((String)cbStoptype.getSelectedItem()))
+	    if ("bus".equals(dialog.getStoptype()))
 	      node.put("highway", "bus_stop");
-	    else if ("tram".equals((String)cbStoptype.getSelectedItem()))
+	    else if ("tram".equals(dialog.getStoptype()))
 	      node.put("railway", "tram_stop");
-	    else if ("light_rail".equals((String)cbStoptype.getSelectedItem()))
+	    else if ("light_rail".equals(dialog.getStoptype()))
 	      node.put("railway", "station");
-	    else if ("subway".equals((String)cbStoptype.getSelectedItem()))
+	    else if ("subway".equals(dialog.getStoptype()))
 	      node.put("railway", "station");
-	    else if ("rail".equals((String)cbStoptype.getSelectedItem()))
+	    else if ("rail".equals(dialog.getStoptype()))
 	      node.put("railway", "station");
 	  }
@@ -1525,5 +1034,5 @@
 	waypointTM.addRow(waypoint);
       }
-      waypointTable.setModel(waypointTM);
+      dialog.getWaypointsTable().setModel(waypointTM);
     }
     else
@@ -1537,21 +1046,18 @@
   }
   
-  private void tracksSelectionChanged()
+  public void tracksSelectionChanged(int selectedPos)
   {
-    int selectedPos = tracksList.getAnchorSelectionIndex();
-    if (tracksList.isSelectedIndex(selectedPos))
+    if (selectedPos >= 0)
     {
       currentTrack = ((TrackReference)tracksListModel.elementAt(selectedPos));
-      tabbedPane.setEnabledAt(1, true);
-      tabbedPane.setEnabledAt(2, true);
+      dialog.setTrackValid(true);
       
       //Prepare Settings
-      tfGPSTimeStart.setText(currentTrack.gpsSyncTime);
-      tfStopwatchStart.setText(currentTrack.stopwatchStart);
-      tfTimeWindow.setText(Double.toString(currentTrack.timeWindow));
-      tfThreshold.setText(Double.toString(currentTrack.threshold));
+      dialog.setSettings
+	  (currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
+	   currentTrack.timeWindow, currentTrack.threshold);
       
       //Prepare Stoplist
-      stoplistTable.setModel
+      dialog.getStoplistTable().setModel
           (((TrackReference)tracksListModel.elementAt(selectedPos)).stoplistTM);
     }
@@ -1559,6 +1065,5 @@
     {
       currentTrack = null;
-      tabbedPane.setEnabledAt(1, false);
-      tabbedPane.setEnabledAt(2, false);
+      dialog.setTrackValid(false);
     }
   }
@@ -1567,13 +1072,13 @@
   {
     Node node = new Node(latLon);
-    if ("bus".equals((String)cbStoptype.getSelectedItem()))
+    if ("bus".equals(dialog.getStoptype()))
       node.put("highway", "bus_stop");
-    else if ("tram".equals((String)cbStoptype.getSelectedItem()))
+    else if ("tram".equals(dialog.getStoptype()))
       node.put("railway", "tram_stop");
-    else if ("light_rail".equals((String)cbStoptype.getSelectedItem()))
+    else if ("light_rail".equals(dialog.getStoptype()))
       node.put("railway", "station");
-    else if ("subway".equals((String)cbStoptype.getSelectedItem()))
+    else if ("subway".equals(dialog.getStoptype()))
       node.put("railway", "station");
-    else if ("rail".equals((String)cbStoptype.getSelectedItem()))
+    else if ("rail".equals(dialog.getStoptype()))
       node.put("railway", "station");
     node.put("name", name);
@@ -1592,19 +1097,4 @@
   }
     
-  private static double parseTime(String s)
-  {
-    double result = 0;
-    if ((s.charAt(2) != ':') || (s.charAt(2) != ':')
-      || (s.length() < 8))
-      return -1;
-    int hour = Integer.parseInt(s.substring(0, 2));
-    int minute = Integer.parseInt(s.substring(3, 5));
-    double second = Double.parseDouble(s.substring(6, s.length()));
-    if ((hour < 0) || (hour > 23) || (minute < 0) || (minute > 59)
-      || (second < 0) || (second >= 60.0))
-      return -1;
-    return (second + minute*60 + hour*60*60);
-  }
-  
   private static String timeOf(double t)
   {
