Changeset 6357 in josm for trunk/src/org


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

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

Location:
trunk/src/org/openstreetmap/josm
Files:
3 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
  • trunk/src/org/openstreetmap/josm/gui/Notification.java

    r6340 r6357  
    5858    private String helpTopic;
    5959
     60    /**
     61     * Constructs a new {@code Notification} without content.
     62     */
    6063    public Notification() {
    6164        duration = NotificationManager.defaultNotificationTime;
    6265    }
    6366
     67    /**
     68     * Constructs a new {@code Notification} with the given textual content.
     69     * @param msg The text to display
     70     */
    6471    public Notification(String msg) {
    6572        this();
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/BackupPreference.java

    r6084 r6357  
    2323import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    2424import org.openstreetmap.josm.gui.widgets.HtmlPanel;
     25import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2526import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
    2627import org.openstreetmap.josm.tools.GBC;
    27 import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2828
    2929public class BackupPreference implements SubPreferenceSetting {
     
    3636    }
    3737    private static final BooleanProperty PROP_KEEP_BACKUP = new BooleanProperty("save.keepbackup", false);
     38    private JCheckBox notification;
    3839    private JCheckBox keepBackup;
    3940    private JCheckBox autosave;
     
    8485            GBC.eop().fill(GBC.HORIZONTAL).insets(5,0,0,0));
    8586
     87        panel.add(new JSeparator(), GBC.eop().fill(GBC.HORIZONTAL));
     88
     89        notification = new JCheckBox(tr("Notification at each save"));
     90        notification.setSelected(AutosaveTask.PROP_NOTIFICATION.get());
     91        notification.setToolTipText(tr("When saving, display a small notification"));
     92        panel.add(notification, GBC.eop());
     93       
    8694        ActionListener autosaveEnabled = new ActionListener(){
    8795            @Override
     
    113121        restartRequired |= AutosaveTask.PROP_INTERVAL.parseAndPut(autosaveInterval.getText());
    114122        AutosaveTask.PROP_FILES_PER_LAYER.parseAndPut(backupPerLayer.getText());
     123        AutosaveTask.PROP_NOTIFICATION.put(notification.isSelected());
    115124        return restartRequired;
    116125    }
Note: See TracChangeset for help on using the changeset viewer.