try {
settings.addLastOpenedFiles(file);
settings.save();
Event startEvent = new Event(Event.EVENT_START_DOCUMENT_LOADING);
startEvent.getParameters().put("file", file);
EventManager.fireEvent(startEvent);
Document document = fileReader.readDocument(
settings.getLangFrom(), settings.getLangTo(), file);
Event endEvent = new Event(Event.EVENT_END_DOCUMENT_LOADING);
endEvent.getParameters().put("file", file);
endEvent.getParameters().put("document", document);
EventManager.fireEvent(endEvent);
} catch (Throwable t) {
Event errorEvent = new Event(Event.EVENT_EXCEPTION);
errorEvent.getParameters().put("file", file);
errorEvent.getParameters().put("exception", t);
errorEvent.getParameters().put("message",
MessageFormat.format("Can''t open document ''{0}''", file.getName()));
EventManager.fireEvent(errorEvent);
LOGGER.error(t, t);