Source:
public void connect(final XMPPAccount account, boolean setAsDefault, boolean failSilently) { if (Display.getCurrent() == null) throw new SWTException(SWT.ERROR_THREAD_INVALID_ACCESS); if (isConnecting || isDisconnecting && failSilently) return; if (isConnecting || isDisconnecting) { MessageDialog.openWarning( SWTUtils.getShell(), "Error", "A connection attempt is already in progress. Please try again."); return; } isConnecting = true; if (connectionHandler.isConnected() && failSilently) { isConnecting = false; return; } if (sessionManager.getSession() != null && failSilently) { isConnecting = false; return; } boolean mustDisconnect = false; if (sessionManager.getSession() != null) { final boolean disconnectFromSession = MessageDialog.openQuestion( SWTUtils.getShell(), "Disconnecting from the current Saros Session", "Connecting with a different account will disconnect you from your current Saros session. Do you wish to continue ?"); if (!disconnectFromSession) { isConnecting = false; return; } mustDisconnect = true; } if (connectionHandler.isConnected()) { final boolean reconnect = MessageDialog.openQuestion( SWTUtils.getShell(), "Already connected", "Do you want to reconnect as " + account.getUsername() + "@" + account.getDomain() + " ?"); if (!reconnect) { isConnecting = false; return; } mustDisconnect = true; } final XMPPAccount accountToConnect; if (account == null) accountToConnect = store.getDefaultAccount(); else accountToConnect = account; if (setAsDefault && accountToConnect != null) { store.setDefaultAccount(accountToConnect); } final boolean disconnectFirst = mustDisconnect; ThreadUtils.runSafeAsync( "dpp-connect-xmpp", log, () -> { if (disconnectFirst) connectionHandler.disconnect(); try { connectionHandler.connect(accountToConnect, failSilently); } finally { isConnecting = false; } }); }

Target:
public void connect(final XMPPAccount account, boolean setAsDefault, boolean failSilently) { if (Display.getCurrent() == null) throw new SWTException(SWT.ERROR_THREAD_INVALID_ACCESS); if (isConnecting || isDisconnecting && failSilently) return; if (isConnecting || isDisconnecting) { MessageDialog.openWarning( SWTUtils.getShell(), "Error", "A connection attempt is already in progress. Please try again."); return; } isConnecting = true; if (connectionHandler.isConnected() && failSilently) { isConnecting = false; return; } if (sessionManager.getSession() != null && failSilently) { isConnecting = false; return; } boolean mustDisconnect = false; if (sessionManager.getSession() != null) { final boolean disconnectFromSession = MessageDialog.openQuestion( SWTUtils.getShell(), "Disconnecting from the current Saros Session", "Connecting with a different account will disconnect you from your current Saros session. Do you wish to continue ?"); if (!disconnectFromSession) { isConnecting = false; return; } mustDisconnect = true; } if (connectionHandler.isConnected()) { final boolean reconnect = MessageDialog.openQuestion( SWTUtils.getShell(), "Already connected", "Do you want to reconnect as " + account.getUsername() + "@" + account.getDomain() + " ?"); if (!reconnect) { isConnecting = false; return; } mustDisconnect = true; } final XMPPAccount accountToConnect; accountToConnect = account != null ? account : store.getDefaultAccount(); if (accountToConnect == null) { log.warn( "unable to establish a connection - no account was provided and no default account could be found"); isConnecting = false; return; } if (setAsDefault) store.setDefaultAccount(accountToConnect); final boolean disconnectFirst = mustDisconnect; ThreadUtils.runSafeAsync( "dpp-connect-xmpp", log, () -> { if (disconnectFirst) connectionHandler.disconnect(); try { connectionHandler.connect(accountToConnect, failSilently); } finally { isConnecting = false; } }); }