public class AutosaveTask extends java.util.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 java.lang.String |
AUTOSAVE_DIR |
private java.io.File |
autosaveDir |
private java.util.Set<DataSet> |
changedDatasets |
private DataSetListenerAdapter |
datasetAdapter |
private static java.lang.String |
DELETED_LAYERS_DIR |
private java.util.Deque<java.io.File> |
deletedLayers |
private java.io.File |
deletedLayersDir |
private static char[] |
ILLEGAL_CHARACTERS |
private java.util.List<AutosaveTask.AutosaveLayerInfo> |
layersInfo |
private java.lang.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 java.util.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 |
discardUnsavedLayers() |
protected void |
displayNotification() |
private static java.lang.String |
getFileName(java.lang.String layerName,
int index) |
private java.io.File |
getNewLayerFile(AutosaveTask.AutosaveLayerInfo layer) |
private java.io.File |
getPidFile(java.io.File osmFile) |
java.util.List<java.io.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(java.lang.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(java.io.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) |
private static final char[] ILLEGAL_CHARACTERS
private static final java.lang.String AUTOSAVE_DIR
private static final java.lang.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 java.util.Set<DataSet> changedDatasets
private final java.util.List<AutosaveTask.AutosaveLayerInfo> layersInfo
private java.util.Timer timer
private final java.lang.Object layersLock
private final java.util.Deque<java.io.File> deletedLayers
private final java.io.File autosaveDir
private final java.io.File deletedLayersDir
public AutosaveTask()
public void schedule()
private static java.lang.String getFileName(java.lang.String layerName, int index)
private void setLayerFileName(AutosaveTask.AutosaveLayerInfo layer)
private java.io.File getNewLayerFile(AutosaveTask.AutosaveLayerInfo layer)
private void savelayer(AutosaveTask.AutosaveLayerInfo info)
public void run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
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 java.io.File getPidFile(java.io.File osmFile)
public java.util.List<java.io.File> getUnsavedLayersFiles()
private boolean jvmPerfDataFileExists(java.lang.String jvmId)
public void recoverUnsavedLayers()
private void moveToDeletedLayersFolder(java.io.File f)
f
- the file, usually from the autosave dirpublic void discardUnsavedLayers()