This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,432 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEditor;
using UnityEditor.VersionControl;
using Codice.Client.Common.Threading;
using Codice.CM.Common;
using Codice.LogWrapper;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using Unity.PlasticSCM.Editor.AssetMenu;
using Unity.PlasticSCM.Editor.AssetsOverlays;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.AssetUtils.Processor;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Tool;
using GluonIncomingChangesUpdater = PlasticGui.Gluon.WorkspaceWindow.IncomingChangesUpdater;
namespace Unity.PlasticSCM.Editor.Inspector
{
static class DrawInspectorOperations
{
internal static void Enable(
WorkspaceInfo wkInfo,
IPlasticAPI plasticApi,
IAssetStatusCache assetStatusCache)
{
if (mIsEnabled)
return;
mLog.Debug("Enable");
mWkInfo = wkInfo;
mPlasticAPI = plasticApi;
mAssetStatusCache = assetStatusCache;
mIsEnabled = true;
mAssetSelection = new InspectorAssetSelection();
UnityEditor.Editor.finishedDefaultHeaderGUI +=
Editor_finishedDefaultHeaderGUI;
RepaintEditor.InspectorWindow();
}
internal static void Disable()
{
mLog.Debug("Disable");
mIsEnabled = false;
UnityEditor.Editor.finishedDefaultHeaderGUI -=
Editor_finishedDefaultHeaderGUI;
RepaintEditor.InspectorWindow();
mWkInfo = null;
mAssetStatusCache = null;
mAssetSelection = null;
mOperations = null;
}
internal static void BuildOperations(
WorkspaceInfo wkInfo,
IPlasticAPI plasticApi,
GluonGui.ViewHost viewHost,
WorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
PlasticGui.Gluon.IGluonViewSwitcher gluonViewSwitcher,
IMergeViewLauncher mergeViewLauncher,
IHistoryViewLauncher historyViewLauncher,
IAssetStatusCache assetStatusCache,
ISaveAssets saveAssets,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
WorkspaceOperationsMonitor workspaceOperationsMonitor,
PendingChangesUpdater pendingChangesUpdater,
IncomingChangesUpdater developerIncomingChangesUpdater,
GluonIncomingChangesUpdater gluonIncomingChangesUpdater,
ShelvedChangesUpdater shelvedChangesUpdater,
bool isGluonMode)
{
if (!mIsEnabled)
Enable(wkInfo, plasticApi, assetStatusCache);
mOperations = new AssetUVCSOperations(
wkInfo,
plasticApi,
viewHost,
workspaceWindow,
viewSwitcher,
gluonViewSwitcher,
mergeViewLauncher,
historyViewLauncher,
assetStatusCache,
mAssetSelection,
saveAssets,
showDownloadPlasticExeWindow,
workspaceOperationsMonitor,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
shelvedChangesUpdater,
isGluonMode);
}
static void Editor_finishedDefaultHeaderGUI(UnityEditor.Editor inspector)
{
try
{
if (!mIsEnabled)
return;
mAssetSelection.SetActiveInspector(inspector);
AssetList assetList = ((AssetUVCSOperations.IAssetSelection)
mAssetSelection).GetSelectedAssets();
if (assetList.Count == 0)
return;
SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
BuildFromAssetList(mWkInfo, assetList, mPlasticAPI, mAssetStatusCache);
if (assetList.Count != selectedGroupInfo.SelectedCount)
return;
AssetsOverlays.AssetStatus assetStatus;
LockStatusData lockStatusData;
GetAssetStatusToDraw(
assetList[0].path, assetList.Count,
mAssetStatusCache,
out assetStatus,
out lockStatusData);
AssetMenuOperations assetOperations = AssetMenuUpdater.
GetAvailableMenuOperations(selectedGroupInfo);
DrawAssetStatusHeader(assetStatus, lockStatusData, assetOperations);
}
catch (Exception ex)
{
ExceptionsHandler.LogException(typeof(DrawInspectorOperations).Name, ex);
}
}
static void DrawAssetStatusHeader(
AssetsOverlays.AssetStatus assetStatus,
LockStatusData lockStatusData,
AssetMenuOperations assetOperations)
{
bool guiEnabledBck = GUI.enabled;
GUI.enabled = true;
try
{
DrawBackRectangle(guiEnabledBck);
GUILayout.BeginHorizontal();
DrawStatusLabel(assetStatus, lockStatusData);
DrawButtons(assetOperations);
GUILayout.EndHorizontal();
}
finally
{
GUI.enabled = guiEnabledBck;
}
}
static void DrawBackRectangle(bool isEnabled)
{
// when the inspector is disabled, there is a separator line
// that breaks the visual style. Draw an empty rectangle
// matching the background color to cover it
GUILayout.Space(UnityConstants.INSPECTOR_ACTIONS_BACK_RECTANGLE_TOP_MARGIN);
GUIStyle targetStyle = (isEnabled) ?
UnityStyles.Inspector.HeaderBackgroundUnderlineStyle :
UnityStyles.Inspector.DisabledHeaderBackgroundUnderlineStyle;
Rect rect = GUILayoutUtility.GetRect(
GUIContent.none, targetStyle);
// extra space to cover the inspector full width
rect.x -= 20;
rect.width += 80;
GUI.Box(rect, GUIContent.none, targetStyle);
// now reset the space used by the rectangle
GUILayout.Space(
-UnityConstants.INSPECTOR_ACTIONS_HEADER_BACK_RECTANGLE_HEIGHT
- UnityConstants.INSPECTOR_ACTIONS_BACK_RECTANGLE_TOP_MARGIN);
}
static void DrawButtons(AssetMenuOperations assetOperations)
{
var operationsAvailability = new Dictionary<AssetMenuOperations, bool>
{
{ AssetMenuOperations.Add, assetOperations.HasFlag(AssetMenuOperations.Add) },
{ AssetMenuOperations.Checkout, assetOperations.HasFlag(AssetMenuOperations.Checkout) },
{ AssetMenuOperations.Checkin, assetOperations.HasFlag(AssetMenuOperations.Checkin) },
{ AssetMenuOperations.Undo, assetOperations.HasFlag(AssetMenuOperations.Undo) }
};
// GUILayout reserves space for controls, which might lead to unexpected layout behavior
// when controls are hidden dynamically. We keep consistency by adding flex spaces for inactive operations.
foreach (var unused in operationsAvailability.Values.Where(activeOperation => !activeOperation))
{
GUILayout.FlexibleSpace();
}
if (operationsAvailability[AssetMenuOperations.Add])
{
DoAddButton();
}
if (operationsAvailability[AssetMenuOperations.Checkout])
{
DoCheckoutButton();
}
if (operationsAvailability[AssetMenuOperations.Checkin])
{
DoCheckinButton();
}
if (operationsAvailability[AssetMenuOperations.Undo])
{
DoUndoButton();
}
DoDiffAndHistoryButtons(assetOperations);
}
static void DrawStatusLabel(
AssetsOverlays.AssetStatus assetStatus,
LockStatusData lockStatusData)
{
string statusText = AssetOverlay.GetStatusString(assetStatus);
string tooltipText = AssetOverlay.GetTooltipText(assetStatus, lockStatusData);
Texture statusIcon = DrawAssetOverlayIcon.GetOverlayIcon(assetStatus);
Rect selectionRect = GUILayoutUtility.GetRect(
new GUIContent(statusText + EXTRA_SPACE, statusIcon),
GUIStyle.none);
selectionRect.height = UnityConstants.OVERLAY_STATUS_ICON_SIZE;
if (statusIcon == null)
{
int labelMarginWithoutIcon = 5;
selectionRect.x += labelMarginWithoutIcon;
GUI.Label(
selectionRect,
new GUIContent(statusText, tooltipText));
return;
}
Rect statusIconRect = new Rect(
selectionRect.x + 3f,
selectionRect.y - 1f,
UnityConstants.INSPECTOR_STATUS_ICON_SIZE,
UnityConstants.INSPECTOR_STATUS_ICON_SIZE);
GUI.DrawTexture(
statusIconRect,
statusIcon,
ScaleMode.ScaleToFit);
int margin = 2;
selectionRect.x += UnityConstants.INSPECTOR_STATUS_ICON_SIZE + margin;
selectionRect.width -= UnityConstants.INSPECTOR_STATUS_ICON_SIZE;
GUI.Label(
selectionRect,
new GUIContent(statusText, tooltipText));
}
static void DoAddButton()
{
string buttonText = PlasticLocalization.GetString(PlasticLocalization.Name.AddButton);
if (GUILayout.Button(string.Format("{0}", buttonText), EditorStyles.miniButton))
{
if (mOperations == null)
ShowWindow.UVCS();
mOperations.Add();
}
}
static void DoCheckoutButton()
{
string buttonText = PlasticLocalization.GetString(PlasticLocalization.Name.CheckoutButton);
if (GUILayout.Button(string.Format("{0}", buttonText), EditorStyles.miniButton))
{
if (mOperations == null)
ShowWindow.UVCS();
mOperations.Checkout();
}
}
static void DoCheckinButton()
{
string buttonText = PlasticLocalization.GetString(PlasticLocalization.Name.CheckinButton);
if (GUILayout.Button(string.Format("{0}", buttonText), EditorStyles.miniButton))
{
if (mOperations == null)
ShowWindow.UVCS();
mOperations.Checkin();
EditorGUIUtility.ExitGUI();
}
}
static void DoUndoButton()
{
string buttonText = PlasticLocalization.GetString(PlasticLocalization.Name.UndoButton);
if (GUILayout.Button(string.Format("{0}", buttonText), EditorStyles.miniButton))
{
if (mOperations == null)
ShowWindow.UVCS();
mOperations.Undo();
EditorGUIUtility.ExitGUI();
}
}
static void DoDiffAndHistoryButtons(AssetMenuOperations assetOperations)
{
if (!assetOperations.HasFlag(AssetMenuOperations.Diff) &&
!assetOperations.HasFlag(AssetMenuOperations.History))
return;
var content = new GUIContent(
Images.GetOptionsIcon(),
PlasticLocalization.Name.More.GetString());
if (GUILayout.Button(content, UnityStyles.Inspector.PaneOptions))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(
new GUIContent(PlasticLocalization.Name.DiffPlasticMenu.GetString()),
false,
() =>
{
if (mOperations == null)
ShowWindow.UVCS();
mOperations.ShowDiff();
});
menu.AddItem(
new GUIContent(PlasticLocalization.Name.DiffMetaPlasticMenu.GetString()),
false,
() =>
{
if (mOperations == null)
ShowWindow.UVCS();
mOperations.ShowMetaDiff();
});
menu.AddSeparator(string.Empty);
menu.AddItem(
new GUIContent(PlasticLocalization.Name.HistoryPlasticMenu.GetString()),
false,
() =>
{
ShowWindow.UVCS();
mOperations.ShowHistory();
});
menu.AddItem(
new GUIContent(PlasticLocalization.Name.HistoryMetaPlasticMenu.GetString()),
false,
() =>
{
ShowWindow.UVCS();
mOperations.ShowMetaHistory();
});
menu.ShowAsContext();
}
}
static void GetAssetStatusToDraw(
string selectedPath,
int selectedCount,
IAssetStatusCache statusCache,
out AssetsOverlays.AssetStatus assetStatus,
out LockStatusData lockStatusData)
{
assetStatus = AssetsOverlays.AssetStatus.None;
lockStatusData = null;
if (selectedCount > 1)
return;
string selectedFullPath = AssetsPath.GetFullPath.ForPath(selectedPath);
assetStatus = statusCache.GetStatus(selectedFullPath);
lockStatusData = statusCache.GetLockStatusData(selectedFullPath);
}
static IAssetMenuUVCSOperations mOperations;
static InspectorAssetSelection mAssetSelection;
static bool mIsEnabled;
static IAssetStatusCache mAssetStatusCache;
static IPlasticAPI mPlasticAPI;
static WorkspaceInfo mWkInfo;
const string EXTRA_SPACE = " ";
static readonly ILog mLog = PlasticApp.GetLogger("DrawInspectorOperations");
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 28ce2dedf734c7c4e8ad114c00173d65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
using UnityEditor.VersionControl;
using Unity.PlasticSCM.Editor.AssetMenu;
using Unity.PlasticSCM.Editor.AssetUtils;
namespace Unity.PlasticSCM.Editor.Inspector
{
internal class InspectorAssetSelection : AssetUVCSOperations.IAssetSelection
{
AssetList AssetUVCSOperations.IAssetSelection.GetSelectedAssets()
{
return GetInspectorAssets(mActiveInspector);
}
internal void SetActiveInspector(UnityEditor.Editor inspector)
{
mActiveInspector = inspector;
}
static AssetList GetInspectorAssets(UnityEditor.Editor inspector)
{
AssetList result = new AssetList();
if (inspector == null)
return result;
foreach (UnityEngine.Object obj in inspector.targets)
{
string assetPath = AssetsPath.GetFullPath.ForObject(obj);
if (string.IsNullOrEmpty(assetPath))
continue;
result.Add(new Asset(assetPath));
}
return result;
}
UnityEditor.Editor mActiveInspector;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9bef80072d106be4ea36de88adc0e985
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f48aeec177c14cf185016d8add57e69f
timeCreated: 1770025915
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 06657c386ba945c2a6e83c5e1d0f04d4
timeCreated: 1770026043
@@ -0,0 +1,220 @@
using System;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.Diff;
using Unity.PlasticSCM.Editor.Views.Properties;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties.Branch
{
internal class BranchPropertiesPanel
{
internal bool IsChangesetByChangesetModeForTesting
{
get { return mToolbarIndex == 1; }
set { mToolbarIndex = value ? 1 : 0; }
}
internal DiffPanel DiffPanel => mDiffPanel;
internal BranchPropertiesPanel(
Action repaint,
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IHistoryViewLauncher historyViewLauncher,
IRefreshView refreshView,
IAssetStatusCache assetStatusCache,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
IPendingChangesUpdater pendingChangesUpdater,
IIncomingChangesUpdater developerIncomingChangesUpdater,
IIncomingChangesUpdater gluonIncomingChangesUpdater,
EditorWindow parentWindow,
bool isGluonMode)
{
mRepaint = repaint;
mToolbarIndex = SessionState.GetInt(TOOLBAR_INDEX_KEY, defaultValue: 0);
mPropertiesPanel = new PropertiesPanel(repaint, workspaceWindow, parentWindow);
mDiffPanel = new DiffPanel(
repaint,
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
refreshView,
assetStatusCache,
showDownloadPlasticExeWindow,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
parentWindow,
isGluonMode);
mChangesetByChangesetDiffPanel = new ChangesetByChangesetDiffPanel(
repaint,
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
refreshView,
assetStatusCache,
showDownloadPlasticExeWindow,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
parentWindow,
isGluonMode);
}
internal void OnEnable()
{
mDiffPanel.OnEnable();
mChangesetByChangesetDiffPanel.OnEnable();
}
internal void OnDisable()
{
mDiffPanel.OnDisable();
mChangesetByChangesetDiffPanel.OnDisable();
}
internal void Update()
{
mDiffPanel.Update();
mPropertiesPanel.Update();
mChangesetByChangesetDiffPanel.Update();
}
internal void ResetForTesting()
{
ClearInfo();
mToolbarIndex = 0;
}
internal void ClearInfo()
{
mSelectedRepObjectInfoData = null;
mPropertiesPanel.ClearInfo();
mDiffPanel.ClearInfo();
mChangesetByChangesetDiffPanel.ClearInfo();
}
internal void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
mSelectedRepObjectInfoData = selectedRepObjectInfoData;
BranchInfo selectedBranchInfo = (BranchInfo)selectedRepObjectInfoData.ObjectInfo;
if (mToolbarIndex == 1)
{
mChangesetByChangesetDiffPanel.UpdateInfo(selectedRepObjectInfoData.MountPoint, selectedBranchInfo);
}
else
{
mPropertiesPanel.UpdateInfo(selectedBranchInfo, selectedRepObjectInfoData.RepSpec);
mDiffPanel.UpdateInfo(selectedRepObjectInfoData.MountPoint, selectedBranchInfo);
}
}
internal void OnInspectorGUI()
{
if (mToolbarIndex == 1)
mChangesetByChangesetDiffPanel.OnGUI();
else
{
mDiffPanel.OnGUI();
}
}
internal void OnHeaderGUI()
{
EditorGUILayout.BeginVertical();
DoDiffModeButtons();
DrawSeparator();
if (mToolbarIndex == 1)
{
EditorGUILayout.EndVertical();
return;
}
mPropertiesPanel.OnGUI();
DrawSeparator();
EditorGUILayout.EndVertical();
}
void DoDiffModeButtons()
{
EditorGUILayout.BeginVertical();
EditorGUILayout.Space(0.5f);
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
//GUI.enabled = !mProgressControls.IsOperationRunning();
int previousToolbarIndex = mToolbarIndex;
string[] options = new string[]
{
PlasticLocalization.Name.DiffEntireBranch.GetString(),
PlasticLocalization.Name.DiffByChangeset.GetString()
};
mToolbarIndex = GUILayout.Toolbar(
mToolbarIndex,
options,
UnityStyles.LargeButton,
GUI.ToolbarButtonSize.FitToContents);
GUILayout.FlexibleSpace();
//GUI.enabled = true;
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space(0.5f);
EditorGUILayout.EndVertical();
// If mode changed, update the panel with the currently selected branch
if (previousToolbarIndex != mToolbarIndex)
{
SessionState.SetInt(TOOLBAR_INDEX_KEY, mToolbarIndex);
SetSelectedObject(mSelectedRepObjectInfoData);
}
}
static void DrawSeparator()
{
Rect bottomSeparatorRect = GUILayoutUtility.GetRect(
0,
1,
GUILayout.ExpandWidth(true));
EditorGUI.DrawRect(bottomSeparatorRect, UnityStyles.Colors.BarBorder);
}
int mToolbarIndex;
DiffPanel mDiffPanel;
PropertiesPanel mPropertiesPanel;
ChangesetByChangesetDiffPanel mChangesetByChangesetDiffPanel;
SelectedRepObjectInfoData mSelectedRepObjectInfoData;
readonly Action mRepaint;
const string TOOLBAR_INDEX_KEY = "BranchPropertiesPanel.ToolbarIndex";
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 14b7fa9fffe443888cccb93957dea182
timeCreated: 1770026998
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 95584824e8c94fafab24cbd922124aff
timeCreated: 1770026047
@@ -0,0 +1,114 @@
using System;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using Unity.PlasticSCM.Editor.AssetsOverlays.Cache;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.Diff;
using Unity.PlasticSCM.Editor.Views.Properties;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties.Changeset
{
internal class ChangesetPropertiesPanel
{
internal DiffPanel DiffPanel => mDiffPanel;
internal ChangesetPropertiesPanel(
Action repaint,
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IHistoryViewLauncher historyViewLauncher,
IRefreshView refreshView,
IAssetStatusCache assetStatusCache,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
IPendingChangesUpdater pendingChangesUpdater,
IIncomingChangesUpdater developerIncomingChangesUpdater,
IIncomingChangesUpdater gluonIncomingChangesUpdater,
EditorWindow parentWindow,
bool isGluonMode)
{
mRepaint = repaint;
mRepaint = repaint;
mPropertiesPanel = new PropertiesPanel(repaint, workspaceWindow, parentWindow);
mDiffPanel = new DiffPanel(
repaint,
wkInfo,
workspaceWindow,
viewSwitcher,
historyViewLauncher,
refreshView,
assetStatusCache,
showDownloadPlasticExeWindow,
pendingChangesUpdater,
developerIncomingChangesUpdater,
gluonIncomingChangesUpdater,
parentWindow,
isGluonMode);
}
internal void Update()
{
mDiffPanel.Update();
mPropertiesPanel.Update();
}
internal void OnEnable()
{
mDiffPanel.OnEnable();
}
internal void OnDisable()
{
mDiffPanel.OnDisable();
}
internal void ResetForTesting()
{
ClearInfo();
}
internal void ClearInfo()
{
mPropertiesPanel.ClearInfo();
mDiffPanel.ClearInfo();
}
internal void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
mPropertiesPanel.UpdateInfo(selectedRepObjectInfoData.ObjectInfo, selectedRepObjectInfoData.RepSpec);
mDiffPanel.UpdateInfo(selectedRepObjectInfoData.MountPoint, selectedRepObjectInfoData.ObjectInfo);
}
internal void OnInspectorGUI()
{
mDiffPanel.OnGUI();
}
internal void OnHeaderGUI()
{
EditorGUILayout.BeginVertical();
mPropertiesPanel.OnGUI();
Rect separatorRect = GUILayoutUtility.GetRect(
0,
1,
GUILayout.ExpandWidth(true));
EditorGUI.DrawRect(separatorRect, UnityStyles.Colors.BarBorder);
EditorGUILayout.EndVertical();
}
DiffPanel mDiffPanel;
PropertiesPanel mPropertiesPanel;
readonly Action mRepaint;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 87e7b84ff9884881b9aceb446cee6ee5
timeCreated: 1770027014
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f6e1f4a705074105b682329d9d1fe334
timeCreated: 1770026056
@@ -0,0 +1,105 @@
using System;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.BrowseRepository;
using Unity.PlasticSCM.Editor.Views.Properties;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties.Label
{
internal class LabelPropertiesPanel : IGetRepositorySpec
{
internal LabelPropertiesPanel(
Action repaint,
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
EditorWindow parentWindow)
{
mRepaint = repaint;
mRepaint = repaint;
mParentWindow = parentWindow;
mPropertiesPanel = new PropertiesPanel(repaint, workspaceWindow, parentWindow);
mBrowseRepositoryPanel = new BrowseRepositoryPanel(
wkInfo,
this,
parentWindow);
}
internal void OnEnable()
{
mBrowseRepositoryPanel.OnEnable();
}
internal void OnDisable()
{
mBrowseRepositoryPanel.OnDisable();
}
internal void Update()
{
mBrowseRepositoryPanel.Update();
mPropertiesPanel.Update();
}
internal void ResetForTesting()
{
ClearInfo();
}
internal void ClearInfo()
{
mSelectedRepObjectInfoData = null;
mPropertiesPanel.ClearInfo();
mBrowseRepositoryPanel.ClearInfo();
}
internal void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
mSelectedRepObjectInfoData = selectedRepObjectInfoData;
mPropertiesPanel.UpdateInfo(selectedRepObjectInfoData.ObjectInfo, selectedRepObjectInfoData.RepSpec);
mBrowseRepositoryPanel.UpdateInfo((MarkerExtendedInfo)selectedRepObjectInfoData.ObjectInfo);
}
internal void OnInspectorGUI()
{
mBrowseRepositoryPanel.OnGUI();
}
internal void OnHeaderGUI()
{
EditorGUILayout.BeginVertical();
mPropertiesPanel.OnGUI();
Rect separatorRect = GUILayoutUtility.GetRect(
0,
1,
GUILayout.ExpandWidth(true));
EditorGUI.DrawRect(separatorRect, UnityStyles.Colors.BarBorder);
EditorGUILayout.EndVertical();
}
RepositorySpec IGetRepositorySpec.Get()
{
if (mSelectedRepObjectInfoData == null)
return null;
return mSelectedRepObjectInfoData.RepSpec;
}
PropertiesPanel mPropertiesPanel;
BrowseRepositoryPanel mBrowseRepositoryPanel;
SelectedRepObjectInfoData mSelectedRepObjectInfoData;
readonly Action mRepaint;
readonly EditorWindow mParentWindow;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9a10c8be3cfa470199e57ef38283bcfd
timeCreated: 1770027025
@@ -0,0 +1,351 @@
using Codice.CM.Common;
using Unity.PlasticSCM.Editor.Diff;
using Unity.PlasticSCM.Editor.Headless;
using Unity.PlasticSCM.Editor.Inspector.Properties.Branch;
using Unity.PlasticSCM.Editor.Inspector.Properties.Changeset;
using Unity.PlasticSCM.Editor.Inspector.Properties.Label;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using EditorWindowInternal = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.EditorWindow;
namespace Unity.PlasticSCM.Editor.Inspector.Properties
{
[CustomEditor(typeof(SelectedRepObjectInfoData))]
internal class PropertiesViewer : UnityEditor.Editor
{
internal BranchPropertiesPanel BranchPropertiesPanel => mBranchPropertiesPanel;
internal ChangesetPropertiesPanel ChangesetPropertiesPanel => mChangesetPropertiesPanel;
public override bool UseDefaultMargins()
{
return false;
}
public override VisualElement CreateInspectorGUI()
{
if (target == null)
return null;
if (mSelectedRepObjectInfoData == target)
return mRootContainer;
mRootContainer = new VisualElement();
IMGUIContainer imguiContainer = new IMGUIContainer(DrawInspectorGUI);
imguiContainer.style.flexGrow = 1;
mRootContainer.Add(imguiContainer);
mRootContainer.RegisterCallback<AttachToPanelEvent>(OnAttatchToPanel);
mRootContainer.RegisterCallback<DetachFromPanelEvent>(OnDetachFromPanel);
SetSelectedObject(target as SelectedRepObjectInfoData);
return mRootContainer;
}
internal void DisposeForTesting()
{
EditorApplication.update -= OnEditorUpdate;
if (mBranchPropertiesPanel != null)
mBranchPropertiesPanel.ResetForTesting();
if (mChangesetPropertiesPanel != null)
mChangesetPropertiesPanel.ResetForTesting();
if (mLabelPropertiesPanel != null)
mLabelPropertiesPanel.ResetForTesting();
DestroyImmediate(this);
}
void OnAttatchToPanel(AttachToPanelEvent evt)
{
ScrollView parentScrollView = mRootContainer.GetFirstAncestorOfType<ScrollView>();
if (parentScrollView == null)
return;
UpdateRootContainerHeight(parentScrollView.contentRect.height);
parentScrollView.RegisterCallback<GeometryChangedEvent>(OnScrollGeometryChanged);
}
void OnDetachFromPanel(DetachFromPanelEvent evt)
{
EditorApplication.delayCall += ClearDiffWindowIfNoLivePropertiesViewer;
}
void OnScrollGeometryChanged(GeometryChangedEvent evt)
{
UpdateRootContainerHeight(evt.newRect.height);
}
void UpdateRootContainerHeight(float parentScrollViewHeight)
{
// 7px is the magic number that makes our view to fit
// the Inspector's scrollviewer viewport size
// we need it to avoid the vertical scrollbar to appear
mRootContainer.style.height = parentScrollViewHeight - 7;
}
void OnEnable()
{
if (mBranchPropertiesPanel != null)
mBranchPropertiesPanel.OnEnable();
if (mChangesetPropertiesPanel != null)
mChangesetPropertiesPanel.OnEnable();
if (mLabelPropertiesPanel != null)
mLabelPropertiesPanel.OnEnable();
EditorApplication.update += OnEditorUpdate;
}
void OnDestroy()
{
if (mRootContainer == null)
return;
mRootContainer.UnregisterCallback<AttachToPanelEvent>(OnAttatchToPanel);
ScrollView parentScrollView = mRootContainer.GetFirstAncestorOfType<ScrollView>();
parentScrollView?.UnregisterCallback<GeometryChangedEvent>(OnScrollGeometryChanged);
if (target != null && !IsTargetUsedByOtherPropertiesViewer())
DestroyImmediate(target);
GetOrCreateBranchPropertiesPanel().ClearInfo();
GetOrCreateLabelPropertiesPanel().ClearInfo();
GetOrCreateChangesetPropertiesPanel().ClearInfo();
ClearDiffWindow();
}
void OnDisable()
{
if (mBranchPropertiesPanel != null)
mBranchPropertiesPanel.OnDisable();
if (mChangesetPropertiesPanel != null)
mChangesetPropertiesPanel.OnDisable();
if (mLabelPropertiesPanel != null)
mLabelPropertiesPanel.OnDisable();
EditorApplication.update -= OnEditorUpdate;
}
void SetSelectedObject(SelectedRepObjectInfoData selectedRepObjectInfoData)
{
ClearDiffWindowCache();
mSelectedRepObjectInfoData = selectedRepObjectInfoData;
object objectInfo = selectedRepObjectInfoData?.ObjectInfo;
mLastObjectInfo = objectInfo;
if (objectInfo == null)
return;
if (objectInfo is BranchInfo)
{
GetOrCreateBranchPropertiesPanel().SetSelectedObject(selectedRepObjectInfoData);
GetOrCreateLabelPropertiesPanel().ClearInfo();
GetOrCreateChangesetPropertiesPanel().ClearInfo();
}
else if (objectInfo is MarkerInfo)
{
GetOrCreateLabelPropertiesPanel().SetSelectedObject(selectedRepObjectInfoData);
GetOrCreateBranchPropertiesPanel().ClearInfo();
GetOrCreateChangesetPropertiesPanel().ClearInfo();
}
else if (objectInfo is ChangesetInfo)
{
GetOrCreateChangesetPropertiesPanel().SetSelectedObject(selectedRepObjectInfoData);
GetOrCreateBranchPropertiesPanel().ClearInfo();
GetOrCreateLabelPropertiesPanel().ClearInfo();
}
}
void DrawInspectorGUI()
{
if (mLastObjectInfo == null)
return;
if (mLastObjectInfo is BranchInfo)
{
GetOrCreateBranchPropertiesPanel().OnHeaderGUI();
GetOrCreateBranchPropertiesPanel().OnInspectorGUI();
}
else if (mLastObjectInfo is MarkerInfo)
{
GetOrCreateLabelPropertiesPanel().OnHeaderGUI();
GetOrCreateLabelPropertiesPanel().OnInspectorGUI();
}
else if (mLastObjectInfo is ChangesetInfo)
{
GetOrCreateChangesetPropertiesPanel().OnHeaderGUI();
GetOrCreateChangesetPropertiesPanel().OnInspectorGUI();
}
}
void OnEditorUpdate()
{
if (mLastObjectInfo == null)
return;
if (mLastObjectInfo is BranchInfo)
GetOrCreateBranchPropertiesPanel().Update();
else if (mLastObjectInfo is MarkerInfo)
GetOrCreateLabelPropertiesPanel().Update();
else if (mLastObjectInfo is ChangesetInfo)
GetOrCreateChangesetPropertiesPanel().Update();
}
BranchPropertiesPanel GetOrCreateBranchPropertiesPanel()
{
if (mBranchPropertiesPanel == null)
{
EditorWindow inspectorWindow = EditorWindowInternal.GetInspectorWindow();
mBranchPropertiesPanel = new BranchPropertiesPanel(
Repaint,
GetWorkspaceInfo(),
new HeadlessWorkspaceWindow(() => { }, info => { }),
new HeadlessViewSwitcher(),
new HeadlessHistoryViewLauncher(UVCSPlugin.Instance),
new HeadlessRefreshView(),
UVCSPlugin.Instance.AssetStatusCache,
mShowDownloadPlasticExeWindow,
UVCSPlugin.Instance.PendingChangesUpdater,
UVCSPlugin.Instance.DeveloperIncomingChangesUpdater,
UVCSPlugin.Instance.GluonIncomingChangesUpdater,
inspectorWindow,
PlasticGui.Plastic.API.IsGluonWorkspace(mWkInfo));
}
return mBranchPropertiesPanel;
}
LabelPropertiesPanel GetOrCreateLabelPropertiesPanel()
{
if (mLabelPropertiesPanel == null)
{
EditorWindow inspectorWindow = EditorWindowInternal.GetInspectorWindow();
mLabelPropertiesPanel = new LabelPropertiesPanel(
Repaint,
GetWorkspaceInfo(),
new HeadlessWorkspaceWindow(() => { }, info => { }),
inspectorWindow);
}
return mLabelPropertiesPanel;
}
ChangesetPropertiesPanel GetOrCreateChangesetPropertiesPanel()
{
if (mChangesetPropertiesPanel == null)
{
EditorWindow inspectorWindow = EditorWindowInternal.GetInspectorWindow();
mChangesetPropertiesPanel = new ChangesetPropertiesPanel(
Repaint,
GetWorkspaceInfo(),
new HeadlessWorkspaceWindow(() => { }, info => { }),
new HeadlessViewSwitcher(),
new HeadlessHistoryViewLauncher(UVCSPlugin.Instance),
new HeadlessRefreshView(),
UVCSPlugin.Instance.AssetStatusCache,
mShowDownloadPlasticExeWindow,
UVCSPlugin.Instance.PendingChangesUpdater,
UVCSPlugin.Instance.DeveloperIncomingChangesUpdater,
UVCSPlugin.Instance.GluonIncomingChangesUpdater,
inspectorWindow,
PlasticGui.Plastic.API.IsGluonWorkspace(mWkInfo));
}
return mChangesetPropertiesPanel;
}
WorkspaceInfo GetWorkspaceInfo()
{
if (mWkInfo == null)
{
mWkInfo = FindWorkspace.InfoForApplicationPath(
ApplicationDataPath.Get(), PlasticGui.Plastic.API);
}
return mWkInfo;
}
bool IsTargetUsedByOtherPropertiesViewer()
{
// check if the current target is displayed in other inspector
PropertiesViewer[] allViewers =
Resources.FindObjectsOfTypeAll<PropertiesViewer>();
foreach (PropertiesViewer viewer in allViewers)
{
if (viewer == this)
continue;
if (viewer.target == target)
return true;
}
return false;
}
static void ClearDiffWindowCache()
{
IUnityDiffWindow diffWindow = GetWindowIfOpened.Diff();
diffWindow?.ClearDiffViewerCache();
}
static void ClearDiffWindow()
{
IUnityDiffWindow diffWindow = GetWindowIfOpened.Diff();
if (diffWindow == null)
return;
diffWindow.ClearDiffViewerCache();
diffWindow.ClearIfShownFrom(DiffSource.DiffPanel);
}
static void ClearDiffWindowIfNoLivePropertiesViewer()
{
PropertiesViewer[] allViewers =
Resources.FindObjectsOfTypeAll<PropertiesViewer>();
foreach (PropertiesViewer viewer in allViewers)
{
if (viewer.mRootContainer != null && viewer.mRootContainer.panel != null)
return;
}
ClearDiffWindow();
}
protected override void OnHeaderGUI() { }
public override void OnInspectorGUI() { }
VisualElement mRootContainer;
object mLastObjectInfo;
WorkspaceInfo mWkInfo;
SelectedRepObjectInfoData mSelectedRepObjectInfoData;
BranchPropertiesPanel mBranchPropertiesPanel;
LabelPropertiesPanel mLabelPropertiesPanel;
ChangesetPropertiesPanel mChangesetPropertiesPanel;
LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow =
new LaunchTool.ShowDownloadPlasticExeWindow();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89c8459035a34dab8b0141d4c4e3e3db
timeCreated: 1770026066
@@ -0,0 +1,56 @@
using System;
using Codice.CM.Common;
using Codice.CM.Common.Mount;
using UnityEditor;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Inspector.Properties
{
internal class SelectedRepObjectInfoData : ScriptableObject
{
internal RepObjectInfo ObjectInfo { get; private set; }
internal RepositorySpec RepSpec { get; private set; }
internal MountPointWithPath MountPoint { get; private set; }
internal static SelectedRepObjectInfoData Create(
RepObjectInfo objectInfo,
RepositorySpec repSpec,
MountPointWithPath mountPoint = null)
{
SelectedRepObjectInfoData result = CreateInstance<SelectedRepObjectInfoData>();
result.ObjectInfo = objectInfo;
result.RepSpec = repSpec;
result.MountPoint = mountPoint;
return result;
}
internal static void SetActiveObject(
RepObjectInfo objectInfo,
RepositorySpec repSpec,
MountPointWithPath mountPoint = null)
{
// Reassigning Selection.activeObject to a new instance makes Unity rebuild
// the Inspector and recompute the diff, losing the current file selection.
// Skip it when the same object is already displayed (VCS-1008599).
if (IsSameObjectSelected(objectInfo, repSpec))
return;
Selection.activeObject = Create(objectInfo, repSpec, mountPoint);
}
static bool IsSameObjectSelected(
RepObjectInfo objectInfo,
RepositorySpec repSpec)
{
SelectedRepObjectInfoData current =
Selection.activeObject as SelectedRepObjectInfoData;
if (current == null || current.ObjectInfo == null || objectInfo == null)
return false;
return current.ObjectInfo.Equals(objectInfo)
&& current.RepSpec.Equals(repSpec);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b6b94b53391e4873a684f61c6f109710
timeCreated: 1770025975