checkIfDataIsAlreadyAvailable();
closeAllViews();
//days==5; 14 timeslots per day
JOptionPane.showMessageDialog(null, tr.get(ID + ".question", 5, 9));
StatusBar bar = getApplicationWindow().getStatusBar();
try {
int resultDownload = JOptionPane.showConfirmDialog(null, tr.get(ID + ".downloadQuestion"),
tr.get(ID + ".downloadQuestion"), JOptionPane.YES_NO_OPTION);
if (resultDownload == JOptionPane.YES_OPTION) {
} else {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle(tr.get(ID + ".fileDialog"));
int res = fc.showOpenDialog(getApplicationWindow().getControl());
if (res != JFileChooser.APPROVE_OPTION) {
bar.setMessage(tr.get(ID + ".noFileSelected"));
return;
}
file = fc.getSelectedFile();
if (!file.getName().endsWith(".j1")) {
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;
}
}
istream = new FileInputStream(file);
}
} catch (Exception ex) {
String errorMsg = "Cannot read file! " + ex.getLocalizedMessage();
logger.fatal(errorMsg, ex);
bar.setErrorMessage(errorMsg);
return;
}
MySwingWorker sw = new MySwingWorker(ID) {
@Override
protected void myconstruct() throws Exception {
StatusBar bar = getApplicationWindow().getStatusBar();
ProgressMonitor pm = bar.getProgressMonitor();
int resultDownload = JOptionPane.showConfirmDialog(null, tr.get(ID + ".downloadQuestion"),
tr.get(ID + ".downloadQuestion"), JOptionPane.YES_NO_OPTION);
if (resultDownload == JOptionPane.YES_OPTION) {
String str = "http://peat_hal.users.sourceforge.net/sessions_catalog.j1";
bar.setMessage(tr.get("downloadFrom", str));
istream = new UrlResource(str).getInputStream();
pm.worked(5);
bar.setMessage("");
}
pm.taskStarted(tr.get(ID + ".startTask"), -1);
pm.worked(10);