Ignore:
Timestamp:
2010-08-24T10:32:50+02:00 (14 years ago)
Author:
bastiK
Message:

added gui preference for autosave; fixed #5359 - Button to delete autosaved data

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/AutosaveTask.java

    r3435 r3461  
    2525import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
    2626import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter.Listener;
     27import org.openstreetmap.josm.data.preferences.BooleanProperty;
    2728import org.openstreetmap.josm.data.preferences.IntegerProperty;
    2829import org.openstreetmap.josm.gui.MapView;
     
    4142    private static final String DELETED_LAYERS_DIR = "autosave/deleted_layers";
    4243
    43 
     44    public static final BooleanProperty PROP_AUTOSAVE_ENABLED = new BooleanProperty("autosave.enabled", true);
    4445    public static final IntegerProperty PROP_FILES_PER_LAYER = new IntegerProperty("autosave.filesPerLayer", 1);
    4546    public static final IntegerProperty PROP_DELETED_LAYERS = new IntegerProperty("autosave.deletedLayersBackupCount", 5);
    4647    public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", 5 * 60);
     48    public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000);
    4749
    4850    private static class AutosaveLayerInfo {
     
    5961    private final List<AutosaveLayerInfo> layersInfo = new ArrayList<AutosaveLayerInfo>();
    6062    private Timer timer;
    61     private Object layersLock = new Object();
     63    private final Object layersLock = new Object();
    6264    private final Deque<File> deletedLayers = new LinkedList<File>();
    6365
     
    136138                else {
    137139                    System.out.println(tr("Unable to create file {0}, other filename will be used", result.getAbsolutePath()));
     140                    if (index > PROP_INDEX_LIMIT.get())
     141                        throw new IOException("index limit exceeded");
    138142                }
    139143            } catch (IOException e) {
     
    278282    }
    279283
     284    public void dicardUnsavedLayers() {
     285        for (File f: getUnsavedLayersFiles()) {
     286            f.renameTo(new File(deletedLayersDir, f.getName()));
     287        }
     288    }
    280289
    281290}
  • trunk/src/org/openstreetmap/josm/data/preferences/IntegerProperty.java

    r3451 r3461  
    2222    }
    2323
     24    /**
     25     * parses and saves an integer value
     26     * @param value the value to be parsed
     27     * @return true - preference value has changed
     28     *         false - parsing failed or preference value has not changed
     29     */
     30    public boolean parseAndPut(String value) {
     31        Integer intVal;
     32        try {
     33            intVal = Integer.parseInt(value);
     34        } catch (NumberFormatException ex) {
     35            return false;
     36        }
     37        return put(intVal);
     38    }
     39
    2440    public String getKey() {
    2541        return key;
Note: See TracChangeset for help on using the changeset viewer.