Commit 1c847220 authored by jang dong hyeok's avatar jang dong hyeok
Browse files

.

parent 076f0c68
using System;
using System.Reflection;
using UnityEditor;
namespace Unity.PlasticSCM.Editor
{
internal static class CollabPlugin
{
internal static bool IsEnabled()
{
return IsCollabInstanceEnabled();
}
internal static void Disable()
{
DisableCollabInstance();
DisableCollabInProjectSettings();
}
static void DisableCollabInstance()
{
object collabInstance = GetCollabInstance();
if (collabInstance == null)
return;
// Invokes Collab.instance.SetCollabEnabledForCurrentProject(false)
SetCollabEnabledForCurrentProject(collabInstance, false);
}
static void DisableCollabInProjectSettings()
{
// Invokes PlayerSettings.SetCloudServiceEnabled("Collab", false)
SetCloudServiceEnabled("Collab", false);
AssetDatabase.SaveAssets();
}
static bool IsCollabInstanceEnabled()
{
object collabInstance = GetCollabInstance();
if (collabInstance == null)
return false;
// Invokes Collab.instance.IsCollabEnabledForCurrentProject()
return IsCollabEnabledForCurrentProject(collabInstance);
}
static void SetCollabEnabledForCurrentProject(object collabInstance, bool enable)
{
MethodInfo InternalSetCollabEnabledForCurrentProject =
CollabType.GetMethod("SetCollabEnabledForCurrentProject");
if (InternalSetCollabEnabledForCurrentProject == null)
return;
InternalSetCollabEnabledForCurrentProject.
Invoke(collabInstance, new object[] { enable });
}
static void SetCloudServiceEnabled(string setting, bool enable)
{
MethodInfo InternalSetCloudServiceEnabled = PlayerSettingsType.GetMethod(
"SetCloudServiceEnabled",
BindingFlags.NonPublic | BindingFlags.Static);
if (InternalSetCloudServiceEnabled == null)
return;
InternalSetCloudServiceEnabled.
Invoke(null, new object[] { setting, enable });
}
static object GetCollabInstance()
{
if (CollabType == null)
return null;
PropertyInfo InternalInstance =
CollabType.GetProperty("instance");
if (InternalInstance == null)
return null;
return InternalInstance.GetValue(null, null);
}
static bool IsCollabEnabledForCurrentProject(object collabInstance)
{
MethodInfo InternalIsCollabEnabledForCurrentProject =
CollabType.GetMethod("IsCollabEnabledForCurrentProject");
if (InternalIsCollabEnabledForCurrentProject == null)
return false;
return (bool)InternalIsCollabEnabledForCurrentProject.
Invoke(collabInstance, null);
}
static readonly Type CollabType =
typeof(UnityEditor.Editor).Assembly.
GetType("UnityEditor.Collaboration.Collab");
static readonly Type PlayerSettingsType =
typeof(UnityEditor.PlayerSettings);
}
}
using Codice.Client.Common;
using Codice.CM.Common;
using PlasticGui;
using PlasticPipe.Certificates;
using Unity.PlasticSCM.Editor.UI;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal class ChannelCertificateUiImpl : IChannelCertificateUI
{
internal ChannelCertificateUiImpl()
{
}
CertOperationResult IChannelCertificateUI.AcceptNewServerCertificate(PlasticCertInfo serverCertificate)
{
return GetUserResponse(
PlasticLocalization.GetString(
PlasticLocalization.Name.NewCertificateTitle),
PlasticLocalization.GetString(
PlasticLocalization.Name.NewCertificateMessage),
serverCertificate);
}
CertOperationResult IChannelCertificateUI.AcceptChangedServerCertificate(PlasticCertInfo serverCertificate)
{
return GetUserResponse(
PlasticLocalization.GetString(
PlasticLocalization.Name.ExistingCertificateChangedTitle),
PlasticLocalization.GetString(
PlasticLocalization.Name.ExistingCertificateChangedMessage),
serverCertificate);
}
bool IChannelCertificateUI.AcceptInvalidHostname(string certHostname, string serverHostname)
{
bool result = false;
GUIActionRunner.RunGUIAction(delegate {
result = EditorUtility.DisplayDialog(
PlasticLocalization.GetString(
PlasticLocalization.Name.InvalidCertificateHostnameTitle),
PlasticLocalization.GetString(
PlasticLocalization.Name.InvalidCertificateHostnameMessage,
certHostname, serverHostname),
PlasticLocalization.GetString(PlasticLocalization.Name.YesButton),
PlasticLocalization.GetString(PlasticLocalization.Name.NoButton));
});
return result;
}
CertOperationResult GetUserResponse(
string title, string message, PlasticCertInfo serverCertificate)
{
GuiMessage.GuiMessageResponseButton result =
GuiMessage.GuiMessageResponseButton.Third;
GUIActionRunner.RunGUIAction(delegate {
result = GuiMessage.ShowQuestion(
title, GetCertificateMessageString(message, serverCertificate),
PlasticLocalization.GetString(PlasticLocalization.Name.YesButton),
PlasticLocalization.GetString(PlasticLocalization.Name.NoButton),
PlasticLocalization.GetString(PlasticLocalization.Name.CancelButton),
true);
});
switch (result)
{
case GuiMessage.GuiMessageResponseButton.First:
return CertOperationResult.AddToStore;
case GuiMessage.GuiMessageResponseButton.Second:
return CertOperationResult.DoNotAddToStore;
case GuiMessage.GuiMessageResponseButton.Third:
return CertOperationResult.Cancel;
default:
return CertOperationResult.Cancel;
}
}
string GetCertificateMessageString(string message, PlasticCertInfo serverCertificate)
{
return string.Format(message,
CertificateUi.GetCnField(serverCertificate.Subject),
CertificateUi.GetCnField(serverCertificate.Issuer),
serverCertificate.Format,
serverCertificate.ExpirationDateString,
serverCertificate.KeyAlgorithm,
serverCertificate.CertHashString);
}
}
}
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using PlasticGui;
using PlasticGui.WebApi;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class CloudEditionWelcomeWindow : EditorWindow
{
internal static void ShowWindow(IPlasticWebRestApi restApi)
{
CloudEditionWelcomeWindow window = GetWindow<CloudEditionWelcomeWindow>();
window.mRestApi = restApi;
window.titleContent = new GUIContent(
PlasticLocalization.GetString(PlasticLocalization.Name.SignInToPlasticSCM));
window.minSize = new Vector2(800, 460);
window.Show();
}
void OnEnable()
{
BuildComponents();
}
void OnDestroy()
{
Dispose();
}
void Dispose()
{
mSignInPanel.Dispose();
mSSOSignUpPanel.Dispose();
}
internal void BuildComponents()
{
VisualElement root = rootVisualElement;
root.Clear();
mTabView = new TabView();
mSignInPanel = new SignInPanel(this);
mSSOSignUpPanel = new SSOSignUpPanel(this, mRestApi);
mTabView.AddTab(
PlasticLocalization.GetString(PlasticLocalization.Name.Login),
mSignInPanel);
mTabView.AddTab(
PlasticLocalization.GetString(PlasticLocalization.Name.SignUp),
mSSOSignUpPanel).clicked += () =>
{
titleContent = new GUIContent(
PlasticLocalization.GetString(PlasticLocalization.Name.SignUp));
};
root.Add(mTabView);
}
internal TabView mTabView;
SignInPanel mSignInPanel;
SSOSignUpPanel mSSOSignUpPanel;
IPlasticWebRestApi mRestApi;
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.Linq;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class CreateOrganizationPanel : VisualElement
{
internal CreateOrganizationPanel(VisualElement rootPanel)
{
mRootPanel = rootPanel;
InitializeLayoutAndStyles();
BuildComponents();
}
internal void Dispose()
{
mLoadingSpinner.Dispose();
mCreateButton.clicked -= CreateButton_Clicked;
mOrganizationNameTextField.UnregisterValueChangedCallback(
OnOrganizationNameTextFieldChanged);
}
void StartProgress()
{
mGettingDatacenters.RemoveFromClassList("hidden");
mLoadingSpinner.Start();
}
void StopProgress()
{
mGettingDatacenters.AddToClassList("hidden");
mLoadingSpinner.Stop();
}
void OnOrganizationNameTextFieldChanged(ChangeEvent<string> evt)
{
mOrganizationNameNotification.text = "";
}
void DataCenterClicked(DropdownMenuAction action)
{
mSelectedDatacenter = action.name;
mDatacenter.text = action.name;
}
void CreateButton_Clicked()
{
//TODO: Launch organization creation task
mRootPanel.Clear();
mRootPanel.Add(new CreatedOrganizationPanel(mOrganizationNameTextField.text));
}
DropdownMenuAction.Status DataCenterActive(DropdownMenuAction action)
{
if (action.name == mSelectedDatacenter)
return DropdownMenuAction.Status.Checked;
return DropdownMenuAction.Status.Normal;
}
IEnumerable<string> GetDatacenters()
{
// TODO: Replace with call
return new string[]
{
"Test Server 1",
"Test Server 2",
"Test Server 3",
"Test Server 4",
"Test Server 5"
};
}
static void SetGettingDatacentersVisibility(
VisualElement gettingDatacenters,
bool visible)
{
if (visible)
{
gettingDatacenters.AddToClassList("hidden");
return;
}
gettingDatacenters.RemoveFromClassList("hidden");
}
void BuildComponents()
{
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.ColorBuho);
VisualElement spinnerControl = this.Query<VisualElement>("gdSpinner").First();
mLoadingSpinner = new LoadingSpinner();
spinnerControl.Add(mLoadingSpinner);
IEnumerable<string> datacenters = GetDatacenters();
mSelectedDatacenter = datacenters.FirstOrDefault();
mDatacenter = new ToolbarMenu { text = mSelectedDatacenter };
foreach (string datacenter in GetDatacenters())
mDatacenter.menu.AppendAction(datacenter, DataCenterClicked, DataCenterActive);
VisualElement datacenterContainer = this.Query<VisualElement>("datacenter").First();
datacenterContainer.Add(mDatacenter);
mOrganizationNameTextField = this.Query<TextField>("orgName").First();
mOrganizationNameNotification = this.Query<Label>("orgNameNotification").First();
mBackButton = this.Query<Button>("back").First();
mCreateButton = this.Query<Button>("create").First();
mEncryptLearnMoreButton = this.Query<Button>("encryptLearnMore").First();
mGettingDatacenters = this.Query<VisualElement>("gettingDatacenters").First();
mCreateButton.clicked += CreateButton_Clicked;
mOrganizationNameTextField.RegisterValueChangedCallback(
OnOrganizationNameTextFieldChanged);
mOrganizationNameTextField.FocusOnceLoaded();
this.SetControlText<Label>("createLabel",
PlasticLocalization.Name.CreateOrganizationTitle);
this.SetControlLabel<TextField>("orgName",
PlasticLocalization.Name.OrganizationName);
this.SetControlText<Label>("datacenterLabel",
PlasticLocalization.Name.Datacenter);
this.SetControlText<Toggle>("encryptData",
PlasticLocalization.Name.EncryptionCheckButton);
this.SetControlText<Label>("encryptExplanation",
PlasticLocalization.Name.EncryptionCheckButtonExplanation, "");
this.SetControlText<Button>("encryptLearnMore",
PlasticLocalization.Name.LearnMore);
this.SetControlText<Label>("gdLabel",
PlasticLocalization.Name.GettingDatacenters);
this.SetControlText<Button>("back",
PlasticLocalization.Name.BackButton);
this.SetControlText<Button>("create",
PlasticLocalization.Name.CreateButton);
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(CreateOrganizationPanel).Name);
this.LoadStyle("SignInSignUp");
this.LoadStyle(typeof(CreateOrganizationPanel).Name);
}
VisualElement mRootPanel;
TextField mOrganizationNameTextField;
Label mOrganizationNameNotification;
ToolbarMenu mDatacenter;
Button mBackButton;
Button mCreateButton;
Button mEncryptLearnMoreButton;
VisualElement mGettingDatacenters;
LoadingSpinner mLoadingSpinner;
string mSelectedDatacenter;
}
}
\ No newline at end of file
using UnityEngine.UIElements;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class CreatedOrganizationPanel : VisualElement
{
internal CreatedOrganizationPanel(string organizationName)
{
mOrganizationName = organizationName;
InitializeLayoutAndStyles();
BuildComponents();
}
void BuildComponents()
{
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.CloudBuho);
this.SetControlText<Label>("createdTitle",
PlasticLocalization.Name.CreatedOrganizationTitle);
this.SetControlText<Label>("createdExplanation",
PlasticLocalization.Name.CreatedOrganizationExplanation, mOrganizationName);
this.SetControlText<Button>("continue",
PlasticLocalization.Name.ContinueButton);
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(CreatedOrganizationPanel).Name);
this.LoadStyle("SignInSignUp");
this.LoadStyle(typeof(CreatedOrganizationPanel).Name);
}
string mOrganizationName;
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.Linq;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class OrganizationPanel : VisualElement
{
internal OrganizationPanel(List<string> organizations)
{
mOrganizations = organizations;
InitializeLayoutAndStyles();
BuildComponents();
}
void BuildComponents()
{
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.CloudBuho);
this.SetControlText<Label>("confirmationMessage",
PlasticLocalization.Name.SignedUpTitle);
if (mOrganizations.Count == 1)
BuildSingleOrganizationSection("Codice");
else if (mOrganizations.Count > 1)
BuildMultipleOrganizationsSection(mOrganizations);
BuildCreateOrganizationSection(!mOrganizations.Any());
}
void BuildSingleOrganizationSection(string organizationName)
{
mOrganizationToJoin = organizationName;
this.Query<VisualElement>("joinSingleOrganization").First().RemoveFromClassList("display-none");
this.SetControlText<Label>("joinSingleOrganizationLabel",
PlasticLocalization.Name.YouBelongToOrganization, organizationName);
this.SetControlText<Button>("joinSingleOrganizationButton",
PlasticLocalization.Name.JoinButton);
}
void BuildMultipleOrganizationsSection(List<string> organizationNames)
{
this.Query<VisualElement>("joinMultipleOrganizations").First().RemoveFromClassList("display-none");
this.SetControlText<Label>("joinMultipleOrganizationsLabel",
PlasticLocalization.Name.YouBelongToSeveralOrganizations);
VisualElement organizationDropdown = this.Query<VisualElement>("organizationDropdown").First();
ToolbarMenu toolbarMenu = new ToolbarMenu
{
text = organizationNames.FirstOrDefault()
};
foreach (string name in organizationNames)
{
toolbarMenu.menu.AppendAction(name, x =>
{
toolbarMenu.text = name;
mOrganizationToJoin = name;
}, DropdownMenuAction.AlwaysEnabled);
organizationDropdown.Add(toolbarMenu);
}
this.SetControlText<Button>("joinMultipleOrganizationsButton",
PlasticLocalization.Name.JoinButton);
}
void BuildCreateOrganizationSection(bool firstOrganization)
{
PlasticLocalization.Name createOrganizationLabelName = firstOrganization ?
PlasticLocalization.Name.CreateFirstOrganizationLabel :
PlasticLocalization.Name.CreateOtherOrganizationLabel;
this.SetControlText<Label>("createOrganizationLabel",
createOrganizationLabelName);
this.SetControlText<Button>("createOrganizationButton",
PlasticLocalization.Name.CreateButton);
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(OrganizationPanel).Name);
this.LoadStyle("SignInSignUp");
this.LoadStyle(typeof(OrganizationPanel).Name);
}
List<string> mOrganizations;
public string mOrganizationToJoin = "";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using PlasticGui;
using PlasticGui.WebApi;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class SSOSignUpPanel : VisualElement
{
internal SSOSignUpPanel(
CloudEditionWelcomeWindow parentWindow,
IPlasticWebRestApi restApi)
{
mParentWindow = parentWindow;
mRestApi = restApi;
InitializeLayoutAndStyles();
BuildComponents();
}
internal void Dispose()
{
mSignUpButton.clicked -= SignUpButton_Clicked;
mTermsOfServiceButton.clicked -= TermsOfServiceButton_Clicked;
mPrivacyPolicyButton.clicked -= PrivacyPolicyButton_Clicked;
mPrivacyPolicyStatementButton.clicked -= PrivacyPolicyStatementButton_Clicked;
mUserNameTextField.UnregisterValueChangedCallback(
OnUserNameTextFieldChanged);
mPasswordTextField.UnregisterValueChangedCallback(
OnPasswordTextFieldChanged);
mConfirmPasswordTextField.UnregisterValueChangedCallback(
OnPasswordTextFieldChanged);
}
void OnUserNameTextFieldChanged(ChangeEvent<string> evt)
{
if (!evt.newValue.Contains('@'))
{
mUserNotificationLabel.RemoveFromClassList("hidden");
mValidEmail = false;
}
else
{
mUserNotificationLabel.AddToClassList("hidden");
mValidEmail = true;
}
SetSignUpButtonEnablement();
}
void OnPasswordTextFieldChanged(ChangeEvent<string> evt)
{
if (mPasswordTextField.value != mConfirmPasswordTextField.value)
{
mPasswordNotificationLabel.RemoveFromClassList("hidden");
mMatchingPasswords = false;
}
else
{
mPasswordNotificationLabel.AddToClassList("hidden");
mMatchingPasswords = true;
}
SetSignUpButtonEnablement();
}
void SignUpButton_Clicked()
{
OrganizationPanel organizationPanel = new OrganizationPanel(
new List<string>() { "codice@codice", "skullcito@codice" });
//OrganizationPanel organizationPanel = new OrganizationPanel(new List<string>() { "codice@codice" });
//OrganizationPanel organizationPanel = new OrganizationPanel(new List<string>() { });
mParentWindow.mTabView.SwitchContent(organizationPanel);
}
void TermsOfServiceButton_Clicked()
{
Application.OpenURL("https://www.plasticscm.com/releases/eula/licenseagreement.pdf");
}
void PrivacyPolicyButton_Clicked()
{
Application.OpenURL("https://unity3d.com/legal/privacy-policy");
}
void PrivacyPolicyStatementButton_Clicked()
{
// TODO: update when dll is avaiable PlasticGui.Configuration.CloudEdition.Welcome
// SignUp.PRIVACY_POLICY_URL
Application.OpenURL("https://unity3d.com/legal/privacy-policy");
}
void SetSignUpButtonEnablement()
{
if (!mValidEmail || !mMatchingPasswords || String.IsNullOrEmpty(mPasswordTextField.value))
mSignUpButton.SetEnabled(false);
else
mSignUpButton.SetEnabled(true);
}
void BuildComponents()
{
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.GenericBuho);
this.SetControlText<Label>("signUpLabel",
PlasticLocalization.Name.SignUp);
mUserNameTextField = this.Q<TextField>("emailField");
mUserNameTextField.label = PlasticLocalization.GetString(
PlasticLocalization.Name.Email);
mUserNameTextField.RegisterValueChangedCallback(
OnUserNameTextFieldChanged);
mUserNotificationLabel = this.Q<Label>("emailNotification");
mUserNotificationLabel.text = PlasticLocalization.GetString(
PlasticLocalization.Name.EnterValidEmailAddress);
mPasswordTextField = this.Q<TextField>("passwordField");
mPasswordTextField.label = PlasticLocalization.GetString(
PlasticLocalization.Name.Password);
mPasswordTextField.RegisterValueChangedCallback(
OnPasswordTextFieldChanged);
mConfirmPasswordTextField = this.Q<TextField>("confirmPasswordField");
mConfirmPasswordTextField.label = PlasticLocalization.GetString(
PlasticLocalization.Name.ConfirmPassword);
mConfirmPasswordTextField.RegisterValueChangedCallback(
OnPasswordTextFieldChanged);
mPasswordNotificationLabel = this.Q<Label>("passwordNotificationLabel");
mPasswordNotificationLabel.text = PlasticLocalization.GetString(
PlasticLocalization.Name.PasswordDoesntMatch);
mSignUpButton = this.Q<Button>("signUp");
mSignUpButton.text = PlasticLocalization.GetString(PlasticLocalization.Name.SignUp);
mSignUpButton.clicked += SignUpButton_Clicked;
string[] signUpText = PlasticLocalization.GetString(
PlasticLocalization.Name.SignUpAgreeToShort).Split('{', '}');
Label signUpAgreePt1 = this.Q<Label>("signUpAgreePt1");
signUpAgreePt1.text = signUpText[0];
mTermsOfServiceButton = this.Q<Button>("termsOfService");
mTermsOfServiceButton.text = PlasticLocalization.GetString(PlasticLocalization.Name.TermsOfService);
mTermsOfServiceButton.clicked += TermsOfServiceButton_Clicked;
Label signUpAgreePt2 = this.Q<Label>("signUpAgreePt2");
signUpAgreePt2.text = signUpText[2];
mPrivacyPolicyButton = this.Q<Button>("privacyPolicy");
mPrivacyPolicyButton.text = PlasticLocalization.GetString(PlasticLocalization.Name.PrivacyPolicy);
mPrivacyPolicyButton.clicked += PrivacyPolicyButton_Clicked;
List<VisualElement> dashes = this.Query<VisualElement>("dash").ToList();
if (EditorGUIUtility.isProSkin)
dashes.ForEach(x => x.style.borderTopColor = new StyleColor(new UnityEngine.Color(0.769f, 0.769f, 0.769f)));
else
dashes.ForEach(x => x.style.borderTopColor = new StyleColor(new UnityEngine.Color(0.008f, 0.008f, 0.008f)));
this.SetControlText<Label>("or",
PlasticLocalization.Name.Or);
this.SetControlImage("unityIcon",
Images.Name.ButtonSsoSignInUnity);
Button unityIDButton = this.Q<Button>("unityIDButton");
unityIDButton.text = PlasticLocalization.GetString(PlasticLocalization.Name.SignUpUnityID);
this.SetControlImage("googleIcon",
Images.Name.ButtonSsoSignInGoogle);
Button googleButton = this.Q<Button>("googleButton");
googleButton.text = PlasticLocalization.GetString(PlasticLocalization.Name.SignUpGoogle);
this.SetControlText<Label>("privacyStatementText",
PlasticLocalization.Name.PrivacyStatementText,
PlasticLocalization.GetString(PlasticLocalization.Name.PrivacyStatement));
mPrivacyPolicyStatementButton = this.Query<Button>("privacyStatement").First();
mPrivacyPolicyStatementButton.text = PlasticLocalization.GetString(
PlasticLocalization.Name.PrivacyStatement);
mPrivacyPolicyStatementButton.clicked += PrivacyPolicyStatementButton_Clicked;
SetSignUpButtonEnablement();
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(SSOSignUpPanel).Name);
this.LoadStyle("SignInSignUp");
this.LoadStyle(typeof(SSOSignUpPanel).Name);
}
Button mTermsOfServiceButton;
Button mPrivacyPolicyButton;
Button mPrivacyPolicyStatementButton;
TextField mUserNameTextField;
TextField mPasswordTextField;
TextField mConfirmPasswordTextField;
Label mUserNotificationLabel;
Label mPasswordNotificationLabel;
Button mSignUpButton;
bool mValidEmail;
bool mMatchingPasswords;
readonly CloudEditionWelcomeWindow mParentWindow;
readonly IPlasticWebRestApi mRestApi;
}
}
using UnityEngine;
using UnityEngine.UIElements;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class SignInPanel : VisualElement
{
internal SignInPanel(
CloudEditionWelcomeWindow parentWindow)
{
mParentWindow = parentWindow;
InitializeLayoutAndStyles();
BuildComponents();
}
internal void Dispose()
{
mSignInWithUnityIdButton.clicked -= SignInWithUnityIdButton_Clicked;
mSignInWithEmailButton.clicked -= SignInWithEmailButton_Clicked;
mPrivacyPolicyStatementButton.clicked -= PrivacyPolicyStatementButton_Clicked;
if (mSignInWithEmailPanel != null)
mSignInWithEmailPanel.Dispose();
if (mWaitingSignInPanel != null)
mWaitingSignInPanel.Dispose();
}
void SignInWithEmailButton_Clicked()
{
mSignInWithEmailPanel = new SignInWithEmailPanel(mParentWindow);
mParentWindow.rootVisualElement.Clear();
mParentWindow.rootVisualElement.Add(mSignInWithEmailPanel);
}
void SignInWithUnityIdButton_Clicked()
{
mWaitingSignInPanel = new WaitingSignInPanel(mParentWindow);
mParentWindow.rootVisualElement.Clear();
mParentWindow.rootVisualElement.Add(mWaitingSignInPanel);
}
void PrivacyPolicyStatementButton_Clicked()
{
// TODO: update when dll is avaiable PlasticGui.Configuration.CloudEdition.Welcome
// SignUp.PRIVACY_POLICY_URL
Application.OpenURL("https://unity3d.com/legal/privacy-policy");
}
void BuildComponents()
{
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.CloudBuho);
this.SetControlText<Label>("signInToPlasticSCM",
PlasticLocalization.Name.SignInToPlasticSCM);
this.SetControlImage("iconUnity",
Images.Name.ButtonSsoSignInUnity);
mSignInWithUnityIdButton = this.Query<Button>("signInWithUnityId").First();
mSignInWithUnityIdButton.text = PlasticLocalization.GetString(
PlasticLocalization.Name.SignInWithUnityID);
mSignInWithUnityIdButton.clicked += SignInWithUnityIdButton_Clicked;
this.SetControlImage("iconEmail",
Images.Name.ButtonSsoSignInEmail);
mSignInWithEmailButton = this.Query<Button>("signInWithEmail").First();
mSignInWithEmailButton.clicked += SignInWithEmailButton_Clicked;
this.SetControlText<Label>("privacyStatementText",
PlasticLocalization.Name.PrivacyStatementText,
PlasticLocalization.GetString(PlasticLocalization.Name.PrivacyStatement));
mPrivacyPolicyStatementButton = this.Query<Button>("privacyStatement").First();
mPrivacyPolicyStatementButton.text = PlasticLocalization.GetString(
PlasticLocalization.Name.PrivacyStatement);
mPrivacyPolicyStatementButton.clicked += PrivacyPolicyStatementButton_Clicked;
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(SignInPanel).Name);
this.LoadStyle("SignInSignUp");
this.LoadStyle(typeof(SignInPanel).Name);
}
SignInWithEmailPanel mSignInWithEmailPanel;
WaitingSignInPanel mWaitingSignInPanel;
CloudEditionWelcomeWindow mParentWindow;
Button mSignInWithUnityIdButton;
Button mSignInWithEmailButton;
Button mPrivacyPolicyStatementButton;
}
}
\ No newline at end of file
using UnityEditor;
using UnityEngine.UIElements;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class SignInWithEmailPanel : VisualElement
{
internal SignInWithEmailPanel(CloudEditionWelcomeWindow parentWindow)
{
mParentWindow = parentWindow;
InitializeLayoutAndStyles();
BuildComponents();
}
internal void Dispose()
{
mSignInButton.clicked -= SignInButton_Clicked;
mBackButton.clicked -= BackButton_Clicked;
}
void SignInButton_Clicked()
{
// TODO: Replace this with validation and sign in logic
string message = string.Format("Signing in as '{0}' with password '{1}'",
mEmailField.text,
mPasswordField.text);
EditorUtility.DisplayDialog("Test", message, "Ok");
}
void BackButton_Clicked()
{
mParentWindow.BuildComponents();
}
void BuildComponents()
{
mEmailField = this.Query<TextField>("email").First();
mPasswordField = this.Query<TextField>("password").First();
mEmailNotificationLabel = this.Query<Label>("emailNotification").First();
mPasswordNotificationLabel = this.Query<Label>("passwordNotification").First();
mSignInButton = this.Query<Button>("signIn").First();
mBackButton = this.Query<Button>("back").First();
mSignInButton.clicked += SignInButton_Clicked;
mBackButton.clicked += BackButton_Clicked;
mEmailField.FocusOnceLoaded();
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.CloudBuho);
this.SetControlText<Label>("signInLabel",
PlasticLocalization.Name.SignInWithEmail);
this.SetControlLabel<TextField>("email",
PlasticLocalization.Name.Email);
this.SetControlLabel<TextField>("password",
PlasticLocalization.Name.Password);
this.SetControlText<Button>("signIn",
PlasticLocalization.Name.SignInButton);
this.SetControlText<Button>("back",
PlasticLocalization.Name.BackButton);
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(SignInWithEmailPanel).Name);
this.LoadStyle(typeof(SignInWithEmailPanel).Name);
}
TextField mEmailField;
TextField mPasswordField;
Label mEmailNotificationLabel;
Label mPasswordNotificationLabel;
Button mSignInButton;
Button mBackButton;
CloudEditionWelcomeWindow mParentWindow;
}
}
\ No newline at end of file
using UnityEngine.UIElements;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI.UIElements;
namespace Unity.PlasticSCM.Editor.Configuration.CloudEdition.Welcome
{
internal class WaitingSignInPanel : VisualElement
{
internal WaitingSignInPanel(CloudEditionWelcomeWindow parentWindow)
{
mParentWindow = parentWindow;
InitializeLayoutAndStyles();
BuildComponents();
}
internal void Dispose()
{
mCancelButton.clicked -= CancelButton_Clicked;
}
void CancelButton_Clicked()
{
mParentWindow.BuildComponents();
}
void BuildComponents()
{
this.SetControlImage("buho",
PlasticGui.Help.HelpImage.GenericBuho);
this.SetControlText<Label>("signInToPlasticSCM",
PlasticLocalization.Name.SignInToPlasticSCM);
this.SetControlText<Label>("completeSignInOnBrowser",
PlasticLocalization.Name.CompleteSignInOnBrowser);
this.SetControlText<Label>("oAuthSignInCheckMessage",
PlasticLocalization.Name.OAuthSignInCheckMessage);
mCancelButton = this.Query<Button>("cancelButton").First();
mCancelButton.text = PlasticLocalization.GetString(
PlasticLocalization.Name.CancelButton);
mCancelButton.clicked += CancelButton_Clicked;
}
void InitializeLayoutAndStyles()
{
this.LoadLayout(typeof(WaitingSignInPanel).Name);
this.LoadStyle("SignInSignUp");
this.LoadStyle(typeof(WaitingSignInPanel).Name);
}
Button mCancelButton;
readonly CloudEditionWelcomeWindow mParentWindow;
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.IO;
using Codice.Client.Commands.Mount;
using Codice.Client.Commands.WkTree;
using Codice.Client.Common;
using Codice.Client.Common.GameUI;
using Codice.CM.Common;
using Codice.CM.WorkspaceServer.DataStore.Configuration;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal static class ConfigurePartialWorkspace
{
internal static void AsFullyChecked(WorkspaceInfo wkInfo)
{
string rootPath = WorkspacePath.GetWorkspacePathFromCmPath(
wkInfo.ClientPath, "/", Path.DirectorySeparatorChar);
WorkspaceTreeNode rootWkNode = CmConnection.Get().GetWorkspaceTreeHandler().
WkGetWorkspaceTreeNode(rootPath);
FullyCheckedDirectory rootDirectory = new FullyCheckedDirectory();
rootDirectory.MountId = MountPointId.WORKSPACE_ROOT;
rootDirectory.ItemId = rootWkNode.RevInfo.ItemId;
List<FullyCheckedDirectory> directoryList = new List<FullyCheckedDirectory>();
directoryList.Add(rootDirectory);
FullyCheckedDirectoriesStorage.Save(wkInfo, directoryList);
}
}
}
using UnityEngine;
using UnityEditor;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Progress;
using Codice.CM.Common;
using Codice.Client.Common.Connection;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal class CredentialsDialog : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
return new Rect(baseRect.x, baseRect.y, 525, 250);
}
}
internal static AskCredentialsToUser.DialogData RequestCredentials(
string server,
EditorWindow parentWindow)
{
CredentialsDialog dialog = Create(
server, new ProgressControlsForDialogs());
ResponseType dialogResult = dialog.RunModal(parentWindow);
return dialog.BuildCredentialsDialogData(dialogResult);
}
protected override void OnModalGUI()
{
Title(PlasticLocalization.GetString(
PlasticLocalization.Name.CredentialsDialogTitle));
Paragraph(PlasticLocalization.GetString(
PlasticLocalization.Name.CredentialsDialogExplanation, mServer));
GUILayout.Space(5);
DoEntriesArea();
GUILayout.Space(10);
DrawProgressForDialogs.For(
mProgressControls.ProgressData);
GUILayout.Space(10);
DoButtonsArea();
}
protected override string GetTitle()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.CredentialsDialogTitle);
}
AskCredentialsToUser.DialogData BuildCredentialsDialogData(
ResponseType dialogResult)
{
return new AskCredentialsToUser.DialogData(
dialogResult == ResponseType.Ok,
mUser, mPassword, mSaveProfile, SEIDWorkingMode.LDAPWorkingMode);
}
void DoEntriesArea()
{
mUser = TextEntry(PlasticLocalization.GetString(
PlasticLocalization.Name.UserName), mUser,
ENTRY_WIDTH, ENTRY_X);
GUILayout.Space(5);
mPassword = PasswordEntry(PlasticLocalization.GetString(
PlasticLocalization.Name.Password), mPassword,
ENTRY_WIDTH, ENTRY_X);
GUILayout.Space(5);
mSaveProfile = ToggleEntry(PlasticLocalization.GetString(
PlasticLocalization.Name.RememberCredentialsAsProfile),
mSaveProfile, ENTRY_WIDTH, ENTRY_X);
}
void DoButtonsArea()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (Application.platform == RuntimePlatform.WindowsEditor)
{
DoOkButton();
DoCancelButton();
return;
}
DoCancelButton();
DoOkButton();
}
}
void DoOkButton()
{
if (!AcceptButton(PlasticLocalization.GetString(
PlasticLocalization.Name.OkButton)))
return;
OkButtonWithValidationAction();
}
void DoCancelButton()
{
if (!NormalButton(PlasticLocalization.GetString(
PlasticLocalization.Name.CancelButton)))
return;
CancelButtonAction();
}
void OkButtonWithValidationAction()
{
CredentialsDialogValidation.AsyncValidation(
BuildCredentialsDialogData(ResponseType.Ok), this, mProgressControls);
}
static CredentialsDialog Create(
string server,
ProgressControlsForDialogs progressControls)
{
var instance = CreateInstance<CredentialsDialog>();
instance.mServer = server;
instance.mProgressControls = progressControls;
instance.mEnterKeyAction = instance.OkButtonWithValidationAction;
instance.mEscapeKeyAction = instance.CancelButtonAction;
return instance;
}
string mUser;
string mPassword = string.Empty;
ProgressControlsForDialogs mProgressControls;
bool mSaveProfile;
string mServer;
const float ENTRY_WIDTH = 345f;
const float ENTRY_X = 150f;
}
}
using UnityEditor;
using Codice.Client.Common;
using Codice.Client.Common.Connection;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal class CredentialsUiImpl : AskCredentialsToUser.IGui
{
internal CredentialsUiImpl(EditorWindow parentWindow)
{
mParentWindow = parentWindow;
}
AskCredentialsToUser.DialogData AskCredentialsToUser.IGui.AskUserForCredentials(string servername)
{
AskCredentialsToUser.DialogData result = null;
GUIActionRunner.RunGUIAction(delegate
{
result = CredentialsDialog.RequestCredentials(
servername, mParentWindow);
});
return result;
}
void AskCredentialsToUser.IGui.ShowSaveProfileErrorMessage(string message)
{
GUIActionRunner.RunGUIAction(delegate
{
GuiMessage.ShowError(string.Format(
PlasticLocalization.GetString(
PlasticLocalization.Name.CredentialsErrorSavingProfile),
message));
});
}
AskCredentialsToUser.DialogData AskCredentialsToUser.IGui.AskUserForSSOCredentials(string cloudServer)
{
AskCredentialsToUser.DialogData result = null;
GUIActionRunner.RunGUIAction(delegate
{
result = CredentialsDialog.RequestCredentials(
cloudServer, mParentWindow);
});
return result;
}
EditorWindow mParentWindow;
}
}
using UnityEditor;
using UnityEngine;
using Codice.Utils;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal class EncryptionConfigurationDialog : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
return new Rect(baseRect.x, baseRect.y, 650, 425);
}
}
internal static EncryptionConfigurationDialogData RequestEncryptionPassword(
string server,
EditorWindow parentWindow)
{
EncryptionConfigurationDialog dialog = Create(server);
ResponseType dialogResult = dialog.RunModal(parentWindow);
EncryptionConfigurationDialogData result =
dialog.BuildEncryptionConfigurationData();
result.Result = dialogResult == ResponseType.Ok;
return result;
}
protected override void OnModalGUI()
{
Title(PlasticLocalization.GetString(
PlasticLocalization.Name.EncryptionConfiguration));
GUILayout.Space(20);
Paragraph(PlasticLocalization.GetString(
PlasticLocalization.Name.EncryptionConfigurationExplanation, mServer));
DoPasswordArea();
Paragraph(PlasticLocalization.GetString(
PlasticLocalization.Name.EncryptionConfigurationRemarks, mServer));
GUILayout.Space(10);
DoNotificationArea();
GUILayout.Space(10);
DoButtonsArea();
}
protected override string GetTitle()
{
return PlasticLocalization.GetString(
PlasticLocalization.Name.EncryptionConfiguration);
}
EncryptionConfigurationDialogData BuildEncryptionConfigurationData()
{
return new EncryptionConfigurationDialogData(
CryptoServices.GetEncryptedPassword(mPassword.Trim()));
}
void DoPasswordArea()
{
Paragraph(PlasticLocalization.GetString(
PlasticLocalization.Name.EncryptionConfigurationEnterPassword));
GUILayout.Space(5);
mPassword = PasswordEntry(PlasticLocalization.GetString(
PlasticLocalization.Name.Password), mPassword,
PASSWORD_TEXT_WIDTH, PASSWORD_TEXT_X);
GUILayout.Space(5);
mRetypePassword = PasswordEntry(PlasticLocalization.GetString(
PlasticLocalization.Name.RetypePassword), mRetypePassword,
PASSWORD_TEXT_WIDTH, PASSWORD_TEXT_X);
GUILayout.Space(18f);
}
void DoNotificationArea()
{
if (string.IsNullOrEmpty(mErrorMessage))
return;
var rect = GUILayoutUtility.GetRect(
GUILayoutUtility.GetLastRect().width, 30);
EditorGUI.HelpBox(rect, mErrorMessage, MessageType.Error);
}
void DoButtonsArea()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (Application.platform == RuntimePlatform.WindowsEditor)
{
DoOkButton();
DoCancelButton();
return;
}
DoCancelButton();
DoOkButton();
}
}
void DoOkButton()
{
if (!AcceptButton(PlasticLocalization.GetString(
PlasticLocalization.Name.OkButton)))
return;
OkButtonWithValidationAction();
}
void DoCancelButton()
{
if (!NormalButton(PlasticLocalization.GetString(
PlasticLocalization.Name.CancelButton)))
return;
CancelButtonAction();
}
void OkButtonWithValidationAction()
{
if (IsValidPassword(
mPassword.Trim(), mRetypePassword.Trim(),
out mErrorMessage))
{
mErrorMessage = string.Empty;
OkButtonAction();
return;
}
mPassword = string.Empty;
mRetypePassword = string.Empty;
}
static bool IsValidPassword(
string password, string retypePassword,
out string errorMessage)
{
errorMessage = string.Empty;
if (string.IsNullOrEmpty(password))
{
errorMessage = PlasticLocalization.GetString(
PlasticLocalization.Name.InvalidEmptyPassword);
return false;
}
if (!password.Equals(retypePassword))
{
errorMessage = PlasticLocalization.GetString(
PlasticLocalization.Name.PasswordDoesntMatch);
return false;
}
return true;
}
static EncryptionConfigurationDialog Create(string server)
{
var instance = CreateInstance<EncryptionConfigurationDialog>();
instance.mServer = server;
instance.mEnterKeyAction = instance.OkButtonWithValidationAction;
instance.mEscapeKeyAction = instance.CancelButtonAction;
return instance;
}
string mPassword = string.Empty;
string mRetypePassword = string.Empty;
string mErrorMessage = string.Empty;
string mServer = string.Empty;
const float PASSWORD_TEXT_WIDTH = 250f;
const float PASSWORD_TEXT_X = 200f;
}
}
using UnityEditor;
using Codice.Client.Common.Encryption;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal class MissingEncryptionPasswordPromptHandler :
ClientEncryptionServiceProvider.IEncryptioPasswordProvider
{
internal MissingEncryptionPasswordPromptHandler(EditorWindow parentWindow)
{
mParentWindow = parentWindow;
}
string ClientEncryptionServiceProvider.IEncryptioPasswordProvider
.GetEncryptionEncryptedPassword(string server)
{
string result = null;
GUIActionRunner.RunGUIAction(delegate
{
result = AskForEncryptionPassword(server);
});
return result;
}
string AskForEncryptionPassword(string server)
{
EncryptionConfigurationDialogData dialogData =
EncryptionConfigurationDialog.RequestEncryptionPassword(server, mParentWindow);
if (!dialogData.Result)
return null;
return dialogData.EncryptedPassword;
}
EditorWindow mParentWindow;
}
}
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;
namespace Unity.PlasticSCM.Editor.Configuration.TeamEdition
{
internal class TeamEditionConfigurationWindow : EditorWindow
{
internal static void ShowWindow(IPlasticWebRestApi restApi)
{
TeamEditionConfigurationWindow window = GetWindow<TeamEditionConfigurationWindow>();
window.mRestApi = restApi;
window.titleContent = new GUIContent(
PlasticLocalization.GetString(PlasticLocalization.Name.WelcomeToPlasticSCM));
window.minSize = 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: (bIsPasswordRequired, seidWorkingMode) =>
{
UpdatePasswordEntries(bIsPasswordRequired);
},
NotifyWorkingMode: (mode) => { mSEIDWorkingMode = mode; },
NotifyConnectedStatus: (b) => { });
mUserTextField.SetEnabled(true);
}
void OnDestroy()
{
Dispose();
}
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.AddToClassList("visibility-hidden");
}
void BuildComponents()
{
VisualElement root = rootVisualElement;
root.Query<Label>("plasticConfigurationTitle").First().text =
PlasticLocalization.GetString(PlasticLocalization.Name.PlasticConfigurationTitle);
root.SetControlText<Label>(
"plasticConfigurationExplanation",
PlasticLocalization.Name.PlasticConfigurationExplanation);
root.SetControlText<Label>("configurationServerInfo",
PlasticLocalization.Name.PlasticSCMServerLabel);
root.SetControlText<Button>(
"connect",
PlasticLocalization.Name.Connect);
root.SetControlText<Label>("useSsl",
PlasticLocalization.Name.UseSsl);
root.SetControlText<Label>("configurationUserNameInfo",
PlasticLocalization.Name.ConfigurationUserNameInfo);
root.SetControlText<Label>("configurationCredentialsInfo",
PlasticLocalization.Name.ConfigurationCredentialsInfo);
root.SetControlText<Button>("check",
PlasticLocalization.Name.Check);
root.SetControlText<Label>("credentialsOk",
PlasticLocalization.Name.CredentialsOK);
root.SetControlText<Button>("okButton",
PlasticLocalization.Name.OkButton);
root.SetControlText<Button>("cancelButton",
PlasticLocalization.Name.CancelButton);
mSpinnerContainer = root.Query<VisualElement>("spinnerContainer").First();
mSpinnerLabel = root.Query<Label>("spinnerLabel").First();
mLoadingSpinner = new LoadingSpinner();
mSpinnerContainer.Add(mLoadingSpinner);
mSpinnerContainer.AddToClassList("visibility-hidden");
mCheckConnectionButton = root.Query<Button>("check").First();
mCheckConnectionButton.clicked += CheckConnectionButton_Clicked;
mConnectButton = root.Query<Button>("connect").First();
mConnectButton.clicked += ConnectButton_Clicked;
mServerTextField = root.Query<TextField>("serverTextField").First();
mServerTextField.RegisterValueChangedCallback(OnServerTextFieldChanged);
mUseSslToggle = root.Query<Toggle>("useSslToogle").First();
mUseSslToggle.RegisterValueChangedCallback(OnUseSslToggleChanged);
mUserTextField = root.Query<TextField>("userTextField").First();
mUserTextField.value = Environment.UserName;
mUserTextField.SetEnabled(false);
mPasswordTextField = root.Query<TextField>("passwordTextField").First();
mPasswordTextField.isPasswordField = true;
mConnectedLabel = root.Query<Label>("connectedLabel").First();
mCredentialsLabel = root.Query<Label>("credentialsOk").First();
mOkButton = root.Query<Button>("okButton").First();
mOkButton.clicked += OkButton_Clicked;
mCancelButton = root.Query<Button>("cancelButton").First();
mCancelButton.clicked += CancelButton_Clicked;
}
void OnUseSslToggleChanged(ChangeEvent<bool> evt)
{
mUserAssistant.OnSslChanged(mServerTextField.value, evt.newValue);
mServerTextField.value = mUserAssistant.GetProposedServer();
}
void InitializeLayoutAndStyles()
{
VisualElement root = rootVisualElement;
root.LoadLayout(typeof(TeamEditionConfigurationWindow).Name);
root.LoadStyle(typeof(TeamEditionConfigurationWindow).Name);
}
void OnServerTextFieldChanged(ChangeEvent<string> evt)
{
mUserAssistant.OnServerChanged(evt.newValue);
mUseSslToggle.value = mUserAssistant.IsSslServer(evt.newValue);
}
void ShowServerNotificationMessage(string message)
{
mConnectedLabel.text = message;
mConnectedLabel.RemoveFromClassList("visibility-hidden");
}
void ShowServerValidationError(string message)
{
mConnectedLabel.text = message;
mConnectedLabel.AddToClassList("error");
mConnectedLabel.RemoveFromClassList("visibility-hidden");
}
void ShowCredentialsNotificationMessage(string message)
{
mCredentialsLabel.text = message;
mCredentialsLabel.RemoveFromClassList("visibility-hidden");
}
void ShowCheckCredentialsError(string message)
{
mCredentialsLabel.text = message;
mCredentialsLabel.AddToClassList("error");
mCredentialsLabel.RemoveFromClassList("visibility-hidden");
}
void HideValidation()
{
mConnectedLabel.RemoveFromClassList("error");
mConnectedLabel.AddToClassList("visibility-hidden");
}
void ShowProgress(string text)
{
mSpinnerLabel.text = text;
mSpinnerContainer.RemoveFromClassList("visibility-hidden");
mSpinnerLabel.RemoveFromClassList("visibility-hidden");
mLoadingSpinner.Start();
}
void HideProgress()
{
mLoadingSpinner.Stop();
mSpinnerContainer.AddToClassList("visibility-hidden");
mSpinnerLabel.AddToClassList("visibility-hidden");
}
void UpdatePasswordEntries(bool bIsPasswordRequired)
{
if (!bIsPasswordRequired)
{
mPasswordTextField.AddToClassList("display-none");
mUserTextField.SetEnabled(false);
mUserTextField.value = Environment.UserName;
return;
}
mUserTextField.SetEnabled(true);
mPasswordTextField.RemoveFromClassList("display-none");
mUserTextField.SelectAll();
mUserTextField.FocusWorkaround();
}
Button mConnectButton;
Label mConnectedLabel;
TextField mServerTextField;
TextField mPasswordTextField;
Toggle mUseSslToggle;
LoadingSpinner mLoadingSpinner;
Label mSpinnerLabel;
VisualElement mSpinnerContainer;
Button mCheckConnectionButton;
Label mCredentialsLabel;
Button mOkButton;
Button mCancelButton;
SEIDWorkingMode mSEIDWorkingMode = SEIDWorkingMode.UPWorkingMode;
ConfigurationDialogUserAssistant mUserAssistant =
new ConfigurationDialogUserAssistant();
IPlasticWebRestApi mRestApi;
TextField mUserTextField;
}
}
\ No newline at end of file
using System.IO;
using Codice.Utils;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal static class ToolConfig
{
internal static string GetUnityPlasticLogConfigFile()
{
return GetConfigFilePath(LOG_CONFIG_FILE);
}
static string GetConfigFilePath(string configfile)
{
string file = Path.Combine(ApplicationLocation.GetAppPath(), configfile);
if (File.Exists(file))
return file;
return UserConfigFolder.GetConfigFile(configfile);
}
const string LOG_CONFIG_FILE = "unityplastic.log.conf";
}
}
using System.IO;
namespace Unity.PlasticSCM.Editor.Configuration
{
internal class WriteLogConfiguration
{
internal static void For(string logConfigPath)
{
string logDirectoryPath = GetPlasticLogDirectoryPath(logConfigPath);
string relevantLogFile = Path.Combine(logDirectoryPath, RELEVANT_LOG_FILE_NAME);
string debugLogFile = Path.Combine(logDirectoryPath, DEBUG_LOG_FILE_NAME);
using (StreamWriter sw = File.CreateText(logConfigPath))
{
sw.Write(string.Format(
LOG_CONFIGURATION,
relevantLogFile,
debugLogFile));
}
}
static string GetPlasticLogDirectoryPath(string logConfigPath)
{
return Path.Combine(
Directory.GetParent(logConfigPath).FullName,
LOGS_DIRECTORY);
}
const string LOGS_DIRECTORY = "logs";
const string RELEVANT_LOG_FILE_NAME = "unityplastic.relevant.log.txt";
const string DEBUG_LOG_FILE_NAME = "unityplastic.debug.log.txt";
const string LOG_CONFIGURATION =
@"<log4net>
<appender name=""RelevantInfoAppender"" type=""log4net.Appender.RollingFileAppender"">
<file value=""{0}"" />
<appendToFile value=""true"" />
<rollingStyle value=""Size"" />
<maxSizeRollBackups value=""10"" />
<maximumFileSize value=""2MB"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%date %username %-5level %logger - %message%newline"" />
</layout>
<filter type=""log4net.Filter.LevelRangeFilter""><levelMin value=""INFO"" /><levelMax value=""FATAL"" /></filter>
</appender>
<appender name=""DebugAppender"" type=""log4net.Appender.RollingFileAppender"">
<file value=""{1}"" />
<appendToFile value=""true"" />
<rollingStyle value=""Size"" />
<maxSizeRollBackups value=""10"" />
<maximumFileSize value=""10MB"" />
<staticLogFileName value=""true"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%date %username %-5level %logger - %message%newline"" />
</layout>
</appender>
<root>
<level value=""DEBUG"" />
<appender-ref ref=""RelevantInfoAppender"" />
<appender-ref ref=""DebugAppender"" />
</root>
</log4net>
";
}
}
using System;
using Codice.Client.BaseCommands;
using Codice.Client.BaseCommands.CheckIn.Progress;
using Codice.Client.Commands.CheckIn;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
namespace Unity.PlasticSCM.Editor.Developer
{
internal class CheckinProgress
{
internal bool CancelPressed;
internal CheckinProgress(WorkspaceInfo wkInfo, PlasticGUIClient guiClient)
{
mWkInfo = wkInfo;
mGuiClient = guiClient;
mGuiClient.Progress.CanCancelProgress = true;
mProgressRender = new CheckinUploadProgressRender(
PlasticLocalization.GetString(
PlasticLocalization.Name.CheckinProgressMultiThreadUploading),
PlasticLocalization.GetString(
PlasticLocalization.Name.CheckinProgressMultiThreadNumOfBlocks),
PlasticLocalization.GetString(PlasticLocalization.Name.CheckinProgressUploadingFiles),
PlasticLocalization.GetString(
PlasticLocalization.Name.CheckinProgressUploadingFileData),
PlasticLocalization.GetString(PlasticLocalization.Name.CheckinProgressOf),
PlasticLocalization.GetString(
PlasticLocalization.Name.RemainingProgressMessage));
}
internal void Refresh(
CheckinStatus checkinStatus,
BuildProgressSpeedAndRemainingTime.ProgressData progressData)
{
if (checkinStatus == null)
return;
var progress = mGuiClient.Progress;
progress.ProgressHeader = checkinStatus.StatusString;
if (checkinStatus.Status >= EnumCheckinStatus.eciConfirming)
progress.CanCancelProgress = false;
if (checkinStatus.Status == EnumCheckinStatus.eciCancelling)
return;
int nowTicks = Environment.TickCount;
progress.TotalProgressMessage = mProgressRender.GetUploadSize(
checkinStatus.TransferredSize, checkinStatus.TotalSize, progressData);
progress.TotalProgressPercent = GetProgressBarPercent.ForTransfer(
checkinStatus.TransferredSize, checkinStatus.TotalSize) / 100f;
progress.ShowCurrentBlock = mProgressRender.
NeedShowCurrentBlockForCheckinStatus(checkinStatus, nowTicks);
string currentFileInfo = mProgressRender.GetCurrentFileInfo(
checkinStatus.CurrentCheckinBlock, mWkInfo.ClientPath);
progress.ProgressHeader = currentFileInfo;
float fileProgressBarValue = GetProgressBarPercent.ForTransfer(
checkinStatus.CurrentCheckinBlock.UploadedSize,
checkinStatus.CurrentCheckinBlock.BlockSize) / 100f;
progress.CurrentBlockProgressPercent = fileProgressBarValue;
progress.CurrentBlockProgressMessage = mProgressRender.GetCurrentBlockUploadSize(
checkinStatus.CurrentCheckinBlock, nowTicks);
}
CheckinUploadProgressRender mProgressRender;
PlasticGUIClient mGuiClient;
WorkspaceInfo mWkInfo;
}
}
using PlasticGui.WorkspaceWindow;
namespace Unity.PlasticSCM.Editor.Developer
{
internal class GenericProgress
{
internal GenericProgress(PlasticGUIClient guiClient)
{
mGuiClient = guiClient;
mGuiClient.Progress.CanCancelProgress = false;
}
internal void RefreshProgress(ProgressData progressData)
{
var progress = mGuiClient.Progress;
progress.ProgressHeader = progressData.Status;
progress.TotalProgressMessage = progressData.Details;
progress.TotalProgressPercent = progressData.ProgressValue / 100f;
}
PlasticGUIClient mGuiClient;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment