* @throws DataReaderException if any exception occurred, it is logged and added as the cause
* to this exception
*/
public GCModel loadModel(URL url, boolean showErrorDialog, Component parent) throws DataReaderException {
// set up special handler
TextAreaLogHandler textAreaLogHandler = new TextAreaLogHandler();
PARSER_LOGGER.addHandler(textAreaLogHandler);
DataReaderException dataReaderException = new DataReaderException();
GCModel model = null;
try {
LOGGER.info("GCViewer version " + BuildInfoReader.getVersion() + " (" + BuildInfoReader.getBuildDate() + ")");
model = readModel(url);
model.setURL(url);
}
catch (RuntimeException | IOException e) {
LOGGER.severe(LocalisationHelper.getString("fileopen_dialog_read_file_failed")
+ "\n" + e.toString() + " " + e.getLocalizedMessage());
dataReaderException.initCause(e);
}
finally {
// remove special handler after we are done with reading.
PARSER_LOGGER.removeHandler(textAreaLogHandler);
}
if (textAreaLogHandler.hasErrors() && showErrorDialog) {
showErrorDialog(url, textAreaLogHandler, parent);
}
if (dataReaderException.getCause() != null) {
throw dataReaderException;