Index: trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 3461)
@@ -25,4 +25,5 @@
 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener;
+import org.openstreetmap.josm.data.preferences.BooleanProperty;
 import org.openstreetmap.josm.data.preferences.IntegerProperty;
 import org.openstreetmap.josm.gui.MapView;
@@ -41,8 +42,9 @@
     private static final String DELETED_LAYERS_DIR = "autosave/deleted_layers";
 
-
+    public static final BooleanProperty PROP_AUTOSAVE_ENABLED = new BooleanProperty("autosave.enabled", true);
     public static final IntegerProperty PROP_FILES_PER_LAYER = new IntegerProperty("autosave.filesPerLayer", 1);
     public static final IntegerProperty PROP_DELETED_LAYERS = new IntegerProperty("autosave.deletedLayersBackupCount", 5);
     public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", 5 * 60);
+    public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000);
 
     private static class AutosaveLayerInfo {
@@ -59,5 +61,5 @@
     private final List<AutosaveLayerInfo> layersInfo = new ArrayList<AutosaveLayerInfo>();
     private Timer timer;
-    private Object layersLock = new Object();
+    private final Object layersLock = new Object();
     private final Deque<File> deletedLayers = new LinkedList<File>();
 
@@ -136,4 +138,6 @@
                 else {
                     System.out.println(tr("Unable to create file {0}, other filename will be used", result.getAbsolutePath()));
+                    if (index > PROP_INDEX_LIMIT.get())
+                        throw new IOException("index limit exceeded");
                 }
             } catch (IOException e) {
@@ -278,4 +282,9 @@
     }
 
+    public void dicardUnsavedLayers() {
+        for (File f: getUnsavedLayersFiles()) {
+            f.renameTo(new File(deletedLayersDir, f.getName()));
+        }
+    }
 
 }
Index: trunk/src/org/openstreetmap/josm/data/preferences/IntegerProperty.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/preferences/IntegerProperty.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/data/preferences/IntegerProperty.java	(revision 3461)
@@ -22,4 +22,20 @@
     }
 
+    /**
+     * parses and saves an integer value
+     * @param value the value to be parsed
+     * @return true - preference value has changed
+     *         false - parsing failed or preference value has not changed
+     */
+    public boolean parseAndPut(String value) {
+        Integer intVal;
+        try {
+            intVal = Integer.parseInt(value);
+        } catch (NumberFormatException ex) {
+            return false;
+        }
+        return put(intVal);
+    }
+
     public String getKey() {
         return key;
Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 3461)
@@ -3,4 +3,5 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.I18n.trn;
 
 import java.awt.EventQueue;
@@ -247,26 +248,30 @@
         }
 
-        AutosaveTask autosaveTask = new AutosaveTask();
-        List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles();
-        if (!unsavedLayerFiles.isEmpty()) {
-            ExtendedDialog dialog = new ExtendedDialog(
-                    Main.parent,
-                    tr("Unsaved osm data"),
-                    new String[] {tr("Restore"), tr("Cancel")}
-            );
-            dialog.setContent(tr("JOSM found {0} unsaved osm data layers. It looks like JOSM crashed last time. Do you want to restore data?",
-                    unsavedLayerFiles.size()));
-            dialog.setButtonIcons(new String[] {"ok.png", "cancel.png"});
-            dialog.showDialog();
-            if (dialog.getValue() == 1) {
-                for (OsmDataLayer layer: autosaveTask.getUnsavedLayers()) {
-                    Main.main.addLayer(layer);
+        if (AutosaveTask.PROP_AUTOSAVE_ENABLED.get()) {
+            AutosaveTask autosaveTask = new AutosaveTask();
+            List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles();
+            if (!unsavedLayerFiles.isEmpty()) {
+                ExtendedDialog dialog = new ExtendedDialog(
+                        Main.parent,
+                        tr("Unsaved osm data"),
+                        new String[] {tr("Restore"), tr("Cancel"), tr("Discard")}
+                );
+                dialog.setContent(
+                        trn("JOSM found {0} unsaved osm data layer. ",
+                        "JOSM found {0} unsaved osm data layers. ", unsavedLayerFiles.size(), unsavedLayerFiles.size()) +
+                        tr("It looks like JOSM crashed last time. Do you like to restore the data?"));
+                dialog.setButtonIcons(new String[] {"ok", "cancel", "dialogs/remove"});
+                int selection = dialog.showDialog().getValue();
+                if (selection == 1) {
+                    for (OsmDataLayer layer: autosaveTask.getUnsavedLayers()) {
+                        Main.main.addLayer(layer);
+                    }
+                    AutoScaleAction.autoScale("data");
+                } else if (selection == 3) {
+                    autosaveTask.dicardUnsavedLayers();
                 }
-                AutoScaleAction.autoScale("data");
-            }
-
-
-        }
-        autosaveTask.schedule();
+            }
+            autosaveTask.schedule();
+        }
 
 
Index: trunk/src/org/openstreetmap/josm/gui/preferences/BackupPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/BackupPreference.java	(revision 3461)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/BackupPreference.java	(revision 3461)
@@ -0,0 +1,112 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.preferences;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
+import javax.swing.JTextField;
+
+import org.openstreetmap.josm.data.AutosaveTask;
+import org.openstreetmap.josm.data.preferences.BooleanProperty;
+import org.openstreetmap.josm.gui.widgets.HtmlPanel;
+import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
+import org.openstreetmap.josm.tools.GBC;
+
+public class BackupPreference implements PreferenceSetting {
+
+    public static class Factory implements PreferenceSettingFactory {
+        @Override
+        public BackupPreference createPreferenceSetting() {
+            return new BackupPreference();
+        }
+    }
+    private static final BooleanProperty PROP_KEEP_BACKUP = new BooleanProperty("save.keepbackup", false);
+    private JCheckBox keepBackup;
+    private JCheckBox autosave;
+    private final JTextField autosaveInterval = new JTextField(8);
+    private final JTextField backupPerLayer = new JTextField(8);
+
+    @Override
+    public void addGui(PreferenceTabbedPane gui) {
+        JPanel panel = new VerticallyScrollablePanel();
+        panel.setLayout(new GridBagLayout());
+        panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+
+        autosave = new JCheckBox("Auto save enabled");
+        autosave.setSelected(AutosaveTask.PROP_AUTOSAVE_ENABLED.get());
+        panel.add(autosave, GBC.eol());
+
+        final JLabel autosaveIntervalLabel = new JLabel(tr("Auto save interval (seconds)"));
+        panel.add(autosaveIntervalLabel, GBC.std().insets(60,0,0,0));
+        autosaveInterval.setText(Integer.toString(AutosaveTask.PROP_INTERVAL.get()));
+        autosaveInterval.setToolTipText(tr("Default value: {0}", AutosaveTask.PROP_INTERVAL.getDefaultValue()));
+        autosaveInterval.setMinimumSize(autosaveInterval.getPreferredSize());
+        panel.add(autosaveInterval, GBC.eol().insets(5,0,0,5));
+
+        final JLabel backupPerLayerLabel = new JLabel(tr("Auto saved files per layer"));
+        panel.add(backupPerLayerLabel, GBC.std().insets(60,0,0,0));
+        backupPerLayer.setText(Integer.toString(AutosaveTask.PROP_FILES_PER_LAYER.get()));
+        backupPerLayer.setToolTipText(tr("Default value: {0}", AutosaveTask.PROP_FILES_PER_LAYER.getDefaultValue()));
+        backupPerLayer.setMinimumSize(backupPerLayer.getPreferredSize());
+        panel.add(backupPerLayer, GBC.eol().insets(5,0,0,10));
+
+        panel.add(new HtmlPanel(
+            tr("<i>(Autosave stores the changed data layers in periodic intervals. " +
+                "The backups are saved in JOSM''s preference folder. " +
+                "In case of a crash, JOSM tries to recover the unsaved changes " +
+                "on next start.)</i>")),
+            GBC.eop().fill(GBC.HORIZONTAL).insets(5,0,0,10));
+
+        panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL));
+
+        keepBackup = new JCheckBox(tr("Keep backup files when saving data layers"));
+        keepBackup.setSelected(PROP_KEEP_BACKUP.get());
+        keepBackup.setToolTipText(tr("When saving, keep backup files ending with a ~"));
+        panel.add(keepBackup, GBC.eop());
+
+        panel.add(new HtmlPanel(
+            tr("<i>(JOSM can keep a backup file when saving data layers. "+
+                "It appends ''~'' to the file name and saves it in the same folder.)</i>")),
+            GBC.eop().fill(GBC.HORIZONTAL).insets(5,0,0,0));
+
+        ActionListener autosaveEnabled = new ActionListener(){
+            public void actionPerformed(ActionEvent e) {
+                boolean enabled = autosave.isSelected();
+                autosaveIntervalLabel.setEnabled(enabled);
+                autosaveInterval.setEnabled(enabled);
+                backupPerLayerLabel.setEnabled(enabled);
+                backupPerLayer.setEnabled(enabled);
+            }
+        };
+        autosave.addActionListener(autosaveEnabled);
+        autosaveEnabled.actionPerformed(null);
+
+        panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
+        JScrollPane sp = new JScrollPane(panel);
+        sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+        sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+
+        gui.mapcontent.addTab(tr("File backup"), null, sp, tr("Configure whether to create backup files"));
+    }
+
+    @Override
+    public boolean ok() {
+        boolean restartRequired = false;
+        PROP_KEEP_BACKUP.put(keepBackup.isSelected());
+
+        restartRequired |= AutosaveTask.PROP_AUTOSAVE_ENABLED.put(autosave.isSelected());
+        restartRequired |= AutosaveTask.PROP_INTERVAL.parseAndPut(autosaveInterval.getText());
+        AutosaveTask.PROP_FILES_PER_LAYER.parseAndPut(backupPerLayer.getText());
+        return restartRequired;
+    }
+}
Index: trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java	(revision 3461)
@@ -78,5 +78,5 @@
                     WindowGeometry.centerInWindow(
                             getParent(),
-                            new Dimension(600,800)
+                            new Dimension(700,800)
                     )
             ).applySafe(this);
Index: trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java	(revision 3461)
@@ -268,4 +268,5 @@
         settingsFactory.add(new MapPaintPreference.Factory());
         settingsFactory.add(new TaggingPresetPreference.Factory());
+        settingsFactory.add(new BackupPreference.Factory());
         if(!Main.applet) {
             settingsFactory.add(new PluginPreference.Factory());
Index: trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java	(revision 3461)
@@ -29,4 +29,5 @@
 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs;
 import org.openstreetmap.josm.gui.NavigatableComponent;
+import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
 import org.openstreetmap.josm.tools.GBC;
 
@@ -107,5 +108,5 @@
      * This is the panel holding all projection preferences
      */
-    private JPanel projPanel = new JPanel();
+    private JPanel projPanel = new VerticallyScrollablePanel();
 
     /**
Index: trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/ServerAccessPreference.java	(revision 3461)
@@ -36,5 +36,4 @@
     private ProxyPreferencesPanel pnlProxyPreferences;
     /** panel for backup preferences */
-    private BackupPreferencesPanel pnlBackupPreferences;
 
     /**
@@ -63,13 +62,9 @@
         pnlProxyPreferences = new ProxyPreferencesPanel();
         tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlProxyPreferences));
-        pnlBackupPreferences = new BackupPreferencesPanel();
-        tpServerPreferences.add(wrapVerticallyScrollablePanel(pnlBackupPreferences));
 
         tpServerPreferences.setTitleAt(0, tr("Authentication"));
         tpServerPreferences.setTitleAt(1, tr("Proxy settings"));
-        tpServerPreferences.setTitleAt(2, tr("File backup"));
         tpServerPreferences.setToolTipTextAt(0, tr("Configure your identity and how to authenticate at the OSM server"));
         tpServerPreferences.setToolTipTextAt(1, tr("Configure whether to use a proxy server"));
-        tpServerPreferences.setToolTipTextAt(2, tr("Configure whether to create backup files"));
 
         pnl.add(tpServerPreferences, BorderLayout.CENTER);
@@ -127,5 +122,4 @@
         pnlAuthPreferences.initFromPreferences();
         pnlProxyPreferences.initFromPreferences();
-        pnlBackupPreferences.initFromPreferences();
     }
 
@@ -137,5 +131,4 @@
         pnlAuthPreferences.saveToPreferences();
         pnlProxyPreferences.saveToPreferences();
-        pnlBackupPreferences.saveToPreferences();
         return false;
     }
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/BackupPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/BackupPreferencesPanel.java	(revision 3460)
+++ 	(revision )
@@ -1,54 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.preferences.server;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-
-import javax.swing.BorderFactory;
-import javax.swing.JCheckBox;
-import javax.swing.JPanel;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.gui.help.HelpUtil;
-import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
-
-public class BackupPreferencesPanel extends VerticallyScrollablePanel {
-
-    private JCheckBox keepBackup;
-
-    protected void build() {
-        setLayout(new GridBagLayout());
-        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
-
-        GridBagConstraints gc = new GridBagConstraints();
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 1.0;
-        keepBackup = new JCheckBox(tr("Keep backup files"));
-        keepBackup.setSelected(Main.pref.getBoolean("save.keepbackup"));
-        keepBackup.setToolTipText(tr("When saving, keep backup files ending with a ~"));
-        add(keepBackup, gc);
-
-        // filler - grab remaining space
-        gc.gridy = 1;
-        gc.fill = GridBagConstraints.BOTH;
-        gc.weightx = 1.0;
-        gc.weighty = 1.0;
-        add(new JPanel(), gc);
-    }
-
-    public void saveToPreferences() {
-        Main.pref.put("save.keepbackup", keepBackup.isSelected());
-    }
-
-    public void initFromPreferences() {
-        keepBackup.setSelected(Main.pref.getBoolean("save.keepbackup", true));
-    }
-
-    public BackupPreferencesPanel() {
-        build();
-        HelpUtil.setHelpContext(this, HelpUtil.ht("/Preferences/Connection#BackupSettings"));
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/gui/widgets/HtmlPanel.java	(revision 3461)
@@ -13,5 +13,5 @@
 
 /**
- * This panel can be used to display larger larger sections of formatted text in
+ * This panel can be used to display larger sections of formatted text in
  * HTML.
  *
@@ -61,4 +61,9 @@
     }
 
+    public HtmlPanel(String text) {
+        this();
+        setText(text);
+    }
+
     /**
      * Replies the editor pane used internally to render the HTML text.
Index: trunk/src/org/openstreetmap/josm/io/OsmExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmExporter.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/io/OsmExporter.java	(revision 3461)
@@ -79,5 +79,5 @@
             }
             // FIXME - how to close?
-            if (!Main.pref.getBoolean("save.keepbackup") && (tmpFile != null)) {
+            if (!Main.pref.getBoolean("save.keepbackup", false) && (tmpFile != null)) {
                 tmpFile.delete();
             }
Index: trunk/src/org/openstreetmap/josm/tools/I18n.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/I18n.java	(revision 3460)
+++ trunk/src/org/openstreetmap/josm/tools/I18n.java	(revision 3461)
@@ -118,6 +118,17 @@
 
     /**
-     * Set by MainApplication. Changes here later will probably mess up everything, because
-     * many strings are already loaded.
+     * Translates some text for the current locale.
+     * These strings are collected by a script that runs on the source code files.
+     * After translation, the localizations are distributed with the main program.
+     *
+     * @param text the text to translate.
+     * Must be a string literal. (No constants or local vars.)
+     * Can be broken over multiple lines.
+     * An apostrophe ' must be quoted by another apostrophe.
+     * @param objects Parameters for the string.
+     * Mark occurrences in <code>text</code> with {0}, {1}, ...
+     * @return the translated string
+     *
+     * Example: tr("JOSM''s default value is ''{0}''.", val);
      */
     public static final String tr(String text, Object... objects) {
@@ -131,13 +142,30 @@
     }
 
-    public static final String trc(String ctx, String text) {
-        if (ctx == null)
+    /**
+     * Provide translation in a context.
+     * There can be different translations for the same text (but 
+     * different context).
+     *
+     * @param context string that helps translators to find an appropriate
+     * translation for <code>text</code>
+     * @param text the text to translate
+     * @return the translated string
+     */
+    public static final String trc(String context, String text) {
+        if (context == null)
             return tr(text);
         if (text == null)
             return null;
-        return MessageFormat.format(gettext(text, ctx), (Object)null);
-    }
-
-    /* NOTE: marktr does NOT support context strings - use marktrc instead */
+        return MessageFormat.format(gettext(text, context), (Object)null);
+    }
+
+    /**
+     * Marks a string for translation (such that a script can harvest
+     * the translatable strings from the source files).
+     *
+     * Example:
+     * String[] options = new String[] {marktr("up"), marktr("down")};
+     * lbl.setText(tr(options[0]));
+     */
     public static final String marktr(String text) {
         return text;
@@ -148,8 +176,14 @@
     }
 
+    /**
+     * Example: trn("Found {0} error!", "Found {0} errors!", i, Integer.toString(i));
+     */
     public static final String trn(String text, String pluralText, long n, Object... objects) {
         return MessageFormat.format(gettextn(text, pluralText, null, n), objects);
     }
 
+    /**
+     * Example: trn("There was an error!", "There were errors!", i);
+     */
     public static final String trn(String text, String pluralText, long n) {
         return MessageFormat.format(gettextn(text, pluralText, null, n), (Object)null);
