Changeset 15358 in josm for trunk


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

Location:
trunk/src/org/openstreetmap/josm/actions/downloadtasks
Files:
4 edited

Legend:

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

    r15332 r15358  
    4949
    5050    private static final String PATTERN_COMPRESS = "https?://.*/(.*\\.osn.(gz|xz|bz2?|zip))";
     51    private static final String NO_NOTES_FOUND = tr("No notes found in this area.");
     52    static {
     53        PostDownloadHandler.addNoDataErrorMessage(NO_NOTES_FOUND);
     54    }
    5155
    5256    private DownloadTask downloadTask;
     
    133137            if (notesData.isEmpty()) {
    134138                if (warnAboutEmptyArea) {
    135                     rememberErrorMessage(tr("No notes found in this area."));
     139                    rememberErrorMessage(NO_NOTES_FOUND);
    136140                }
    137141                return;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r15353 r15358  
    6363
    6464    protected static final String OVERPASS_INTERPRETER_DATA = "interpreter?data=";
     65
     66    private static final String NO_DATA_FOUND = tr("No data found in this area.");
     67    static {
     68        PostDownloadHandler.addNoDataErrorMessage(NO_DATA_FOUND);
     69    }
    6570
    6671    @Override
     
    466471            if (dataSet.allPrimitives().isEmpty()) {
    467472                if (warnAboutEmptyArea) {
    468                     rememberErrorMessage(tr("No data found in this area."));
     473                    rememberErrorMessage(NO_DATA_FOUND);
    469474                }
    470475                String remark = dataSet.getRemark();
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java

    r15353 r15358  
    264264
    265265                GuiHelper.runInEDT(() -> {
    266                     if (items.size() == 1 && tr("No data found in this area.").equals(items.iterator().next())) {
     266                    if (items.size() == 1 && PostDownloadHandler.isNoDataErrorMessage(items.iterator().next())) {
    267267                        new Notification(items.iterator().next()).setIcon(JOptionPane.WARNING_MESSAGE).show();
    268268                    } else {
  • 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.