use of de.catma.ui.module.project.corpusimport.CorpusImporter in project catma by forTEXT.
the class ProjectView method importCorpus.
private void importCorpus(final File corpusFile, final List<CorpusImportDocumentMetadata> documentMetadataList) {
setEnabled(false);
setProgressBarVisible(true);
try {
final String tempDir = ((CatmaApplication) UI.getCurrent()).accquirePersonalTempFolder();
final UI ui = UI.getCurrent();
BackgroundServiceProvider backgroundServiceProvider = (BackgroundServiceProvider) UI.getCurrent();
BackgroundService backgroundService = backgroundServiceProvider.accuireBackgroundService();
backgroundService.submit(new DefaultProgressCallable<Void>() {
@Override
public Void call() throws Exception {
return new CorpusImporter().importCorpus(getProgressListener(), corpusFile, documentMetadataList, tempDir, ui, project);
}
}, new ExecutionListener<Void>() {
@Override
public void done(Void result) {
setProgressBarVisible(false);
setEnabled(true);
}
@Override
public void error(Throwable t) {
setProgressBarVisible(false);
setEnabled(true);
Logger.getLogger(ProjectView.class.getName()).log(Level.SEVERE, "Error importing the CATMA 5 Corpus!", t);
String errorMsg = t.getMessage();
if ((errorMsg == null) || (errorMsg.trim().isEmpty())) {
errorMsg = "";
}
Notification.show("Error", String.format("Error importing the CATMA 5 Corpus! " + "This import will be aborted!\n The underlying error message was:\n%1$s", errorMsg), Type.ERROR_MESSAGE);
}
}, progressListener);
} catch (Exception e) {
setProgressBarVisible(false);
setEnabled(true);
Logger.getLogger(ProjectView.class.getName()).log(Level.SEVERE, "Error importing the CATMA 5 Corpus!", e);
String errorMsg = e.getMessage();
if ((errorMsg == null) || (errorMsg.trim().isEmpty())) {
errorMsg = "";
}
Notification.show("Error", String.format("Error importing the CATMA 5 Corpus! " + "This import will be aborted!\n The underlying error message was:\n%1$s", errorMsg), Type.ERROR_MESSAGE);
}
}
Aggregations