if (i != JOptionPane.OK_OPTION)
return;
// parse the contents and insert the resulting dictionary
tworker = new TaskWorker(yoshikoder){
VBProFileParser parser = new VBProFileParser();
protected void doWork() throws Exception {
importedDictionary = parser.parse(f, preview.getSelectedEncoding().name());
importedDictionary.setName(f.getName());
if (parser.getErrors().size()>0)
throw new Exception("non-fatal import errors");
}
protected void onSuccess() {
log.info("parsed dictionary without major errors");
log.info("setting dictionary to imported version");
yoshikoder.setDictionary(importedDictionary);
yoshikoder.setUnsavedChanges(true);
}
protected void onError() {
if (parser.getErrors() == null){
// serious error occurred before parser had a chance to work
DialogUtil.yelp(yoshikoder, "Could not parse contents of VBPro file", e);
} else {
// nonfatal errors
List l = parser.getErrors();
if (l.size() > 0){
JTextArea area = new JTextArea(20, 40);
area.setFont(yoshikoder.getDisplayFont());
area.setEditable(false);
area.setLineWrap(true);