using System; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; using PlasticGui; using Codice.CM.Common; using Codice.Client.Common; using Unity.PlasticSCM.Editor.UI.UIElements; using PlasticGui.Configuration.TeamEdition; using PlasticGui.Configuration; using PlasticGui.WebApi; using Unity.PlasticSCM.Editor.Views.Welcome; namespace Unity.PlasticSCM.Editor.Configuration.TeamEdition { internal class TeamEditionConfigurationWindow : EditorWindow { internal static void ShowWindow(IPlasticWebRestApi restApi, WelcomeView welcomeView) { TeamEditionConfigurationWindow window = GetWindow(); window.mRestApi = restApi; window.mWelcomeView = welcomeView; window.titleContent = new GUIContent( PlasticLocalization.GetString(PlasticLocalization.Name.WelcomeToUnityVCS)); window.minSize = window.maxSize = new Vector2(650, 300); window.Show(); } void OnEnable() { InitializeLayoutAndStyles(); BuildComponents(); } void Dispose() { mConnectButton.clicked -= ConnectButton_Clicked; mCheckConnectionButton.clicked -= CheckConnectionButton_Clicked; mOkButton.clicked -= OkButton_Clicked; mCancelButton.clicked -= CancelButton_Clicked; mServerTextField.UnregisterValueChangedCallback(OnServerTextFieldChanged); mUseSslToggle.UnregisterValueChangedCallback(OnUseSslToggleChanged); mLoadingSpinner.Dispose(); } void ConnectButton_Clicked() { ConfigurationConnectServerButtonClickEvent.Click( server: mUserAssistant.GetProposedServer(), HideValidation: HideValidation, ShowError: ShowServerValidationError, ShowProgress: ShowProgress, HideProgress: HideProgress, ShowNotification: ShowServerNotificationMessage, DisableButtons: () => { mConnectButton.SetEnabled(false); }, EnableButtons: () => { mConnectButton.SetEnabled(true); }, UpdatePasswordEntries: (seidWorkingMode) => { UpdatePasswordEntries(ValidateServerAndCreds. IsPasswordRequired(seidWorkingMode)); }, NotifyWorkingMode: (mode) => { mSEIDWorkingMode = mode; }, NotifyConnectedStatus: (b) => { }); mUserTextField.SetEnabled(true); } void OnDestroy() { Dispose(); if (mWelcomeView != null) mWelcomeView.OnUserClosedConfigurationWindow(); } void CheckConnectionButton_Clicked() { ConfigurationCheckCredentialsButtonClickEvent.Click( mSEIDWorkingMode, mUserTextField.value, mPasswordTextField.value, Edition.Team, mUserAssistant, HideCredentialsValidationError, ShowCheckCredentialsError, ShowProgress, HideProgress, ShowNotification: ShowCredentialsNotificationMessage, DisableButtons: () => { mCheckConnectionButton.SetEnabled(false); mConnectButton.SetEnabled(false); }, EnableButtons: () => { mCheckConnectionButton.SetEnabled(true); mConnectButton.SetEnabled(true); }, NotifyWorkingMode: (mode) => { mSEIDWorkingMode = mode; }, NotifyConnectedStatus: (status) => { }, restApi: mRestApi, cmConnection: CmConnection.Get()); } void CancelButton_Clicked() { Close(); } void OkButton_Clicked() { if (!ValidateServerAndCreds.IsValidInput( mUserAssistant.GetProposedServer(), mUserTextField.value, mSEIDWorkingMode, mPasswordTextField.value, ShowCheckCredentialsError)) { return; } ConfigurationActions.SaveClientConfig( mServerTextField.value, mSEIDWorkingMode, mUserTextField.value, mPasswordTextField.value); Close(); } void HideCredentialsValidationError() { mCredentialsLabel.RemoveFromClassList("error"); mCredentialsLabel.Hide(); } void BuildComponents() { VisualElement root = rootVisualElement; root.Query