Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java	(revision 10747)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSInfo.java	(revision 10767)
@@ -8,5 +8,5 @@
  * @author Frederik Ramm <frederik@remote.org>
  */
-public class WMSInfo {
+public class WMSInfo implements Comparable {
 	
 	String name;
@@ -23,4 +23,17 @@
 		Main.pref.put("wmsplugin.url." + prefid + ".url", url);
 	}
-	
+	public int compareTo(Object c)
+	{
+		Integer i = 0;
+		if(c instanceof WMSInfo)
+		{
+			WMSInfo in = (WMSInfo)c;
+			i = name.compareTo(in.name);
+			if(i == 0)
+				i = url.compareTo(in.url);
+			if(i == 0)
+				i = prefid-in.prefid;
+		}
+		return i;
+	}
 }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java	(revision 10747)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java	(revision 10767)
@@ -7,4 +7,5 @@
 import java.awt.event.KeyEvent;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Map;
 import java.util.TreeSet;
@@ -39,6 +40,6 @@
 	static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
 
-       // remember state of menu item to restore on changed preferences
-       static private boolean menuEnabled = false;
+	// remember state of menu item to restore on changed preferences
+	static private boolean menuEnabled = false;
 	
 	public WMSPlugin() {
@@ -82,5 +83,4 @@
 		String url = null;
 		int lastid = -1;
-		boolean isYahoo = false;
 		for (String key : keys) {
 			String[] elements = key.split("\\.");
@@ -92,45 +92,19 @@
 			}
 			if (prefid != lastid) {
-				if ((name != null) && (url != null)) {
-					wmsList.add(new WMSInfo(name, url, prefid));
-					if(url.startsWith("yahoo://")) isYahoo = true;
-				}
-				name = null; url = null; lastid = prefid; 
+				name = url = null; lastid = prefid;
 			}
-			if (elements[3].equals("name")) {
-				name=prefs.get(key);
-			} else if (elements[3].equals("url")) {
+			if (elements[3].equals("name"))
+				name = prefs.get(key);
+			else if (elements[3].equals("url"))
 				url = prefs.get(key);
-			}		
+			if (name != null && url != null)
+				wmsList.add(new WMSInfo(name, url, prefid));
 		}
-		if ((name != null) && (url != null)) {
-			wmsList.add(new WMSInfo(name, url, prefid));
-			if(url.startsWith("yahoo://")) isYahoo = true;
-		}
+		setDefault(tr("Landsat"), "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&"+
+		"layers=global_mosaic&styles=&srs=EPSG:4326&format=image/jpeg");
+		setDefault(tr("NPE Maps"), "http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe&");
+		setDefault(tr("YAHOO"), "yahoo://gnome-web-photo --mode=photo --format=png {0} /dev/stdout");
 
-		// if no (valid) prefs are set, initialize to a sensible default.
-		if (wmsList.isEmpty()) {
-			WMSInfo landsatInfo = new WMSInfo(tr("Landsat"),
-					"http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&"+
-					"layers=global_mosaic&styles=&srs=EPSG:4326&"+
-					"format=image/jpeg", 1);
-			landsatInfo.save();
-			wmsList.add(landsatInfo);
-			
-			WMSInfo npeInfo = new WMSInfo(tr("NPE Maps"),
-					"http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe&", 2);
-			npeInfo.save();
-			wmsList.add(npeInfo);
-		}
-		if(!isYahoo){ //add Yahoo to the list, if there isn't
-			int maxKey = 0;
-			for(WMSInfo in : wmsList)
-				if(maxKey < in.prefid)maxKey = in.prefid;
-			WMSInfo yahooInfo = new WMSInfo(tr("YAHOO"),
-					"yahoo://gnome-web-photo --mode=photo --format=png {0} /dev/stdout", maxKey+1);
-			yahooInfo.save();
-			wmsList.add(yahooInfo);
-		}
-		
+		Collections.sort(wmsList);
 		JMenuBar menu = Main.main.menu;
 
@@ -159,5 +133,26 @@
 		wmsJMenu.addSeparator();
 		wmsJMenu.add(new JMenuItem(new Help_WMSmenuAction()));
-               setEnabledAll(menuEnabled);
+		setEnabledAll(menuEnabled);
+	}
+
+	/* add a default entry in case the URL does not yet exist */
+	private static void setDefault(String name, String url)
+	{
+		String testurl = url.replaceAll("=", "_");
+		if(!Main.pref.getBoolean("wmsplugin.default."+testurl))
+		{
+			Main.pref.put("wmsplugin.default."+testurl, true);
+			int id = -1;
+			for(WMSInfo i : wmsList)
+			{
+				if(url.equals(i.url))
+					return;
+				if(i.prefid > id)
+					id = i.prefid;
+			}
+			WMSInfo newinfo = new WMSInfo(name, url, id+1);
+			newinfo.save();
+			wmsList.add(newinfo);
+		}
 	}
 
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java	(revision 10747)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java	(revision 10767)
@@ -30,5 +30,4 @@
 	private Map<String,String> orig;
 	private DefaultTableModel model;
-	private int highestIdUsed = 0;
 	private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
 	
@@ -36,11 +35,6 @@
 		JPanel p = gui.createPreferenceTab("wms", tr("WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS plugin menu"));
 		
-		model = new DefaultTableModel(new String[]{"#", tr("Menu Name"), tr("WMS URL")}, 0) {
-			@Override public boolean isCellEditable(int row, int column) {
-				return column != 0;
-			}
-		};
+		model = new DefaultTableModel(new String[]{tr("Menu Name"), tr("WMS URL")}, 0);
 		final JTable list = new JTable(model);
-		list.getColumnModel().removeColumn(list.getColumnModel().getColumn(0));
 		JScrollPane scroll = new JScrollPane(list);
 		p.add(scroll, GBC.eol().fill(GBC.BOTH));
@@ -49,6 +43,5 @@
 		for (WMSInfo i : WMSPlugin.wmsList) {
 			oldValues.put(i.prefid, i);
-			model.addRow(new String[]{Integer.toString(i.prefid), i.name, i.url});
-			if (i.prefid > highestIdUsed) highestIdUsed = i.prefid;
+			model.addRow(new String[]{i.name, i.url});
 		}
 		
@@ -67,20 +60,21 @@
 				int answer = JOptionPane.showConfirmDialog(gui, p, tr("Enter a menu name and WMS URL"), JOptionPane.OK_CANCEL_OPTION);
 				if (answer == JOptionPane.OK_OPTION) {
-					highestIdUsed++;
-					model.addRow(new String[]{Integer.toString(highestIdUsed), key.getText(), value.getText()});
+					model.addRow(new String[]{key.getText(), value.getText()});
 				}
 			}
 		});
-				
+
 		JButton delete = new JButton(tr("Delete"));
 		p.add(delete, GBC.std().insets(0,5,0,0));
 		delete.addActionListener(new ActionListener(){
 			public void actionPerformed(ActionEvent e) {
-				if (list.getSelectedRowCount() == 0) {
+				if (list.getSelectedRow() == -1)
 					JOptionPane.showMessageDialog(gui, tr("Please select the row to delete."));
-					return;
+				else
+				{
+					Integer i;
+					while ((i = list.getSelectedRow()) != -1)
+						model.removeRow(i);
 				}
-				while (list.getSelectedRow() != -1)
-					model.removeRow(list.getSelectedRow());
 			}
 		});
@@ -90,16 +84,17 @@
 		boolean change = false;
 		for (int i = 0; i < model.getRowCount(); ++i) {
-			int id = Integer.parseInt(model.getValueAt(i, 0).toString());
-			String name = model.getValueAt(i,1).toString();
-			String url = model.getValueAt(i,2).toString();
-			
-			WMSInfo origValue = oldValues.get(id);
-			if (origValue == null) {
-				new WMSInfo(name, url, id).save();
+			String name = model.getValueAt(i,0).toString();
+			String url = model.getValueAt(i,1).toString();
+
+			WMSInfo origValue = oldValues.get(i);
+			if (origValue == null)
+			{
+				new WMSInfo(name, url, i).save();
 				change = true;
-			} else {
-				if (origValue.name.equals(name) && origValue.url.equals(url)) {
-					// no change
-				} else {
+			}
+			else
+			{
+				if (!origValue.name.equals(name) || !origValue.url.equals(url))
+				{
 					origValue.name = name; 
 					origValue.url = url;
@@ -107,17 +102,18 @@
 					change = true;
 				}
-				oldValues.remove(id);
+				oldValues.remove(i);
 			}
 		}
 		
-               // using null values instead of empty string really deletes
-               // the preferences entry
-		for (WMSInfo i : oldValues.values()) {
-                       i.url = null;
-                       i.name = null;
+		// using null values instead of empty string really deletes
+		// the preferences entry
+		for (WMSInfo i : oldValues.values())
+		{
+			i.url = null;
+			i.name = null;
 			i.save();
 			change = true;
 		}
-		
+
 		if (change) WMSPlugin.refreshMenu();
 	}
@@ -133,19 +129,16 @@
         for (int i = 0; i < model.getRowCount(); i++) 
         {
-            String name = model.getValueAt(i,1).toString();
-            if( name.equals(server) )
+            if( server.equals(model.getValueAt(i,0).toString()) )
             {
-                model.setValueAt(url, i, 2);
+                model.setValueAt(url, i, 1);
                 return;
             }
-        }        
+        }
+        model.addRow(new String[]{server, url});
+    }
 
-        highestIdUsed++;
-        model.addRow(new String[]{Integer.toString(highestIdUsed), server, url});
-    }
-    
     /**
      * Gets a server URL in the preferences dialog. Used by other plugins.
-     * 
+     *
      * @param server The server name
      * @return The server URL
@@ -155,12 +148,9 @@
         for (int i = 0; i < model.getRowCount(); i++) 
         {
-            String name = model.getValueAt(i,1).toString();
-            if( name.equals(server) )
+            if( server.equals(model.getValueAt(i,0).toString()) )
             {
-                String url = model.getValueAt(i,2).toString();
-                return url;
+                return model.getValueAt(i,1).toString();
             }
         }
-        
         return null;
     }
