private class FileManager implements IFileOpener, IFileSaver {
@Override
public void openFile(final File file) {
final WaitLock waitLock = startWait();
new SwingWorker<XmlFile, Void>() {
@Override
public XmlFile doInBackground() throws Exception {
return XmlFile.createXmlFile(file);
}
@Override
public void done() {
try {
XmlFile xmlFile = get();
XmlDocumentFrame frame = new XmlDocumentFrame(MainWindow.this, xmlFile);
frame.setVisible(true);
windowsMenu.addFile(file, frame);
deskTop.add(frame);
searchAction.setEnabled(true);
fileMenu.refresh();
try {
frame.setSelected(true);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
} catch (Exception ex) {
KongaTextArea text = new KongaTextArea(ex.toString(), 5, 40);
String title = "Failed to open '" + file.getName() + "'";
JOptionPane.showMessageDialog(null, new JScrollPane(text), title, JOptionPane.ERROR_MESSAGE);
} finally {
waitLock.release();
}
}
}.execute();
}