forked from External/mage
* UI: improved connects and disconnects processing:
* fixed app freeze on broken server; * fixed app freeze on cancel button clicks; * fixed wrong still connected dialogs on app close or connect; * fixed missing wrong versions message; * improved error logs and messages.
This commit is contained in:
parent
718bfb0a52
commit
5a0f01c14a
6 changed files with 150 additions and 97 deletions
|
|
@ -517,7 +517,6 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
char[] input = new char[0];
|
||||
try {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
connection = new Connection();
|
||||
connection.setHost(this.txtServer.getText().trim());
|
||||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
||||
|
|
@ -545,6 +544,12 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
}//GEN-LAST:event_btnConnectActionPerformed
|
||||
|
||||
private void setConnectButtonsState(boolean enable) {
|
||||
btnConnect.setEnabled(enable);
|
||||
btnRegister.setEnabled(enable);
|
||||
btnForgotPassword.setEnabled(enable);
|
||||
}
|
||||
|
||||
private class ConnectTask extends SwingWorker<Boolean, Void> {
|
||||
|
||||
private boolean result = false;
|
||||
|
|
@ -555,7 +560,7 @@ public class ConnectDialog extends MageDialog {
|
|||
@Override
|
||||
protected Boolean doInBackground() throws Exception {
|
||||
lblStatus.setText("Connecting...");
|
||||
btnConnect.setEnabled(false);
|
||||
setConnectButtonsState(false);
|
||||
result = MageFrame.connect(connection);
|
||||
lastConnectError = SessionHandler.getLastConnectError();
|
||||
return result;
|
||||
|
|
@ -565,7 +570,6 @@ public class ConnectDialog extends MageDialog {
|
|||
protected void done() {
|
||||
try {
|
||||
get(CONNECTION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
if (result) {
|
||||
lblStatus.setText("");
|
||||
connected();
|
||||
|
|
@ -578,13 +582,13 @@ public class ConnectDialog extends MageDialog {
|
|||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Players Task error", ex);
|
||||
} catch (CancellationException ex) {
|
||||
logger.info("Connect was canceled");
|
||||
logger.info("Connect: canceled");
|
||||
lblStatus.setText("Connect was canceled");
|
||||
} catch (TimeoutException ex) {
|
||||
logger.fatal("Connection timeout: ", ex);
|
||||
} finally {
|
||||
MageFrame.stopConnecting();
|
||||
btnConnect.setEnabled(true);
|
||||
setConnectButtonsState(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue