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,86 @@
|
||||
using PlasticGui.Gluon.WorkspaceWindow;
|
||||
using Unity.PlasticSCM.Editor.UI.StatusBar;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class IncomingChangesNotifier :
|
||||
IIncomingChangesNotifier,
|
||||
CheckIncomingChanges.IUpdateIncomingChanges
|
||||
{
|
||||
bool IIncomingChangesNotifier.HasNotification
|
||||
{
|
||||
get { return mHasNotification; }
|
||||
}
|
||||
|
||||
IncomingChangesNotification IIncomingChangesNotifier.Notification
|
||||
{
|
||||
get { return mNotification; }
|
||||
}
|
||||
|
||||
internal IncomingChangesNotifier(
|
||||
PlasticWindow plasticWindow)
|
||||
{
|
||||
mPlasticWindow = plasticWindow;
|
||||
}
|
||||
|
||||
void CheckIncomingChanges.IUpdateIncomingChanges.Hide()
|
||||
{
|
||||
PlasticPlugin.SetNotificationStatus(
|
||||
mPlasticWindow,
|
||||
PlasticNotification.Status.None);
|
||||
|
||||
mNotification.Clear();
|
||||
|
||||
mHasNotification = false;
|
||||
|
||||
mPlasticWindow.Repaint();
|
||||
}
|
||||
|
||||
void CheckIncomingChanges.IUpdateIncomingChanges.Show(
|
||||
string infoText,
|
||||
string actionText,
|
||||
string tooltipText,
|
||||
CheckIncomingChanges.Severity severity)
|
||||
{
|
||||
PlasticNotification.Status status = PlasticNotification.Status.None;
|
||||
if (severity == CheckIncomingChanges.Severity.Info)
|
||||
status = PlasticNotification.Status.IncomingChanges;
|
||||
else if (severity == CheckIncomingChanges.Severity.Warning)
|
||||
status = PlasticNotification.Status.Conflicts;
|
||||
|
||||
PlasticPlugin.SetNotificationStatus(
|
||||
mPlasticWindow,
|
||||
status);
|
||||
|
||||
UpdateData(
|
||||
mNotification,
|
||||
infoText,
|
||||
actionText,
|
||||
tooltipText,
|
||||
status);
|
||||
|
||||
mHasNotification = true;
|
||||
|
||||
mPlasticWindow.Repaint();
|
||||
}
|
||||
|
||||
static void UpdateData(
|
||||
IncomingChangesNotification data,
|
||||
string infoText,
|
||||
string actionText,
|
||||
string tooltipText,
|
||||
PlasticNotification.Status status)
|
||||
{
|
||||
data.InfoText = infoText;
|
||||
data.ActionText = actionText;
|
||||
data.TooltipText = tooltipText;
|
||||
data.HasUpdateAction = false;
|
||||
data.Status = status;
|
||||
}
|
||||
|
||||
bool mHasNotification;
|
||||
IncomingChangesNotification mNotification = new IncomingChangesNotification();
|
||||
|
||||
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,72 @@
|
||||
using GluonGui.WorkspaceWindow.Views.Checkin.Operations;
|
||||
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Gluon
|
||||
{
|
||||
internal class ProgressOperationHandler : IUpdateProgress, ICheckinProgress
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
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,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,20 @@
|
||||
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