/// <summary>
        /// Sets the new connection settings for the addin,
        /// connects to the server and refreshes the active wiki explorer.
        /// </summary>
        private void ApplyConnectionSettings()
        {
            Cursor c = addinSettingsForm.Cursor;

            addinSettingsForm.Cursor = Cursors.WaitCursor;
            if (addinSettingsForm.ServerURL.EndsWith("/"))
            {
                addinSettingsForm.ServerURL = addinSettingsForm.ServerURL.Substring(0, addinSettingsForm.ServerURL.Length - 1);
            }
            addin.ServerURL = addinSettingsForm.ServerURL;
            addin.Username  = addinSettingsForm.UserName;
            addin.Password  = addinSettingsForm.Password;
            LoginData loginData = new LoginData(LoginData.XWORD_LOGIN_DATA_FILENAME);

            addin.Client = XWikiClientFactory.CreateXWikiClient(addin.ClientType,
                                                                addin.ServerURL, addin.Username, addin.Password);

            if (addinSettingsForm.IsCkRememberMeChecked)
            {
                String[] credentials = new String[3];
                credentials[0] = Globals.XWord2003AddIn.ServerURL;
                credentials[1] = Globals.XWord2003AddIn.Username;
                credentials[2] = Globals.XWord2003AddIn.Password;
                loginData.WriteCredentials(credentials);
            }
            else
            {
                loginData.ClearCredentials();
            }
            //Write the settings to isolated storage.
            XOfficeCommonSettingsHandler.WriteRepositorySettings(addinSettings);

            addinSettingsForm.Cursor = c;
        }