// TODO: What if cancel is pressed?
@RequestHandler
public void connect() {
final XulDialog waitDialog = (XulDialog) document.getElementById(ANON_WAIT_DIALOG);
try {
if (selectedSchemaProvider == null) {
throw new AggDesignerException(Messages.getString("select_olap_model"));
}
workspace.setApplicationUnlocked(false);
new Thread() {
@Override
public void run() {
try {
while (waitDialog.isHidden()) {
Thread.sleep(300);
}
ConnectionController.this.schema = selectedSchemaProvider.loadSchema(connectionModel.getCubeName());
} catch (Exception e) {
//consume, schema will be null which is checked outside of this thread
logger.error("Error loading schema: ", e);
} finally {
waitDialog.hide();
}
}
}.start();
waitDialog.show();
if (schema == null) {
throw new AggDesignerException("Error loading Schema");
}
connectionModel.setSchema(schema);
outputService.init(schema);
connectionModel.setSchemaUpToDate(true);
// don't unlock app until everything has succeeded.
workspace.setApplicationUnlocked(true);
hideConnectionDialog();
} catch (Exception e) {
logger.error("Unable to connect", e);
if (!waitDialog.isHidden()) {
waitDialog.hide();
}
XulDialog connectErrorDialog = (XulDialog) document.getElementById(CONNECT_ERROR_DIALOG);
Assert.notNull(connectErrorDialog, "missing element from document");
XulTextbox connectErrorDialogMessage = (XulTextbox) document.getElementById("connectErrorDialogMessage");
Assert.notNull(connectErrorDialogMessage, "missing element from document");
connectErrorDialogMessage.setValue(e.getLocalizedMessage());
connectErrorDialog.show();
}
}