Ignore:
Timestamp:
2019-09-19T12:26:55+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #18105 - Show a notification if no notes can be downloaded

File:
1 edited

Legend:

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

    r14153 r15358  
    77import java.util.ArrayList;
    88import java.util.Collection;
     9import java.util.HashSet;
    910import java.util.LinkedHashSet;
    1011import java.util.Set;
     
    3435    private Consumer<Collection<Object>> errorReporter;
    3536
     37    private static final Set<String> NO_DATA_ERROR_MESSAGES = new HashSet<>();
     38
    3639    /**
    3740     * Creates a new {@link PostDownloadHandler}
     
    5457        this(task, future);
    5558        this.errorReporter = errorReporter;
     59    }
     60
     61    /**
     62     * Adds a new translated error message indicating that no data has been downloaded.
     63     * @param message new translated error message indicating that no data has been downloaded.
     64     * @return {@code true} if the message was not already known
     65     * @since 15358
     66     */
     67    public static boolean addNoDataErrorMessage(String message) {
     68        return NO_DATA_ERROR_MESSAGES.add(message);
     69    }
     70
     71    /**
     72     * Determines if a translated error message indicates that no data has been downloaded.
     73     * @param message translated error message to check
     74     * @return {@code true} if the message indicates that no data has been downloaded
     75     * @since 15358
     76     */
     77    public static boolean isNoDataErrorMessage(Object message) {
     78        return NO_DATA_ERROR_MESSAGES.contains(message);
    5679    }
    5780
     
    87110                    if (error instanceof Exception) {
    88111                        ExceptionDialogUtil.explainException((Exception) error);
    89                     } else if (tr("No data found in this area.").equals(error)) {
     112                    } else if (isNoDataErrorMessage(error)) {
    90113                        new Notification(error.toString()).setIcon(JOptionPane.WARNING_MESSAGE).show();
    91114                    } else {
Note: See TracChangeset for help on using the changeset viewer.