first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using GluonGui.WorkspaceWindow.Views.Checkin.Operations;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class CheckinProgress
|
||||
{
|
||||
internal CheckinProgress(WorkspaceWindow workspaceWindow)
|
||||
{
|
||||
mWorkspaceWindow = workspaceWindow;
|
||||
}
|
||||
|
||||
internal void Refresh(CheckinProgressData progress)
|
||||
{
|
||||
mWorkspaceWindow.Progress.ProgressHeader = progress.ProgressText;
|
||||
|
||||
mWorkspaceWindow.Progress.TotalProgressMessage = progress.TotalProgressText;
|
||||
mWorkspaceWindow.Progress.TotalProgressPercent = ((double)progress.TotalProgressValue) / 100;
|
||||
|
||||
mWorkspaceWindow.Progress.ShowCurrentBlock = progress.bShowCurrentBlock;
|
||||
mWorkspaceWindow.Progress.CurrentBlockProgressMessage = progress.CurrentBlockText;
|
||||
mWorkspaceWindow.Progress.CurrentBlockProgressPercent = ((double)progress.CurrentBlockProgressValue) / 100;
|
||||
}
|
||||
|
||||
WorkspaceWindow mWorkspaceWindow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 201d30422af8ea34193a59b4254b8663
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4edf5537f8245134c8b023ab85d8e640
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using Codice.CM.Common;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.Errors
|
||||
{
|
||||
internal class ErrorListViewItem : TreeViewItem
|
||||
{
|
||||
internal ErrorMessage ErrorMessage { get; private set; }
|
||||
|
||||
internal ErrorListViewItem(int id, ErrorMessage errorMessage)
|
||||
: base(id, 0)
|
||||
{
|
||||
ErrorMessage = errorMessage;
|
||||
|
||||
displayName = errorMessage.Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71c34e5fa319ca644b6806e573c33d88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.Errors
|
||||
{
|
||||
internal enum ErrorsListColumn
|
||||
{
|
||||
Path,
|
||||
Reason
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class ErrorsListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
|
||||
{
|
||||
internal static ErrorsListHeaderState GetDefault()
|
||||
{
|
||||
return new ErrorsListHeaderState(BuildColumns());
|
||||
}
|
||||
|
||||
static string GetColumnName(ErrorsListColumn column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case ErrorsListColumn.Path:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.PathColumn);
|
||||
case ErrorsListColumn.Reason:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.Reason);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (mHeaderTitles != null)
|
||||
TreeHeaderColumns.SetTitles(columns, mHeaderTitles);
|
||||
|
||||
if (mColumnsAllowedToggleVisibility != null)
|
||||
TreeHeaderColumns.SetVisibilities(columns, mColumnsAllowedToggleVisibility);
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
static Column[] BuildColumns()
|
||||
{
|
||||
return new Column[]
|
||||
{
|
||||
new Column()
|
||||
{
|
||||
width = 300,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ErrorsListColumn.Path)),
|
||||
minWidth = 200,
|
||||
allowToggleVisibility = false,
|
||||
canSort = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = 600,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ErrorsListColumn.Reason)),
|
||||
minWidth = 200,
|
||||
canSort = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ErrorsListHeaderState(Column[] columns)
|
||||
: base(columns)
|
||||
{
|
||||
if (mHeaderTitles == null)
|
||||
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
|
||||
|
||||
if (mColumnsAllowedToggleVisibility == null)
|
||||
mColumnsAllowedToggleVisibility = TreeHeaderColumns.GetVisibilities(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
|
||||
[SerializeField]
|
||||
bool[] mColumnsAllowedToggleVisibility;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c069d7fb0d30cf499458f0d9c9fe035
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,179 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.Errors
|
||||
{
|
||||
internal class ErrorsListView : TreeView
|
||||
{
|
||||
internal ErrorsListView(ErrorsListHeaderState headerState)
|
||||
: base(new TreeViewState())
|
||||
{
|
||||
multiColumnHeader = new MultiColumnHeader(headerState);
|
||||
multiColumnHeader.canSort = false;
|
||||
|
||||
rowHeight = UnityConstants.TREEVIEW_ROW_HEIGHT;
|
||||
showAlternatingRowBackgrounds = true;
|
||||
}
|
||||
|
||||
public override IList<TreeViewItem> GetRows()
|
||||
{
|
||||
return mRows;
|
||||
}
|
||||
|
||||
protected override TreeViewItem BuildRoot()
|
||||
{
|
||||
return new TreeViewItem(0, -1, string.Empty);
|
||||
}
|
||||
|
||||
protected override IList<TreeViewItem> BuildRows(TreeViewItem rootItem)
|
||||
{
|
||||
RegenerateRows(
|
||||
this, mErrorMessages, rootItem, mRows);
|
||||
|
||||
return mRows;
|
||||
}
|
||||
|
||||
protected override void BeforeRowsGUI()
|
||||
{
|
||||
int firstRowVisible;
|
||||
int lastRowVisible;
|
||||
GetFirstAndLastVisibleRows(out firstRowVisible, out lastRowVisible);
|
||||
|
||||
GUI.DrawTexture(new Rect(0,
|
||||
firstRowVisible * rowHeight,
|
||||
GetRowRect(0).width,
|
||||
(lastRowVisible * rowHeight) + 1000),
|
||||
Images.GetTreeviewBackgroundTexture());
|
||||
|
||||
DrawTreeViewItem.InitializeStyles();
|
||||
base.BeforeRowsGUI();
|
||||
}
|
||||
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
if (args.item is ErrorListViewItem)
|
||||
{
|
||||
ErrorListViewItemGUI((ErrorListViewItem)args.item, args);
|
||||
return;
|
||||
}
|
||||
|
||||
base.RowGUI(args);
|
||||
}
|
||||
|
||||
internal void BuildModel(List<ErrorMessage> errorMessages)
|
||||
{
|
||||
mErrorMessages = errorMessages;
|
||||
}
|
||||
|
||||
internal ErrorMessage GetSelectedError()
|
||||
{
|
||||
List<ErrorMessage> selectedErrors = GetSelectedErrors(this);
|
||||
|
||||
if (selectedErrors.Count != 1)
|
||||
return null;
|
||||
|
||||
return selectedErrors[0];
|
||||
}
|
||||
|
||||
static List<ErrorMessage> GetSelectedErrors(
|
||||
ErrorsListView listView)
|
||||
{
|
||||
List<ErrorMessage> result = new List<ErrorMessage>();
|
||||
|
||||
IList<int> selectedIds = listView.GetSelection();
|
||||
|
||||
if (selectedIds.Count == 0)
|
||||
return result;
|
||||
|
||||
foreach (ErrorListViewItem treeViewItem in
|
||||
listView.FindRows(selectedIds))
|
||||
{
|
||||
result.Add(treeViewItem.ErrorMessage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void RegenerateRows(
|
||||
ErrorsListView listView,
|
||||
List<ErrorMessage> errorMessages,
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
ClearRows(rootItem, rows);
|
||||
|
||||
if (errorMessages.Count == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < errorMessages.Count; i++)
|
||||
{
|
||||
ErrorListViewItem errorListViewItem =
|
||||
new ErrorListViewItem(i + 1, errorMessages[i]);
|
||||
|
||||
rootItem.AddChild(errorListViewItem);
|
||||
rows.Add(errorListViewItem);
|
||||
}
|
||||
|
||||
listView.SetSelection(new List<int> { 1 });
|
||||
}
|
||||
|
||||
static void ClearRows(
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
if (rootItem.hasChildren)
|
||||
rootItem.children.Clear();
|
||||
|
||||
rows.Clear();
|
||||
}
|
||||
|
||||
static void ErrorListViewItemGUI(
|
||||
ErrorListViewItem item,
|
||||
RowGUIArgs args)
|
||||
{
|
||||
for (int visibleColumnIdx = 0; visibleColumnIdx < args.GetNumVisibleColumns(); visibleColumnIdx++)
|
||||
{
|
||||
Rect cellRect = args.GetCellRect(visibleColumnIdx);
|
||||
|
||||
ErrorsListColumn column =
|
||||
(ErrorsListColumn)args.GetColumn(visibleColumnIdx);
|
||||
|
||||
ErrorListViewItemCellGUI(
|
||||
cellRect, item, column, args.selected, args.focused);
|
||||
}
|
||||
}
|
||||
|
||||
static void ErrorListViewItemCellGUI(
|
||||
Rect rect,
|
||||
ErrorListViewItem item,
|
||||
ErrorsListColumn column,
|
||||
bool isSelected,
|
||||
bool isFocused)
|
||||
{
|
||||
ErrorMessage errorMessage = item.ErrorMessage;
|
||||
|
||||
string label = column == ErrorsListColumn.Path ?
|
||||
errorMessage.Path : errorMessage.Error;
|
||||
|
||||
if (column == ErrorsListColumn.Path)
|
||||
{
|
||||
DrawTreeViewItem.ForLabel(
|
||||
rect, label, isSelected, isFocused, false);
|
||||
return;
|
||||
}
|
||||
|
||||
DrawTreeViewItem.ForSecondaryLabel(
|
||||
rect, label, isSelected, isFocused, false);
|
||||
}
|
||||
|
||||
List<TreeViewItem> mRows = new List<TreeViewItem>();
|
||||
|
||||
List<ErrorMessage> mErrorMessages = new List<ErrorMessage>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 331d1c37d891f334390adb8324042856
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.Errors
|
||||
{
|
||||
internal class ErrorsPanel
|
||||
{
|
||||
internal bool IsVisible { get; private set; }
|
||||
|
||||
internal ErrorsPanel(
|
||||
string title,
|
||||
string treeSettingsName)
|
||||
{
|
||||
mTitle = title;
|
||||
|
||||
ErrorsListHeaderState errorsListHeaderState =
|
||||
ErrorsListHeaderState.GetDefault();
|
||||
TreeHeaderSettings.Load(
|
||||
errorsListHeaderState,
|
||||
treeSettingsName,
|
||||
UnityConstants.UNSORT_COLUMN_ID);
|
||||
|
||||
mErrorsListView = new ErrorsListView(errorsListHeaderState);
|
||||
mErrorsListView.Reload();
|
||||
|
||||
mErrorDetailsSplitterState = PlasticSplitterGUILayout.InitSplitterState(
|
||||
new float[] { 0.60f, 0.40f },
|
||||
new int[] { 100, 100 },
|
||||
new int[] { 100000, 100000 }
|
||||
);
|
||||
}
|
||||
|
||||
internal void UpdateErrorsList(List<ErrorMessage> errorMessages)
|
||||
{
|
||||
mErrorsListView.BuildModel(errorMessages);
|
||||
mErrorsListView.Reload();
|
||||
|
||||
IsVisible = errorMessages.Count > 0;
|
||||
}
|
||||
|
||||
internal void OnDisable()
|
||||
{
|
||||
TreeHeaderSettings.Save(
|
||||
mErrorsListView.multiColumnHeader.state,
|
||||
UnityConstants.GLUON_INCOMING_ERRORS_TABLE_SETTINGS_NAME);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
DrawSplitter.ForHorizontalIndicator();
|
||||
DoErrorsListArea(mErrorsListView, mErrorDetailsSplitterState);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DoErrorsListArea(
|
||||
ErrorsListView errorsListView,
|
||||
object splitterState)
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
GUILayout.Label(
|
||||
mTitle,
|
||||
EditorStyles.boldLabel);
|
||||
|
||||
DoErrorsListSplitViewArea(
|
||||
errorsListView, splitterState);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DoErrorsListSplitViewArea(
|
||||
ErrorsListView errorsListView,
|
||||
object splitterState)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
PlasticSplitterGUILayout.BeginHorizontalSplit(splitterState);
|
||||
|
||||
DoErrorsListViewArea(errorsListView);
|
||||
|
||||
DoErrorDetailsTextArea(errorsListView.GetSelectedError());
|
||||
|
||||
PlasticSplitterGUILayout.EndHorizontalSplit();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
static void DoErrorsListViewArea(
|
||||
ErrorsListView errorsListView)
|
||||
{
|
||||
Rect treeRect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
|
||||
|
||||
errorsListView.OnGUI(treeRect);
|
||||
}
|
||||
|
||||
void DoErrorDetailsTextArea(ErrorMessage selectedErrorMessage)
|
||||
{
|
||||
string errorDetailsText = selectedErrorMessage == null ?
|
||||
string.Empty : selectedErrorMessage.Error;
|
||||
|
||||
mErrorDetailsScrollPosition = GUILayout.BeginScrollView(
|
||||
mErrorDetailsScrollPosition);
|
||||
|
||||
GUILayout.TextArea(
|
||||
errorDetailsText, UnityStyles.TextFieldWithWrapping,
|
||||
GUILayout.ExpandHeight(true));
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
Vector2 mErrorDetailsScrollPosition;
|
||||
|
||||
readonly string mTitle;
|
||||
readonly ErrorsListView mErrorsListView;
|
||||
readonly object mErrorDetailsSplitterState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79a84f5f92624d57ae40a84a53bd9d24
|
||||
timeCreated: 1737719456
|
||||
@@ -0,0 +1,109 @@
|
||||
using UnityEngine;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui.Gluon.WorkspaceWindow;
|
||||
using PlasticGui.Gluon;
|
||||
using Unity.PlasticSCM.Editor.UI.StatusBar;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class IncomingChangesNotification :
|
||||
StatusBar.IIncomingChangesNotification,
|
||||
CheckIncomingChanges.IUpdateIncomingChanges
|
||||
{
|
||||
internal IncomingChangesNotification(
|
||||
WorkspaceInfo wkInfo,
|
||||
IGluonViewSwitcher gluonViewSwitcher,
|
||||
PlasticWindow plasticWindow)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mGluonViewSwitcher = gluonViewSwitcher;
|
||||
mPlasticWindow = plasticWindow;
|
||||
}
|
||||
|
||||
bool StatusBar.IIncomingChangesNotification.HasNotification
|
||||
{
|
||||
get { return mHasNotification; }
|
||||
}
|
||||
|
||||
void StatusBar.IIncomingChangesNotification.OnGUI()
|
||||
{
|
||||
Texture2D icon = mData.Status == PlasticNotification.Status.Conflicts ?
|
||||
Images.GetConflictedIcon() :
|
||||
Images.GetOutOfSyncIcon();
|
||||
|
||||
StatusBar.DrawIcon(icon);
|
||||
|
||||
StatusBar.DrawNotificationLabel(new GUIContent(mData.InfoText));
|
||||
|
||||
if (StatusBar.DrawButton(new GUIContent(mData.ActionText, mData.TooltipText)))
|
||||
{
|
||||
ShowIncomingChanges.FromNotificationBar(mWkInfo, mGluonViewSwitcher);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckIncomingChanges.IUpdateIncomingChanges.Hide(WorkspaceInfo wkInfo)
|
||||
{
|
||||
if (!wkInfo.Equals(mWkInfo))
|
||||
return;
|
||||
|
||||
PlasticPlugin.SetNotificationStatus(
|
||||
mPlasticWindow,
|
||||
PlasticNotification.Status.None);
|
||||
|
||||
mData.Clear();
|
||||
|
||||
mHasNotification = false;
|
||||
|
||||
mPlasticWindow.Repaint();
|
||||
}
|
||||
|
||||
void CheckIncomingChanges.IUpdateIncomingChanges.Show(
|
||||
WorkspaceInfo wkInfo,
|
||||
string infoText,
|
||||
string actionText,
|
||||
string tooltipText,
|
||||
CheckIncomingChanges.Severity severity)
|
||||
{
|
||||
if (!wkInfo.Equals(mWkInfo))
|
||||
return;
|
||||
|
||||
PlasticNotification.Status status = GetStatusFromSeverity(severity);
|
||||
|
||||
mData.UpdateData(
|
||||
infoText,
|
||||
actionText,
|
||||
tooltipText,
|
||||
false,
|
||||
status);
|
||||
|
||||
mHasNotification = true;
|
||||
|
||||
PlasticPlugin.SetNotificationStatus(
|
||||
mPlasticWindow,
|
||||
status);
|
||||
|
||||
mPlasticWindow.Repaint();
|
||||
}
|
||||
|
||||
static PlasticNotification.Status GetStatusFromSeverity(
|
||||
CheckIncomingChanges.Severity severity)
|
||||
{
|
||||
if (severity == CheckIncomingChanges.Severity.Info)
|
||||
return PlasticNotification.Status.IncomingChanges;
|
||||
|
||||
if (severity == CheckIncomingChanges.Severity.Warning)
|
||||
return PlasticNotification.Status.Conflicts;
|
||||
|
||||
return PlasticNotification.Status.None;
|
||||
}
|
||||
|
||||
bool mHasNotification;
|
||||
StatusBar.IncomingChangesNotificationData mData =
|
||||
new StatusBar.IncomingChangesNotificationData();
|
||||
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
readonly IGluonViewSwitcher mGluonViewSwitcher;
|
||||
readonly PlasticWindow mPlasticWindow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b17ac8ceb35dc74fbf646862e01a782
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
using GluonGui.WorkspaceWindow.Views.Checkin.Operations;
|
||||
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
|
||||
using PlasticGui;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class ProgressOperationHandler : IUpdateProgress, ICheckinProgress, IProgressOperationHandler
|
||||
{
|
||||
internal ProgressOperationHandler(WorkspaceWindow workspaceWindow)
|
||||
{
|
||||
mWorkspaceWindow = workspaceWindow;
|
||||
}
|
||||
|
||||
internal bool IsOperationInProgress()
|
||||
{
|
||||
return mUpdateProgress != null
|
||||
|| mCheckinProgress != null;
|
||||
}
|
||||
|
||||
internal void CancelUpdateProgress()
|
||||
{
|
||||
mUpdateProgress.Cancel();
|
||||
}
|
||||
|
||||
void ICheckinProgress.ShowProgress()
|
||||
{
|
||||
mCheckinProgress = new CheckinProgress(mWorkspaceWindow);
|
||||
}
|
||||
|
||||
void ICheckinProgress.RefreshProgress(CheckinProgressData progress)
|
||||
{
|
||||
mCheckinProgress.Refresh(progress);
|
||||
}
|
||||
|
||||
void ICheckinProgress.EndProgress()
|
||||
{
|
||||
mCheckinProgress = null;
|
||||
mWorkspaceWindow.Progress.ResetProgress();
|
||||
mWorkspaceWindow.RequestRepaint();
|
||||
}
|
||||
|
||||
void IUpdateProgress.ShowNoCancelableProgress()
|
||||
{
|
||||
mUpdateProgress = new UpdateProgress(mWorkspaceWindow);
|
||||
mUpdateProgress.SetCancellable(false);
|
||||
}
|
||||
|
||||
void IUpdateProgress.ShowCancelableProgress()
|
||||
{
|
||||
mUpdateProgress = new UpdateProgress(mWorkspaceWindow);
|
||||
mUpdateProgress.SetCancellable(true);
|
||||
}
|
||||
|
||||
void IUpdateProgress.RefreshProgress(
|
||||
Codice.Client.BaseCommands.UpdateProgress updateProgress,
|
||||
UpdateProgressData updateProgressData)
|
||||
{
|
||||
mUpdateProgress.RefreshProgress(updateProgress, updateProgressData);
|
||||
}
|
||||
|
||||
void IUpdateProgress.EndProgress()
|
||||
{
|
||||
mUpdateProgress = null;
|
||||
mWorkspaceWindow.Progress.ResetProgress();
|
||||
mWorkspaceWindow.RequestRepaint();
|
||||
}
|
||||
|
||||
bool IProgressOperationHandler.CheckOperationInProgress()
|
||||
{
|
||||
return IsOperationInProgress();
|
||||
}
|
||||
|
||||
UpdateProgress mUpdateProgress;
|
||||
CheckinProgress mCheckinProgress;
|
||||
|
||||
WorkspaceWindow mWorkspaceWindow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09b199e86de5d1944ab9106ca2c11f75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,162 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common.EventTracking;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow;
|
||||
using PlasticGui.WorkspaceWindow.Topbar;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
using Unity.PlasticSCM.Editor.Tool;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.StatusBar;
|
||||
|
||||
using GluonShelveOperations = GluonGui.WorkspaceWindow.Views.Shelves.ShelveOperations;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class ShelvedChangesNotification :
|
||||
StatusBar.IShelvedChangesNotification,
|
||||
CheckShelvedChanges.IUpdateShelvedChangesNotification
|
||||
{
|
||||
internal ShelvedChangesNotification(
|
||||
WorkspaceInfo wkInfo,
|
||||
RepositorySpec repSpec,
|
||||
ViewSwitcher viewSwitcher,
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
PlasticWindow plasticWindow)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mRepSpec = repSpec;
|
||||
mViewSwitcher = viewSwitcher;
|
||||
mShowDownloadPlasticExeWindow = showDownloadPlasticExeWindow;
|
||||
mPlasticWindow = plasticWindow;
|
||||
}
|
||||
|
||||
bool StatusBar.IShelvedChangesNotification.HasNotification
|
||||
{
|
||||
get { return mHasNotification; }
|
||||
}
|
||||
|
||||
void StatusBar.IShelvedChangesNotification.SetWorkspaceWindow(
|
||||
WorkspaceWindow workspaceWindow)
|
||||
{
|
||||
mWorkspaceWindow = workspaceWindow;
|
||||
}
|
||||
|
||||
void StatusBar.IShelvedChangesNotification.SetShelvedChangesUpdater(
|
||||
IShelvedChangesUpdater shelvedChangesUpdater)
|
||||
{
|
||||
mShelvedChangesUpdater = shelvedChangesUpdater;
|
||||
}
|
||||
|
||||
void StatusBar.IShelvedChangesNotification.OnGUI()
|
||||
{
|
||||
Texture2D icon = Images.GetInfoBellNotificationIcon();
|
||||
|
||||
StatusBar.DrawIcon(icon, UnityConstants.STATUS_BAR_ICON_SIZE - 2);
|
||||
|
||||
StatusBar.DrawNotificationLabel(
|
||||
new GUIContent(
|
||||
PlasticLocalization.Name.ShelvedChanges.GetString(),
|
||||
PlasticLocalization.Name.ShelvedChangesExplanation.GetString()));
|
||||
|
||||
GenericMenu discardShelveDropdownMenu = new GenericMenu();
|
||||
|
||||
discardShelveDropdownMenu.AddItem(
|
||||
new GUIContent(PlasticLocalization.Name.Apply.GetString()),
|
||||
false,
|
||||
ApplyPartialShelveset);
|
||||
|
||||
discardShelveDropdownMenu.AddItem(
|
||||
new GUIContent(PlasticLocalization.Name.DiscardShelvedChanges.GetString()),
|
||||
false,
|
||||
DiscardShelvedChanges);
|
||||
|
||||
DrawActionButtonWithMenu.For(
|
||||
PlasticLocalization.Name.ViewButton.GetString(),
|
||||
PlasticLocalization.Name.ViewShelvedChangesButtonExplanation.GetString(),
|
||||
ShowShelvesView,
|
||||
discardShelveDropdownMenu);
|
||||
}
|
||||
|
||||
void CheckShelvedChanges.IUpdateShelvedChangesNotification.Hide(
|
||||
WorkspaceInfo wkInfo)
|
||||
{
|
||||
if (!wkInfo.Equals(mWkInfo))
|
||||
return;
|
||||
|
||||
mShelveInfo = null;
|
||||
|
||||
mHasNotification = false;
|
||||
|
||||
mPlasticWindow.Repaint();
|
||||
}
|
||||
|
||||
void CheckShelvedChanges.IUpdateShelvedChangesNotification.Show(
|
||||
WorkspaceInfo wkInfo,
|
||||
RepositorySpec repSpec,
|
||||
ChangesetInfo shelveInfo)
|
||||
{
|
||||
if (!wkInfo.Equals(mWkInfo))
|
||||
return;
|
||||
|
||||
mShelveInfo = shelveInfo;
|
||||
|
||||
mHasNotification = true;
|
||||
|
||||
mPlasticWindow.Repaint();
|
||||
}
|
||||
|
||||
void ApplyPartialShelveset()
|
||||
{
|
||||
GluonShelveOperations.ApplyPartialShelveset(
|
||||
mWkInfo,
|
||||
mShelveInfo,
|
||||
mWorkspaceWindow,
|
||||
PlasticExeLauncher.BuildForResolveConflicts(
|
||||
mWkInfo, true, mShowDownloadPlasticExeWindow),
|
||||
mViewSwitcher.ShelvesTab,
|
||||
mViewSwitcher.ShelvesTab.ProgressControls,
|
||||
mViewSwitcher.PendingChangesTab,
|
||||
mWorkspaceWindow.GluonProgressOperationHandler,
|
||||
mWorkspaceWindow.GluonProgressOperationHandler,
|
||||
mShelvedChangesUpdater,
|
||||
RefreshAsset.BeforeLongAssetOperation,
|
||||
RefreshAsset.AfterLongAssetOperation);
|
||||
}
|
||||
|
||||
void DiscardShelvedChanges()
|
||||
{
|
||||
ShelvedChangesNotificationPanelOperations.DiscardShelvedChanges(
|
||||
mWkInfo,
|
||||
mShelveInfo,
|
||||
this,
|
||||
mShelvedChangesUpdater,
|
||||
null,
|
||||
mWorkspaceWindow);
|
||||
}
|
||||
|
||||
void ShowShelvesView()
|
||||
{
|
||||
TrackFeatureUseEvent.For(
|
||||
mRepSpec,
|
||||
TrackFeatureUseEvent.Features.SwitchAndShelve.ShowShelvesViewFromNotification);
|
||||
|
||||
mViewSwitcher.ShowShelvesView(mShelveInfo);
|
||||
}
|
||||
|
||||
bool mHasNotification;
|
||||
ChangesetInfo mShelveInfo;
|
||||
|
||||
WorkspaceWindow mWorkspaceWindow;
|
||||
IShelvedChangesUpdater mShelvedChangesUpdater;
|
||||
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
readonly RepositorySpec mRepSpec;
|
||||
readonly ViewSwitcher mViewSwitcher;
|
||||
readonly LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow;
|
||||
readonly PlasticWindow mPlasticWindow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea76fa5a629244fa9ae3a8d3224aef02
|
||||
timeCreated: 1733153987
|
||||
@@ -0,0 +1,41 @@
|
||||
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class UpdateProgress
|
||||
{
|
||||
internal UpdateProgress(WorkspaceWindow workspaceWindow)
|
||||
{
|
||||
mWorkspaceWindow = workspaceWindow;
|
||||
}
|
||||
|
||||
internal void Cancel()
|
||||
{
|
||||
if (mUpdateProgress == null)
|
||||
return;
|
||||
|
||||
mUpdateProgress.Cancel();
|
||||
}
|
||||
|
||||
internal void SetCancellable(bool bCancelable)
|
||||
{
|
||||
mWorkspaceWindow.Progress.CanCancelProgress = bCancelable;
|
||||
}
|
||||
|
||||
internal void RefreshProgress(
|
||||
Codice.Client.BaseCommands.UpdateProgress progress,
|
||||
UpdateProgressData updateProgressData)
|
||||
{
|
||||
mUpdateProgress = progress;
|
||||
|
||||
mWorkspaceWindow.Progress.ProgressHeader = updateProgressData.Details;
|
||||
|
||||
mWorkspaceWindow.Progress.TotalProgressMessage = updateProgressData.Status;
|
||||
mWorkspaceWindow.Progress.TotalProgressPercent = updateProgressData.ProgressValue / 100;
|
||||
}
|
||||
|
||||
Codice.Client.BaseCommands.UpdateProgress mUpdateProgress;
|
||||
|
||||
WorkspaceWindow mWorkspaceWindow;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c13239fbea1666a42b26691afcd91e63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3f9d1ab8dcbb414abb3380d0d8032fc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
using Codice.CM.Common;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.UpdateReport
|
||||
{
|
||||
internal class ErrorListViewItem : TreeViewItem
|
||||
{
|
||||
internal ErrorMessage ErrorMessage { get; private set; }
|
||||
|
||||
internal ErrorListViewItem(int id, ErrorMessage errorMessage)
|
||||
: base(id, 0)
|
||||
{
|
||||
ErrorMessage = errorMessage;
|
||||
|
||||
displayName = errorMessage.Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0188683ab76112f4897348feb19a3b77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.BaseCommands;
|
||||
using Codice.CM.Common;
|
||||
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.UpdateReport
|
||||
{
|
||||
internal class UpdateReportDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 800, 400);
|
||||
}
|
||||
}
|
||||
|
||||
internal static UpdateReportResult ShowUpdateReport(
|
||||
WorkspaceInfo wkInfo,
|
||||
List<ErrorMessage> errors,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
UpdateReportDialog dialog = Create(wkInfo, errors);
|
||||
|
||||
ResponseType dialogResult = dialog.RunModal(parentWindow);
|
||||
|
||||
UpdateReportResult result = dialog.GetUpdateReportResult();
|
||||
|
||||
result.Result = dialogResult == ResponseType.Ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override void SaveSettings()
|
||||
{
|
||||
TreeHeaderSettings.Save(mUpdateReportListView.multiColumnHeader.state,
|
||||
UnityConstants.GLUON_UPDATE_REPORT_TABLE_SETTINGS_NAME);
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
Title(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UpdateResultsTitle));
|
||||
|
||||
Paragraph(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UpdateResultsExplanation));
|
||||
|
||||
DoUpdateReportArea(
|
||||
mUpdateReportListView, mErrorDetailsSplitterState);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
DoSelectAllArea();
|
||||
|
||||
GUILayout.Space(20);
|
||||
|
||||
DoButtonsArea(mIsUpdateForcedButtonEnabled);
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UpdateResultsTitle);
|
||||
}
|
||||
|
||||
void OnCheckedErrorChanged()
|
||||
{
|
||||
mIsUpdateForcedButtonEnabled =
|
||||
mUpdateReportListView.IsAnyErrorChecked();
|
||||
mIsSelectAllToggleChecked =
|
||||
mUpdateReportListView.AreAllErrorsChecked();
|
||||
}
|
||||
|
||||
UpdateReportResult GetUpdateReportResult()
|
||||
{
|
||||
return new UpdateReportResult
|
||||
{
|
||||
UpdateForcedPaths = mUpdateReportListView.GetCheckedPaths(),
|
||||
UnaffectedErrors = mUpdateReportListView.GetUncheckedErrors()
|
||||
};
|
||||
}
|
||||
|
||||
static void UpdateUpdateReportList(
|
||||
UpdateReportListView updateReportListView,
|
||||
List<ErrorMessage> errorMessages)
|
||||
{
|
||||
updateReportListView.BuildModel(errorMessages);
|
||||
|
||||
updateReportListView.Reload();
|
||||
}
|
||||
|
||||
static string GetErrorDetailsText(
|
||||
ErrorMessage selectedErrorMessage)
|
||||
{
|
||||
if (selectedErrorMessage == null)
|
||||
return string.Empty;
|
||||
|
||||
return string.Format("{0}:{1}{2}",
|
||||
selectedErrorMessage.Path,
|
||||
Environment.NewLine,
|
||||
selectedErrorMessage.Error);
|
||||
}
|
||||
|
||||
void DoUpdateReportArea(
|
||||
UpdateReportListView updateReportListView,
|
||||
object splitterState)
|
||||
{
|
||||
PlasticSplitterGUILayout.BeginHorizontalSplit(splitterState);
|
||||
|
||||
DoUpdateReportViewArea(updateReportListView);
|
||||
|
||||
DoErrorDetailsTextArea(updateReportListView.GetSelectedError());
|
||||
|
||||
PlasticSplitterGUILayout.EndHorizontalSplit();
|
||||
}
|
||||
|
||||
static void DoUpdateReportViewArea(
|
||||
UpdateReportListView updateReportListView)
|
||||
{
|
||||
Rect treeRect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
|
||||
|
||||
updateReportListView.OnGUI(treeRect);
|
||||
}
|
||||
|
||||
void DoErrorDetailsTextArea(
|
||||
ErrorMessage selectedErrorMessage)
|
||||
{
|
||||
string errorDetailsText =
|
||||
GetErrorDetailsText(selectedErrorMessage);
|
||||
|
||||
mErrorDetailsScrollPosition = GUILayout.BeginScrollView(
|
||||
mErrorDetailsScrollPosition);
|
||||
|
||||
GUILayout.TextArea(
|
||||
errorDetailsText, UnityStyles.TextFieldWithWrapping,
|
||||
GUILayout.ExpandHeight(true));
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
void DoSelectAllArea()
|
||||
{
|
||||
bool wasChecked = mIsSelectAllToggleChecked;
|
||||
|
||||
bool isChecked = EditorGUILayout.ToggleLeft(
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.SelectAll),
|
||||
wasChecked);
|
||||
|
||||
if (!wasChecked && isChecked)
|
||||
{
|
||||
mIsSelectAllToggleChecked = true;
|
||||
mUpdateReportListView.CheckAllLines();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wasChecked && !isChecked)
|
||||
{
|
||||
mIsSelectAllToggleChecked = false;
|
||||
mUpdateReportListView.UncheckAllLines();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DoButtonsArea(bool isUpdateForcedButtonEnabled)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
DoUpdateForcedButton(isUpdateForcedButtonEnabled);
|
||||
DoCloseButton();
|
||||
return;
|
||||
}
|
||||
|
||||
DoCloseButton();
|
||||
DoUpdateForcedButton(isUpdateForcedButtonEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
void DoUpdateForcedButton(bool isEnabled)
|
||||
{
|
||||
GUI.enabled = isEnabled;
|
||||
|
||||
mEnterKeyAction = GetEnterKeyAction(isEnabled);
|
||||
|
||||
bool pressed = AcceptButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.UpdateForced));
|
||||
|
||||
GUI.enabled = true;
|
||||
|
||||
if (!pressed)
|
||||
return;
|
||||
|
||||
OkButtonAction();
|
||||
}
|
||||
|
||||
void DoCloseButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CloseButton)))
|
||||
return;
|
||||
|
||||
CloseButtonAction();
|
||||
}
|
||||
|
||||
Action GetEnterKeyAction(bool isEnabled)
|
||||
{
|
||||
if (isEnabled)
|
||||
return OkButtonAction;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void BuildComponents(WorkspaceInfo wkInfo)
|
||||
{
|
||||
UpdateReportListHeaderState updateReportListHeaderState =
|
||||
UpdateReportListHeaderState.GetDefault();
|
||||
TreeHeaderSettings.Load(updateReportListHeaderState,
|
||||
UnityConstants.GLUON_UPDATE_REPORT_TABLE_SETTINGS_NAME,
|
||||
UnityConstants.UNSORT_COLUMN_ID);
|
||||
|
||||
mUpdateReportListView = new UpdateReportListView(
|
||||
wkInfo, updateReportListHeaderState,
|
||||
OnCheckedErrorChanged);
|
||||
mUpdateReportListView.Reload();
|
||||
}
|
||||
|
||||
static UpdateReportDialog Create(
|
||||
WorkspaceInfo wkInfo,
|
||||
List<ErrorMessage> errors)
|
||||
{
|
||||
var instance = CreateInstance<UpdateReportDialog>();
|
||||
instance.mWkInfo = wkInfo;
|
||||
instance.mErrors = errors;
|
||||
instance.mEscapeKeyAction = instance.CloseButtonAction;
|
||||
|
||||
instance.BuildComponents(instance.mWkInfo);
|
||||
|
||||
instance.mErrorDetailsSplitterState = PlasticSplitterGUILayout.InitSplitterState(
|
||||
new float[] { 0.50f, 0.50f },
|
||||
new int[] { 100, 100 },
|
||||
new int[] { 100000, 100000 }
|
||||
);
|
||||
|
||||
UpdateUpdateReportList(
|
||||
instance.mUpdateReportListView,
|
||||
instance.mErrors);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool mIsSelectAllToggleChecked;
|
||||
bool mIsUpdateForcedButtonEnabled;
|
||||
object mErrorDetailsSplitterState;
|
||||
Vector2 mErrorDetailsScrollPosition;
|
||||
|
||||
UpdateReportListView mUpdateReportListView;
|
||||
|
||||
List<ErrorMessage> mErrors;
|
||||
WorkspaceInfo mWkInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c0160d91d8eec24bbb43873243d2343
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.UpdateReport
|
||||
{
|
||||
internal enum UpdateReportListColumn
|
||||
{
|
||||
Path
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class UpdateReportListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
|
||||
{
|
||||
internal static UpdateReportListHeaderState GetDefault()
|
||||
{
|
||||
return new UpdateReportListHeaderState(BuildColumns());
|
||||
}
|
||||
|
||||
internal static string GetColumnName(UpdateReportListColumn column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case UpdateReportListColumn.Path:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.PathColumn);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (mHeaderTitles != null)
|
||||
TreeHeaderColumns.SetTitles(columns, mHeaderTitles);
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
static Column[] BuildColumns()
|
||||
{
|
||||
return new Column[]
|
||||
{
|
||||
new Column()
|
||||
{
|
||||
width = 600,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(UpdateReportListColumn.Path)),
|
||||
minWidth = 200,
|
||||
allowToggleVisibility = false,
|
||||
canSort = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
UpdateReportListHeaderState(Column[] columns)
|
||||
: base(columns)
|
||||
{
|
||||
if (mHeaderTitles == null)
|
||||
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f40a58028b39d3f4bbebe1f6cf919271
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,286 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.BaseCommands;
|
||||
using Codice.Client.Commands;
|
||||
using Codice.Client.Common;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon.UpdateReport
|
||||
{
|
||||
internal class UpdateReportListView : TreeView
|
||||
{
|
||||
internal UpdateReportListView(
|
||||
WorkspaceInfo wkInfo,
|
||||
UpdateReportListHeaderState headerState,
|
||||
Action onCheckedErrorChanged)
|
||||
: base(new TreeViewState())
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mOnCheckedErrorChanged = onCheckedErrorChanged;
|
||||
|
||||
multiColumnHeader = new MultiColumnHeader(headerState);
|
||||
multiColumnHeader.canSort = false;
|
||||
|
||||
rowHeight = UnityConstants.TREEVIEW_ROW_HEIGHT;
|
||||
showAlternatingRowBackgrounds = false;
|
||||
}
|
||||
|
||||
public override IList<TreeViewItem> GetRows()
|
||||
{
|
||||
return mRows;
|
||||
}
|
||||
|
||||
protected override TreeViewItem BuildRoot()
|
||||
{
|
||||
return new TreeViewItem(0, -1, string.Empty);
|
||||
}
|
||||
|
||||
protected override IList<TreeViewItem> BuildRows(TreeViewItem rootItem)
|
||||
{
|
||||
RegenerateRows(
|
||||
this, mErrorMessages, rootItem, mRows);
|
||||
|
||||
return mRows;
|
||||
}
|
||||
|
||||
protected override void BeforeRowsGUI()
|
||||
{
|
||||
int firstRowVisible;
|
||||
int lastRowVisible;
|
||||
GetFirstAndLastVisibleRows(out firstRowVisible, out lastRowVisible);
|
||||
|
||||
GUI.DrawTexture(new Rect(0,
|
||||
firstRowVisible * rowHeight,
|
||||
GetRowRect(0).width+500,
|
||||
(lastRowVisible * rowHeight) + 1000),
|
||||
Images.GetTreeviewBackgroundTexture());
|
||||
|
||||
DrawTreeViewItem.InitializeStyles();
|
||||
base.BeforeRowsGUI();
|
||||
}
|
||||
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
if (args.item is ErrorListViewItem)
|
||||
{
|
||||
ErrorListViewItemGUI(
|
||||
rowHeight, mWkInfo, mCheckedErrors,
|
||||
(ErrorListViewItem)args.item,
|
||||
mOnCheckedErrorChanged, args);
|
||||
return;
|
||||
}
|
||||
|
||||
base.RowGUI(args);
|
||||
}
|
||||
|
||||
internal void BuildModel(List<ErrorMessage> errorMessages)
|
||||
{
|
||||
mCheckedErrors.Clear();
|
||||
|
||||
mErrorMessages = errorMessages;
|
||||
|
||||
mOnCheckedErrorChanged();
|
||||
}
|
||||
|
||||
internal void CheckAllLines()
|
||||
{
|
||||
mCheckedErrors.Clear();
|
||||
|
||||
foreach (ErrorMessage error in mErrorMessages)
|
||||
mCheckedErrors.Add(error);
|
||||
|
||||
mOnCheckedErrorChanged();
|
||||
}
|
||||
|
||||
internal void UncheckAllLines()
|
||||
{
|
||||
mCheckedErrors.Clear();
|
||||
|
||||
mOnCheckedErrorChanged();
|
||||
}
|
||||
|
||||
internal bool AreAllErrorsChecked()
|
||||
{
|
||||
if (mErrorMessages.Count == 0)
|
||||
return false;
|
||||
|
||||
return mCheckedErrors.Count == mErrorMessages.Count;
|
||||
}
|
||||
|
||||
internal bool IsAnyErrorChecked()
|
||||
{
|
||||
return mCheckedErrors.Count > 0;
|
||||
}
|
||||
|
||||
internal List<string> GetCheckedPaths()
|
||||
{
|
||||
return mCheckedErrors.Select(
|
||||
message => message.Path).ToList();
|
||||
}
|
||||
|
||||
internal List<ErrorMessage> GetUncheckedErrors()
|
||||
{
|
||||
return mErrorMessages.Where(
|
||||
message => !mCheckedErrors.Contains(message)).ToList();
|
||||
}
|
||||
|
||||
internal ErrorMessage GetSelectedError()
|
||||
{
|
||||
List<ErrorMessage> selectedErrors = GetSelectedErrors(this);
|
||||
|
||||
if (selectedErrors.Count != 1)
|
||||
return null;
|
||||
|
||||
return selectedErrors[0];
|
||||
}
|
||||
|
||||
static void UpdateCheckState(
|
||||
HashSet<ErrorMessage> checkedErrors,
|
||||
ErrorMessage errorMessage,
|
||||
bool isChecked)
|
||||
{
|
||||
if (isChecked)
|
||||
{
|
||||
checkedErrors.Add(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
checkedErrors.Remove(errorMessage);
|
||||
}
|
||||
|
||||
static List<ErrorMessage> GetSelectedErrors(
|
||||
UpdateReportListView listView)
|
||||
{
|
||||
List<ErrorMessage> result = new List<ErrorMessage>();
|
||||
|
||||
IList<int> selectedIds = listView.GetSelection();
|
||||
|
||||
if (selectedIds.Count == 0)
|
||||
return result;
|
||||
|
||||
foreach (ErrorListViewItem treeViewItem in
|
||||
listView.FindRows(selectedIds))
|
||||
{
|
||||
result.Add(treeViewItem.ErrorMessage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void RegenerateRows(
|
||||
UpdateReportListView listView,
|
||||
List<ErrorMessage> errorMessages,
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
ClearRows(rootItem, rows);
|
||||
|
||||
if (errorMessages.Count == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < errorMessages.Count; i++)
|
||||
{
|
||||
ErrorListViewItem errorListViewItem =
|
||||
new ErrorListViewItem(i + 1, errorMessages[i]);
|
||||
|
||||
rootItem.AddChild(errorListViewItem);
|
||||
rows.Add(errorListViewItem);
|
||||
}
|
||||
|
||||
listView.SetSelection(new List<int> { 1 });
|
||||
}
|
||||
|
||||
static void ClearRows(
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
if (rootItem.hasChildren)
|
||||
rootItem.children.Clear();
|
||||
|
||||
rows.Clear();
|
||||
}
|
||||
|
||||
static void ErrorListViewItemGUI(
|
||||
float rowHeight,
|
||||
WorkspaceInfo wkInfo,
|
||||
HashSet<ErrorMessage> checkedErrors,
|
||||
ErrorListViewItem item,
|
||||
Action onCheckedErrorChanged,
|
||||
RowGUIArgs args)
|
||||
{
|
||||
for (int visibleColumnIdx = 0; visibleColumnIdx < args.GetNumVisibleColumns(); visibleColumnIdx++)
|
||||
{
|
||||
Rect cellRect = args.GetCellRect(visibleColumnIdx);
|
||||
|
||||
UpdateReportListColumn column =
|
||||
(UpdateReportListColumn)args.GetColumn(visibleColumnIdx);
|
||||
|
||||
ErrorListViewItemCellGUI(
|
||||
cellRect, rowHeight, wkInfo, checkedErrors,
|
||||
item, onCheckedErrorChanged, column,
|
||||
args.selected, args.focused);
|
||||
}
|
||||
}
|
||||
|
||||
static void ErrorListViewItemCellGUI(
|
||||
Rect rect,
|
||||
float rowHeight,
|
||||
WorkspaceInfo wkInfo,
|
||||
HashSet<ErrorMessage> checkedErrors,
|
||||
ErrorListViewItem item,
|
||||
Action onCheckedErrorChanged,
|
||||
UpdateReportListColumn column,
|
||||
bool isSelected,
|
||||
bool isFocused)
|
||||
{
|
||||
ErrorMessage errorMessage = item.ErrorMessage;
|
||||
|
||||
string label = GetColumnText(
|
||||
wkInfo, errorMessage,
|
||||
UpdateReportListHeaderState.GetColumnName(column));
|
||||
|
||||
bool wasChecked = checkedErrors.Contains(errorMessage);
|
||||
|
||||
bool isChecked = DrawTreeViewItem.ForCheckableItemCell(
|
||||
rect, rowHeight, 0, null, null, label,
|
||||
isSelected, isFocused, false, wasChecked);
|
||||
|
||||
if (wasChecked != isChecked)
|
||||
{
|
||||
UpdateCheckState(
|
||||
checkedErrors, errorMessage, isChecked);
|
||||
|
||||
onCheckedErrorChanged();
|
||||
}
|
||||
}
|
||||
|
||||
static string GetColumnText(
|
||||
WorkspaceInfo wkInfo, ErrorMessage message, string columnName)
|
||||
{
|
||||
if (columnName != PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.PathColumn))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return WorkspacePath.ClientToCM(
|
||||
message.Path, wkInfo.ClientPath);
|
||||
}
|
||||
|
||||
List<TreeViewItem> mRows = new List<TreeViewItem>();
|
||||
|
||||
HashSet<ErrorMessage> mCheckedErrors = new HashSet<ErrorMessage>();
|
||||
List<ErrorMessage> mErrorMessages = new List<ErrorMessage>();
|
||||
|
||||
readonly Action mOnCheckedErrorChanged;
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5d431e8131b1d74897c1a18b5e76932
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user