Changeset 6856 in josm for trunk/src


Ignore:
Timestamp:
2014-02-17T01:07:57+01:00 (6 years ago)
Author:
Don-vip
Message:

see #9715 - do not block start when external presets cannot be retrieved, save the error for later display in global network errors message dialog

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java

    r6733 r6856  
    277277     */
    278278    public static void readFromPreferences() {
    279         taggingPresets = TaggingPresetReader.readFromPreferences(false);
     279        taggingPresets = TaggingPresetReader.readFromPreferences(false, false);
    280280    }
    281281
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java

    r6670 r6856  
    237237    }
    238238
     239    /**
     240     * Reads all tagging presets from the given sources.
     241     * @param sources Collection of tagging presets sources.
     242     * @param validate if {@code true}, presets will be validated against XML schema
     243     * @return Collection of all presets successfully read
     244     */
    239245    public static Collection<TaggingPreset> readAll(Collection<String> sources, boolean validate) {
     246        return readAll(sources, validate, true);
     247    }
     248
     249    /**
     250     * Reads all tagging presets from the given sources.
     251     * @param sources Collection of tagging presets sources.
     252     * @param validate if {@code true}, presets will be validated against XML schema
     253     * @param displayErrMsg if {@code true}, a blocking error message is displayed in case of I/O exception.
     254     * @return Collection of all presets successfully read
     255     */
     256    public static Collection<TaggingPreset> readAll(Collection<String> sources, boolean validate, boolean displayErrMsg) {
    240257        LinkedList<TaggingPreset> allPresets = new LinkedList<TaggingPreset>();
    241258        for(String source : sources)  {
     
    243260                allPresets.addAll(readAll(source, validate));
    244261            } catch (IOException e) {
    245                 Main.error(e);
     262                Main.error(e, false);
    246263                Main.error(source);
    247                 JOptionPane.showMessageDialog(
    248                         Main.parent,
    249                         tr("Could not read tagging preset source: {0}",source),
    250                         tr("Error"),
    251                         JOptionPane.ERROR_MESSAGE
    252                         );
     264                if (source.startsWith("http")) {
     265                    Main.addNetworkError(source, e);
     266                }
     267                if (displayErrMsg) {
     268                    JOptionPane.showMessageDialog(
     269                            Main.parent,
     270                            tr("Could not read tagging preset source: {0}",source),
     271                            tr("Error"),
     272                            JOptionPane.ERROR_MESSAGE
     273                            );
     274                }
    253275            } catch (SAXException e) {
    254276                Main.error(e);
     
    265287    }
    266288   
    267     public static Collection<TaggingPreset> readFromPreferences(boolean validate) {
    268         return readAll(getPresetSources(), validate);
     289    /**
     290     * Reads all tagging presets from sources stored in preferences.
     291     * @param validate if {@code true}, presets will be validated against XML schema
     292     * @param displayErrMsg if {@code true}, a blocking error message is displayed in case of I/O exception.
     293     * @return Collection of all presets successfully read
     294     */
     295    public static Collection<TaggingPreset> readFromPreferences(boolean validate, boolean displayErrMsg) {
     296        return readAll(getPresetSources(), validate, displayErrMsg);
    269297    }
    270298   
Note: See TracChangeset for help on using the changeset viewer.