ok.setEnabled(true);
label.setText(Labels.getString("DataSelectionDialog.errorRead")); //$NON-NLS-1$
shell.setText(Labels.getString("DataSelectionDialog.titleError"));
return;
}
DataReader dataReader = (DataReader)controller.getDao();
List header = null;
int totalRows = 0;
try {
dataReader.checkConnection();
dataReader.open();
String warning = DAORowUtil.validateColumns(dataReader);
if(warning != null && warning.length() != 0) {
int response = UIUtils.warningConfMessageBox(shell, warning + "\n" + Labels.getString("DataSelectionDialog.warningConf"));
// in case user doesn't want to continue, treat this as an error
if(response != SWT.YES) {
success = false;
ok.setEnabled(true);
label.setText(Labels.getString("DataSelectionDialog.errorCSVFormat")); //$NON-NLS-1$
shell.setText(Labels.getString("DataSelectionDialog.titleError"));
return;
}
}
totalRows = dataReader.getTotalRows();
if ((header = dataReader.getColumnNames())== null || header.size() == 0) {
success = false;
ok.setEnabled(true);
label.setText(Labels.getString("DataSelectionDialog.errorCSVFormat")); //$NON-NLS-1$
shell.setText(Labels.getString("DataSelectionDialog.titleError"));
return;
}
} catch (DataAccessObjectException e) {
success = false;
ok.setEnabled(true);
label.setText(Labels.getString("DataSelectionDialog.errorCSVFormat") + " " + e.getMessage()); //$NON-NLS-1$
Point size = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
label.setSize(shell.getClientArea().width, size.y);
shell.setText(Labels.getString("DataSelectionDialog.titleError"));
shell.pack();
shell.redraw();
return;
} finally {
dataReader.close();
}
success = true;
ok.setEnabled(true);
label.setText(Labels.getFormattedString(
"DataSelectionDialog.initSuccess", String.valueOf(totalRows))); //$NON-NLS-1$