parser.addNavigationFileParserListener(listener);
try {
invokeAndWait(new Runnable() {
public void run() {
Gpx11Format gpxFormat = new Gpx11Format();
formatAndRoutesModel.setRoutes(new FormatAndRoutes(gpxFormat, new GpxRoute(gpxFormat)));
urlModel.clear();
}
});
final ParserResult result = parser.read(url, formats);
if (result.isSuccessful()) {
log.info("Opened: " + path);
final NavigationFormat format = result.getFormat();
countRead(format);
if (!checkReadFormat(format))
return;
invokeLater(new Runnable() {
public void run() {
formatAndRoutesModel.setRoutes(new FormatAndRoutes(format, result.getAllRoutes()));
comboBoxChoosePositionList.setModel(formatAndRoutesModel);
urlModel.setString(path);
recentUrlsModel.addUrl(url);
if (urls.size() > 1) {
List<URL> append = new ArrayList<>(urls);
append.remove(0);
// this way the route is always marked as modified :-(
appendPositionList(-1, append);
}
}
});
} else {
invokeLater(new Runnable() {
public void run() {
Gpx11Format gpxFormat = new Gpx11Format();
formatAndRoutesModel.setRoutes(new FormatAndRoutes(gpxFormat, new GpxRoute(gpxFormat)));
}
});
r.handleUnsupportedFormat(path);
}