Ignore:
Timestamp:
2021-08-20T14:18:17+02:00 (5 years ago)
Author:
Don-vip
Message:

see #16709 - fix #20755 - Display a notification while/after saving session files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java

    r16553 r18135  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.actions;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.util.Collection;
     
    79import javax.swing.filechooser.FileFilter;
    810
     11import org.openstreetmap.josm.gui.Notification;
     12import org.openstreetmap.josm.gui.util.GuiHelper;
    913import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
    1014import org.openstreetmap.josm.gui.widgets.FileChooserManager;
     15import org.openstreetmap.josm.tools.ImageProvider;
    1116import org.openstreetmap.josm.tools.Shortcut;
    1217
     
    137142                .openFileChooser();
    138143    }
     144
     145    /**
     146     * Show "saving file ..." notification and returns it, for future replacement.
     147     * @param filename filename of file to save
     148     * @return {@link Notification} to provide to {@link #showSavedNotification} once saving is successful
     149     * @since 18135
     150     */
     151    protected static Notification showSavingNotification(String filename) {
     152        Notification savingNotification = new Notification(tr("Saving file {0}...", filename)).setIcon(ImageProvider.get("save"));
     153        GuiHelper.runInEDT(savingNotification::show);
     154        return savingNotification;
     155    }
     156
     157    /**
     158     * Show "Successfully saved file" notification and returns it.
     159     * @param savingNotification {@link Notification} returned by {@link #showSavingNotification}
     160     * @param filename filename of file saved
     161     * @return {@code Notification} displayed
     162     * @since 18135
     163     */
     164    protected static Notification showSavedNotification(Notification savingNotification, String filename) {
     165        Notification doneNotification = new Notification(tr("Successfully saved file {0}", filename)).setIcon(ImageProvider.get("save"));
     166        GuiHelper.runInEDT(() -> doneNotification.replaceExisting(savingNotification));
     167        return doneNotification;
     168    }
    139169}
Note: See TracChangeset for help on using the changeset viewer.