public class AutosaveTask extends TimerTask implements MapView.LayerChangeListener, DataSetListenerAdapter.Listener
Modifier and Type | Class and Description |
---|---|
private static class |
AutosaveTask.AutosaveLayerInfo |
Modifier and Type | Field and Description |
---|---|
private static String |
AUTOSAVE_DIR |
private File |
autosaveDir |
private Set<DataSet> |
changedDatasets |
private DataSetListenerAdapter |
datasetAdapter |
private static String |
DELETED_LAYERS_DIR |
private Deque<File> |
deletedLayers |
private File |
deletedLayersDir |
private static char[] |
ILLEGAL_CHARACTERS |
private List<AutosaveTask.AutosaveLayerInfo> |
layersInfo |
private Object |
layersLock |
static BooleanProperty |
PROP_AUTOSAVE_ENABLED |
static IntegerProperty |
PROP_DELETED_LAYERS |
static IntegerProperty |
PROP_FILES_PER_LAYER |
static IntegerProperty |
PROP_INDEX_LIMIT |
static IntegerProperty |
PROP_INTERVAL |
static BooleanProperty |
PROP_NOTIFICATION
Defines if a notification should be displayed after each autosave
|
private Timer |
timer |
Constructor and Description |
---|
AutosaveTask() |
Modifier and Type | Method and Description |
---|---|
void |
activeLayerChange(Layer oldLayer,
Layer newLayer)
Notifies this listener that the active layer has changed.
|
void |
dicardUnsavedLayers() |
protected void |
displayNotification() |
private String |
getFileName(String layerName,
int index) |
private File |
getNewLayerFile(AutosaveTask.AutosaveLayerInfo layer) |
private File |
getPidFile(File osmFile) |
List<File> |
getUnsavedLayersFiles()
Replies the list of .osm files still present in autosave dir, that are not currently managed by another instance of JOSM.
|
private boolean |
jvmPerfDataFileExists(String jvmId) |
void |
layerAdded(Layer newLayer)
Notifies this listener that a layer has been added.
|
void |
layerRemoved(Layer oldLayer)
Notifies this listener that a layer has been removed.
|
private void |
moveToDeletedLayersFolder(File f)
Move file to the deleted layers directory.
|
void |
processDatasetEvent(AbstractDatasetChangedEvent event) |
void |
recoverUnsavedLayers() |
private void |
registerNewlayer(OsmDataLayer layer) |
void |
run() |
private void |
savelayer(AutosaveTask.AutosaveLayerInfo info) |
void |
schedule() |
private void |
setLayerFileName(AutosaveTask.AutosaveLayerInfo layer) |
cancel, scheduledExecutionTime
private static final char[] ILLEGAL_CHARACTERS
private static final String AUTOSAVE_DIR
private static final String DELETED_LAYERS_DIR
public static final BooleanProperty PROP_AUTOSAVE_ENABLED
public static final IntegerProperty PROP_FILES_PER_LAYER
public static final IntegerProperty PROP_DELETED_LAYERS
public static final IntegerProperty PROP_INTERVAL
public static final IntegerProperty PROP_INDEX_LIMIT
public static final BooleanProperty PROP_NOTIFICATION
private final DataSetListenerAdapter datasetAdapter
private final Set<DataSet> changedDatasets
private final List<AutosaveTask.AutosaveLayerInfo> layersInfo
private final Object layersLock
private final Deque<File> deletedLayers
private final File autosaveDir
private final File deletedLayersDir
public AutosaveTask()
public void schedule()
private String getFileName(String layerName, int index)
private void setLayerFileName(AutosaveTask.AutosaveLayerInfo layer)
private File getNewLayerFile(AutosaveTask.AutosaveLayerInfo layer)
private void savelayer(AutosaveTask.AutosaveLayerInfo info) throws IOException
IOException
protected void displayNotification()
public void activeLayerChange(Layer oldLayer, Layer newLayer)
MapView.LayerChangeListener
activeLayerChange
in interface MapView.LayerChangeListener
oldLayer
- The previous active layernewLayer
- The new activer layerprivate void registerNewlayer(OsmDataLayer layer)
public void layerAdded(Layer newLayer)
MapView.LayerChangeListener
layerAdded
in interface MapView.LayerChangeListener
newLayer
- The new added layerpublic void layerRemoved(Layer oldLayer)
MapView.LayerChangeListener
layerRemoved
in interface MapView.LayerChangeListener
oldLayer
- The old removed layerpublic void processDatasetEvent(AbstractDatasetChangedEvent event)
processDatasetEvent
in interface DataSetListenerAdapter.Listener
private final File getPidFile(File osmFile)
public List<File> getUnsavedLayersFiles()
private boolean jvmPerfDataFileExists(String jvmId)
public void recoverUnsavedLayers()
private void moveToDeletedLayersFolder(File f)
f
- the file, usually from the autosave dirpublic void dicardUnsavedLayers()