use of org.opendatakit.briefcase.util.ServerConnectionTest in project briefcase by opendatakit.
the class ServerConnectionDialog method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (CONNECT.equals(e.getActionCommand())) {
// do action...
final ServerConnectionInfo info = new ServerConnectionInfo((textUrlField.getText()).trim(), textUsernameField.getText(), textPasswordField.getPassword());
okButton.setEnabled(false);
cancelButton.setEnabled(false);
String errorString;
Cursor saved = getCursor();
try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
paint(getGraphics());
terminationFuture.reset();
ServerConnectionTest backgroundAction = new ServerConnectionTest(info, terminationFuture, asTarget);
backgroundAction.run();
isSuccessful = backgroundAction.isSuccessful();
errorString = backgroundAction.getErrorReason();
} finally {
setCursor(saved);
}
if (isSuccessful) {
serverInfo = info;
this.setVisible(false);
} else {
String errorMessage = errorString.trim();
// with punctuation and some not
if (!(errorMessage.endsWith("!") || errorMessage.endsWith("."))) {
errorMessage += ". ";
}
ODKOptionPane.showErrorDialog(this, errorMessage + MessageStrings.PROXY_SET_ADVICE, "Invalid Server URL");
okButton.setEnabled(true);
cancelButton.setEnabled(true);
}
} else {
// cancel...
terminationFuture.markAsCancelled(new TransferAbortEvent("User cancels connection."));
this.setVisible(false);
}
}
Aggregations