protected void doOnce() {
checkIfDataIsAlreadyAvailable();
closeAllViews();
ApplicationWindow aw = getApplicationWindow();
final StatusBar bar = aw.getStatusBar();
final ProgressMonitor pm = bar.getProgressMonitor();
JFileChooser fc = new JFileChooser();
fc.setDialogTitle(tr.get(ID + ".fileDialog"));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int res = fc.showOpenDialog(aw.getControl());
if (res != JFileChooser.APPROVE_OPTION) {
bar.setMessage(tr.get(ID + ".noFileSelected"));
return;
}
file = fc.getSelectedFile();
if (!file.isDirectory()) {
int resultOP = JOptionPane.showConfirmDialog(null, tr.get(ID + ".confirmation.message"),
tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
if (resultOP != JOptionPane.OK_OPTION) {
return;
}
}
pm.taskStarted(tr.get(ID + ".startTask"), 100);
MySwingWorker sw = new MySwingWorker(ID) {
@Override
protected void myconstruct() throws Exception {
bar.getProgressMonitor().worked(10);
ImportText importer = new ImportText(dataPool, settings, file);
bar.getProgressMonitor().worked(20);
importer.doWork();
bar.getProgressMonitor().worked(80);
}
@Override
protected void done() {
bar.getProgressMonitor().worked(90);
openAllViews();
bar.getProgressMonitor().worked(100);
super.done();
}
};
sw.execute();