Ignore:
Timestamp:
2013-11-02T21:28:24+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #5382 - add an option to display a notification at each autosave (disabled by default)

File:
1 edited

Legend:

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

    r6248 r6357  
    3434import org.openstreetmap.josm.gui.MapView;
    3535import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
     36import org.openstreetmap.josm.gui.Notification;
    3637import org.openstreetmap.josm.gui.layer.Layer;
    3738import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     39import org.openstreetmap.josm.gui.util.GuiHelper;
    3840import org.openstreetmap.josm.io.OsmExporter;
    3941import org.openstreetmap.josm.io.OsmImporter;
     
    6769    public static final IntegerProperty PROP_INTERVAL = new IntegerProperty("autosave.interval", 5 * 60);
    6870    public static final IntegerProperty PROP_INDEX_LIMIT = new IntegerProperty("autosave.index-limit", 1000);
     71    /** Defines if a notification should be displayed after each autosave */
     72    public static final BooleanProperty PROP_NOTIFICATION = new BooleanProperty("autosave.notification", false);
    6973
    7074    private static class AutosaveLayerInfo {
     
    205209                }
    206210                changedDatasets.clear();
     211                if (PROP_NOTIFICATION.get() && !layersInfo.isEmpty()) {
     212                    displayNotification();
     213                }
    207214            } catch (Throwable t) {
    208215                // Don't let exception stop time thread
     
    212219            }
    213220        }
     221    }
     222
     223    protected void displayNotification() {
     224        GuiHelper.runInEDT(new Runnable() {
     225            @Override
     226            public void run() {
     227                new Notification(tr("Your work has been saved automatically."))
     228                .setDuration(Notification.TIME_SHORT)
     229                .show();
     230            }
     231        });
    214232    }
    215233
Note: See TracChangeset for help on using the changeset viewer.