Changeset 35722 in osm for applications/editors


Ignore:
Timestamp:
2021-03-13T13:23:28+01:00 (3 years ago)
Author:
Don-vip
Message:

fix #20579 - fix EDT violation

Location:
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/ValidatingImageryReader.java

    r33493 r35722  
    44import java.io.IOException;
    55
    6 import javax.xml.XMLConstants;
    76import javax.xml.transform.stream.StreamSource;
    8 import javax.xml.validation.Schema;
    9 import javax.xml.validation.SchemaFactory;
    107
    118import org.openstreetmap.josm.io.CachedFile;
    129import org.openstreetmap.josm.io.imagery.ImageryReader;
    1310import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants;
     11import org.openstreetmap.josm.tools.XmlUtils;
    1412import org.xml.sax.SAXException;
    1513
     
    5250     */
    5351    public static void validate(String source) throws SAXException, IOException {
    54         SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    5552        try (CachedFile xmlSchema = new CachedFile(XML_SCHEMA)) {
    56             Schema schema = factory.newSchema(new StreamSource(xmlSchema.getInputStream()));
    57             schema.newValidator().validate(new StreamSource(source));
     53            XmlUtils.newXmlSchemaFactory()
     54                .newSchema(new StreamSource(xmlSchema.getInputStream()))
     55                .newValidator().validate(new StreamSource(source));
    5856        }
    5957    }
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/XmlBoundsImporter.java

    r34518 r35722  
    6464            entries = reader.parse();
    6565        } catch (SAXException e) {
    66             Logging.trace(e);
    67             if (JOptionPane.showConfirmDialog(
     66            Logging.warn(e);
     67            if (JOptionPane.YES_OPTION != GuiHelper.runInEDTAndWaitAndReturn(() -> JOptionPane.showConfirmDialog(
    6868                    MainApplication.getMainFrame(),
    6969                    tr("Validating error in file {0}:\n{1}\nDo you want to continue without validating the file ?",
    7070                            source != null ? source : file.getPath(), e.getLocalizedMessage()),
    7171                    tr("Open Imagery XML file"),
    72                     JOptionPane.YES_NO_CANCEL_OPTION) != JOptionPane.YES_OPTION) {
    73                 return null;
    74             }
     72                    JOptionPane.YES_NO_CANCEL_OPTION))) {
     73                return null;
     74            }
    7575
    7676            try (ImageryReader reader = new ImageryReader(source != null ? source : file.getAbsolutePath())) {
Note: See TracChangeset for help on using the changeset viewer.