Initial commit

This commit is contained in:
lethanhsonvsp
2025-11-17 15:02:30 +07:00
commit 0a84b9d75e
15481 changed files with 2009655 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
using UnityEditor.IMGUI.Controls;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
class BranchListViewItem : TreeViewItem
{
internal object ObjectInfo { get; private set; }
internal BranchListViewItem(int id, object objectInfo)
: base(id, 1)
{
ObjectInfo = objectInfo;
displayName = id.ToString();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebbbce5f7ed39ab45b6f43340727ba5e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Tree;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
internal enum BranchesListColumn
{
Name,
Repository,
CreatedBy,
CreationDate,
Comment
}
[Serializable]
internal class BranchesListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
{
internal static BranchesListHeaderState GetDefault()
{
return new BranchesListHeaderState(BuildColumns());
}
internal static List<string> GetColumnNames()
{
List<string> result = new List<string>();
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.NameColumn));
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.RepositoryColumn));
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.CreatedByColumn));
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.CreationDateColumn));
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.CommentColumn));
return result;
}
internal static string GetColumnName(BranchesListColumn column)
{
switch (column)
{
case BranchesListColumn.Name:
return PlasticLocalization.GetString(PlasticLocalization.Name.NameColumn);
case BranchesListColumn.Repository:
return PlasticLocalization.GetString(PlasticLocalization.Name.RepositoryColumn);
case BranchesListColumn.CreatedBy:
return PlasticLocalization.GetString(PlasticLocalization.Name.CreatedByColumn);
case BranchesListColumn.CreationDate:
return PlasticLocalization.GetString(PlasticLocalization.Name.CreationDateColumn);
case BranchesListColumn.Comment:
return PlasticLocalization.GetString(PlasticLocalization.Name.CommentColumn);
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 = UnityConstants.BranchesColumns.BRANCHES_NAME_WIDTH,
minWidth = UnityConstants.BranchesColumns.BRANCHES_NAME_MIN_WIDTH,
headerContent = new GUIContent(
GetColumnName(BranchesListColumn.Name)),
allowToggleVisibility = false,
sortingArrowAlignment = TextAlignment.Right
},
new Column()
{
width = UnityConstants.BranchesColumns.REPOSITORY_WIDTH,
minWidth = UnityConstants.BranchesColumns.REPOSITORY_MIN_WIDTH,
headerContent = new GUIContent(
GetColumnName(BranchesListColumn.Repository)),
sortingArrowAlignment = TextAlignment.Right
},
new Column()
{
width = UnityConstants.BranchesColumns.CREATEDBY_WIDTH,
minWidth = UnityConstants.BranchesColumns.CREATEDBY_MIN_WIDTH,
headerContent = new GUIContent(
GetColumnName(BranchesListColumn.CreatedBy)),
sortingArrowAlignment = TextAlignment.Right
},
new Column()
{
width = UnityConstants.BranchesColumns.CREATION_DATE_WIDTH,
minWidth = UnityConstants.BranchesColumns.CREATION_DATE_MIN_WIDTH,
headerContent = new GUIContent(
GetColumnName(BranchesListColumn.CreationDate)),
sortingArrowAlignment = TextAlignment.Right
},
new Column()
{
width = UnityConstants.BranchesColumns.COMMENT_WIDTH,
minWidth = UnityConstants.BranchesColumns.COMMENT_MIN_WIDTH,
headerContent = new GUIContent(
GetColumnName(BranchesListColumn.Comment)),
sortingArrowAlignment = TextAlignment.Right
}
};
}
BranchesListHeaderState(Column[] columns)
: base(columns)
{
if (mHeaderTitles == null)
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
if (mColumnsAllowedToggleVisibility == null)
mColumnsAllowedToggleVisibility = TreeHeaderColumns.GetVisibilities(columns);
}
[SerializeField]
string[] mHeaderTitles;
[SerializeField]
bool[] mColumnsAllowedToggleVisibility;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f4a41e458bcb22946bcfa6b165c90288
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,397 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Avatar;
using Unity.PlasticSCM.Editor.UI.Tree;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
internal class BranchesListView : PlasticTreeView
{
internal GenericMenu Menu { get { return mMenu.Menu; } }
internal long LoadedBranchId { get { return mLoadedBranchId; } }
internal BranchesListView(
BranchesListHeaderState headerState,
List<string> columnNames,
BranchesViewMenu menu,
Action sizeChangedAction,
Action doubleClickAction)
{
mColumnNames = columnNames;
mMenu = menu;
mSizeChangedAction = sizeChangedAction;
mDoubleClickAction = doubleClickAction;
multiColumnHeader = new MultiColumnHeader(headerState);
multiColumnHeader.canSort = true;
multiColumnHeader.sortingChanged += SortingChanged;
mCooldownFilterAction = new CooldownWindowDelayer(
DelayedSearchChanged, UnityConstants.SEARCH_DELAYED_INPUT_ACTION_INTERVAL);
}
internal void SetLoadedBranchId(long loadedBranchId)
{
mLoadedBranchId = loadedBranchId;
}
protected override IList<TreeViewItem> BuildRows(
TreeViewItem rootItem)
{
if (mQueryResult == null)
{
ClearRows(rootItem, mRows);
return mRows;
}
RegenerateRows(
mListViewItemIds,
mQueryResult.GetObjects(),
rootItem, mRows);
return mRows;
}
protected override void SearchChanged(string newSearch)
{
mCooldownFilterAction.Ping();
}
protected override void ContextClickedItem(int id)
{
mMenu.Popup();
Repaint();
}
public override void OnGUI(Rect rect)
{
if (Event.current.type == EventType.Layout)
{
if (IsSizeChanged(treeViewRect, mLastRect))
mSizeChangedAction();
}
mLastRect = treeViewRect;
base.OnGUI(rect);
Event e = Event.current;
if (e.type != EventType.KeyDown)
return;
bool isProcessed = mMenu.ProcessKeyActionIfNeeded(e);
if (isProcessed)
e.Use();
}
protected override void RowGUI(RowGUIArgs args)
{
if (args.item is BranchListViewItem)
{
BranchListViewItem branchListViewItem = (BranchListViewItem)args.item;
BranchInfo branchInfo = (BranchInfo)branchListViewItem.ObjectInfo;
BranchesListViewItemGUI(
mQueryResult,
rowHeight,
branchListViewItem,
args,
branchInfo.BranchId == mLoadedBranchId,
Repaint);
return;
}
base.RowGUI(args);
}
protected override void DoubleClickedItem(int id)
{
if (GetSelection().Count != 1)
return;
mDoubleClickAction();
}
internal void BuildModel(
ViewQueryResult queryResult,
long loadedBranchId)
{
mListViewItemIds.Clear();
mQueryResult = queryResult;
mLoadedBranchId = loadedBranchId;
}
internal void Refilter()
{
if (mQueryResult == null)
return;
Filter filter = new Filter(searchString);
mQueryResult.ApplyFilter(filter, mColumnNames);
}
internal void Sort()
{
if (mQueryResult == null)
return;
int sortedColumnIdx = multiColumnHeader.state.sortedColumnIndex;
bool sortAscending = multiColumnHeader.IsSortedAscending(sortedColumnIdx);
mQueryResult.Sort(
mColumnNames[sortedColumnIdx],
sortAscending);
}
internal List<RepositorySpec> GetSelectedRepositories()
{
List<RepositorySpec> result = new List<RepositorySpec>();
IList<int> selectedIds = GetSelection();
if (selectedIds.Count == 0)
return result;
foreach (KeyValuePair<object, int> item
in mListViewItemIds.GetInfoItems())
{
if (!selectedIds.Contains(item.Value))
continue;
RepositorySpec repSpec =
mQueryResult.GetRepositorySpec(item.Key);
result.Add(repSpec);
}
return result;
}
internal List<RepObjectInfo> GetSelectedRepObjectInfos()
{
List<RepObjectInfo> result = new List<RepObjectInfo>();
IList<int> selectedIds = GetSelection();
if (selectedIds.Count == 0)
return result;
foreach (KeyValuePair<object, int> item
in mListViewItemIds.GetInfoItems())
{
if (!selectedIds.Contains(item.Value))
continue;
RepObjectInfo repObjectInfo =
mQueryResult.GetRepObjectInfo(item.Key);
result.Add(repObjectInfo);
}
return result;
}
internal void SelectRepObjectInfos(
List<RepObjectInfo> repObjectsToSelect)
{
List<int> idsToSelect = new List<int>();
foreach (RepObjectInfo repObjectInfo in repObjectsToSelect)
{
int repObjectInfoId = GetTreeIdForItem(repObjectInfo);
if (repObjectInfoId == -1)
continue;
idsToSelect.Add(repObjectInfoId);
}
TableViewOperations.SetSelectionAndScroll(this, idsToSelect);
}
int GetTreeIdForItem(RepObjectInfo repObjectInfo)
{
foreach (KeyValuePair<object, int> item in mListViewItemIds.GetInfoItems())
{
RepObjectInfo currentRepObjectInfo =
mQueryResult.GetRepObjectInfo(item.Key);
if (!currentRepObjectInfo.Equals(repObjectInfo))
continue;
if (!currentRepObjectInfo.GUID.Equals(repObjectInfo.GUID))
continue;
return item.Value;
}
return -1;
}
void DelayedSearchChanged()
{
Refilter();
Sort();
Reload();
TableViewOperations.ScrollToSelection(this);
}
void SortingChanged(MultiColumnHeader multiColumnHeader)
{
Sort();
Reload();
}
static void RegenerateRows(
ListViewItemIds<object> listViewItemIds,
List<object> objectInfos,
TreeViewItem rootItem,
List<TreeViewItem> rows)
{
ClearRows(rootItem, rows);
if (objectInfos.Count == 0)
return;
foreach (object objectInfo in objectInfos)
{
int objectId;
if (!listViewItemIds.TryGetInfoItemId(objectInfo, out objectId))
objectId = listViewItemIds.AddInfoItem(objectInfo);
BranchListViewItem branchListViewItem =
new BranchListViewItem(objectId, objectInfo);
rootItem.AddChild(branchListViewItem);
rows.Add(branchListViewItem);
}
}
static void ClearRows(
TreeViewItem rootItem,
List<TreeViewItem> rows)
{
if (rootItem.hasChildren)
rootItem.children.Clear();
rows.Clear();
}
static void BranchesListViewItemGUI(
ViewQueryResult queryResult,
float rowHeight,
BranchListViewItem item,
RowGUIArgs args,
bool isBoldText,
Action avatarLoadedAction)
{
for (int visibleColumnIdx = 0; visibleColumnIdx < args.GetNumVisibleColumns(); visibleColumnIdx++)
{
Rect cellRect = args.GetCellRect(visibleColumnIdx);
if (visibleColumnIdx == 0)
{
cellRect.x += UnityConstants.FIRST_COLUMN_WITHOUT_ICON_INDENT;
cellRect.width -= UnityConstants.FIRST_COLUMN_WITHOUT_ICON_INDENT;
}
BranchesListColumn column =
(BranchesListColumn)args.GetColumn(visibleColumnIdx);
BranchesListViewItemCellGUI(
cellRect,
rowHeight,
queryResult,
item,
column,
avatarLoadedAction,
args.selected,
args.focused,
isBoldText);
}
}
static void BranchesListViewItemCellGUI(
Rect rect,
float rowHeight,
ViewQueryResult queryResult,
BranchListViewItem item,
BranchesListColumn column,
Action avatarLoadedAction,
bool isSelected,
bool isFocused,
bool isBoldText)
{
string columnText = RepObjectInfoView.GetColumnText(
queryResult.GetRepositorySpec(item.ObjectInfo),
queryResult.GetRepObjectInfo(item.ObjectInfo),
BranchesListHeaderState.GetColumnName(column));
if (column == BranchesListColumn.CreatedBy)
{
DrawTreeViewItem.ForItemCell(
rect,
rowHeight,
-1,
GetAvatar.ForEmail(columnText, avatarLoadedAction),
null,
columnText,
isSelected,
isFocused,
isBoldText,
false);
return;
}
if (column == BranchesListColumn.Repository)
{
DrawTreeViewItem.ForSecondaryLabel(
rect, columnText, isSelected, isFocused, isBoldText);
return;
}
DrawTreeViewItem.ForLabel(
rect, columnText, isSelected, isFocused, isBoldText);
}
static bool IsSizeChanged(
Rect currentRect, Rect lastRect)
{
if (currentRect.width != lastRect.width)
return true;
if (currentRect.height != lastRect.height)
return true;
return false;
}
Rect mLastRect;
ListViewItemIds<object> mListViewItemIds = new ListViewItemIds<object>();
ViewQueryResult mQueryResult;
long mLoadedBranchId;
readonly CooldownWindowDelayer mCooldownFilterAction;
readonly Action mSizeChangedAction;
readonly Action mDoubleClickAction;
readonly BranchesViewMenu mMenu;
readonly List<string> mColumnNames;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b909cb14b9a08c45b5d03f0b61feecb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
using System.Collections.Generic;
using System.Linq;
using Codice.CM.Common;
using Unity.PlasticSCM.Editor.UI.Tree;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
internal static class BranchesSelection
{
internal static void SelectBranches(
BranchesListView listView,
List<RepObjectInfo> branchesToSelect,
int defaultRow)
{
if (branchesToSelect == null || branchesToSelect.Count == 0)
{
TableViewOperations.SelectFirstRow(listView);
return;
}
listView.SelectRepObjectInfos(branchesToSelect);
if (listView.HasSelection())
return;
TableViewOperations.SelectDefaultRow(listView, defaultRow);
if (listView.HasSelection())
return;
TableViewOperations.SelectFirstRow(listView);
}
internal static List<RepObjectInfo> GetSelectedRepObjectInfos(
BranchesListView listView)
{
return listView.GetSelectedRepObjectInfos();
}
internal static int GetSelectedBranchesCount(
BranchesListView listView)
{
return listView.GetSelection().Count;
}
internal static BranchInfo GetSelectedBranch(
BranchesListView listView)
{
List<RepObjectInfo> selectedRepObjectsInfos = listView.GetSelectedRepObjectInfos();
if (selectedRepObjectsInfos.Count == 0)
return null;
return (BranchInfo)selectedRepObjectsInfos[0];
}
internal static List<BranchInfo> GetSelectedBranches(
BranchesListView listView)
{
return listView.GetSelectedRepObjectInfos().Cast<BranchInfo>().ToList();
}
internal static RepositorySpec GetSelectedRepository(
BranchesListView listView)
{
List<RepositorySpec> selectedRepositories = listView.GetSelectedRepositories();
if (selectedRepositories.Count == 0)
return null;
return selectedRepositories[0];
}
internal static List<RepositorySpec> GetSelectedRepositories(
BranchesListView listView)
{
return listView.GetSelectedRepositories();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73306fe71bf092d4495ff28ee02b766b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,655 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using Codice.Client.Common.EventTracking;
using Codice.Client.Common.Threading;
using Codice.CM.Common;
using GluonGui;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using PlasticGui.WorkspaceWindow.CodeReview;
using PlasticGui.WorkspaceWindow.QueryViews;
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
using PlasticGui.WorkspaceWindow.Update;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.AssetUtils.Processor;
using Unity.PlasticSCM.Editor.Tool;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Progress;
using Unity.PlasticSCM.Editor.UI.Tree;
using Unity.PlasticSCM.Editor.Views.Branches.Dialogs;
using Unity.PlasticSCM.Editor.Views.Changesets;
using GluonNewIncomingChangesUpdater = PlasticGui.Gluon.WorkspaceWindow.NewIncomingChangesUpdater;
using IGluonUpdateReport = PlasticGui.Gluon.IUpdateReport;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
internal partial class BranchesTab :
IRefreshableView,
IQueryRefreshableView,
IBranchMenuOperations,
ILaunchCodeReviewWindow
{
internal bool ShowHiddenBranchesForTesting { set { mShowHiddenBranches = value; } }
internal string EmptyStateMessage { get { return mEmptyStateData.Content.text; } }
internal BranchesListView Table { get { return mBranchesListView; } }
internal IBranchMenuOperations Operations { get { return this; } }
internal BranchesTab(
WorkspaceInfo wkInfo,
WorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IMergeViewLauncher mergeViewLauncher,
ViewHost viewHost,
IUpdateReport updateReport,
IGluonUpdateReport gluonUpdateReport,
NewIncomingChangesUpdater developerNewIncomingChangesUpdater,
GluonNewIncomingChangesUpdater gluonNewIncomingChangesUpdater,
IShelvedChangesUpdater shelvedChangesUpdater,
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
LaunchTool.IProcessExecutor processExecutor,
WorkspaceOperationsMonitor workspaceOperationsMonitor,
ISaveAssets saveAssets,
EditorWindow parentWindow,
bool isGluonMode,
bool showHiddenBranches)
{
mWkInfo = wkInfo;
mParentWindow = parentWindow;
mGluonUpdateReport = gluonUpdateReport;
mViewHost = viewHost;
mWorkspaceWindow = workspaceWindow;
mIsGluonMode = isGluonMode;
mShowHiddenBranches = showHiddenBranches;
mProgressControls = new ProgressControlsForViews();
mDeveloperNewIncomingChangesUpdater = developerNewIncomingChangesUpdater;
mGluonNewIncomingChangesUpdater = gluonNewIncomingChangesUpdater;
mShelvedChangesUpdater = shelvedChangesUpdater;
mShowDownloadPlasticExeWindow = showDownloadPlasticExeWindow;
mProcessExecutor = processExecutor;
mWorkspaceOperationsMonitor = workspaceOperationsMonitor;
mSaveAssets = saveAssets;
mShelvePendingChangesQuestionerBuilder =
new ShelvePendingChangesQuestionerBuilder(parentWindow);
mEnableSwitchAndShelveFeatureDialog = new EnableSwitchAndShelveFeature(
PlasticGui.Plastic.API.GetRepositorySpec(mWkInfo),
mParentWindow);
BuildComponents(
wkInfo,
workspaceWindow,
viewSwitcher,
mergeViewLauncher,
updateReport,
developerNewIncomingChangesUpdater,
shelvedChangesUpdater,
mShelvePendingChangesQuestionerBuilder,
mEnableSwitchAndShelveFeatureDialog,
parentWindow);
((IRefreshableView)this).Refresh();
}
internal void OnEnable()
{
mSearchField.downOrUpArrowKeyPressed +=
SearchField_OnDownOrUpArrowKeyPressed;
}
internal void OnDisable()
{
mSearchField.downOrUpArrowKeyPressed -=
SearchField_OnDownOrUpArrowKeyPressed;
TreeHeaderSettings.Save(
mBranchesListView.multiColumnHeader.state,
UnityConstants.BRANCHES_TABLE_SETTINGS_NAME);
}
internal SerializableBranchesTabState GetSerializableState()
{
return new SerializableBranchesTabState(mShowHiddenBranches);
}
internal void Update()
{
mProgressControls.UpdateProgress(mParentWindow);
}
internal void OnGUI()
{
DoActionsToolbar(mProgressControls);
DoBranchesArea(
mBranchesListView,
mEmptyStateData,
mProgressControls.IsOperationRunning(),
mShowHiddenBranches,
HasFiltersApplied(mDateFilter, mBranchesListView),
mParentWindow.Repaint);
}
internal void DrawSearchFieldForTab()
{
DrawSearchField.For(
mSearchField,
mBranchesListView,
UnityConstants.SEARCH_FIELD_WIDTH);
}
internal void DrawShowHiddenBranchesButton()
{
GUI.enabled = !mProgressControls.IsOperationRunning();
EditorGUI.BeginChangeCheck();
mShowHiddenBranches = GUILayout.Toggle(
mShowHiddenBranches,
new GUIContent(
mShowHiddenBranches ?
Images.GetUnhideIcon() :
Images.GetHideIcon(),
mShowHiddenBranches ?
PlasticLocalization.Name.DontShowHiddenBranchesTooltip.GetString() :
PlasticLocalization.Name.ShowHiddenBranchesTooltip.GetString()),
EditorStyles.toolbarButton,
GUILayout.Width(26));
if (EditorGUI.EndChangeCheck())
{
TrackFeatureUseEvent.For(
BranchesSelection.GetSelectedRepository(mBranchesListView),
TrackFeatureUseEvent.Features.Branches.ToggleShowHiddenBranches);
((IRefreshableView)this).Refresh();
}
GUI.enabled = true;
}
internal void DrawDateFilter()
{
GUI.enabled = !mProgressControls.IsOperationRunning();
EditorGUI.BeginChangeCheck();
mDateFilter.FilterType = (DateFilter.Type)
EditorGUILayout.EnumPopup(
mDateFilter.FilterType,
EditorStyles.toolbarDropDown,
GUILayout.Width(100));
if (EditorGUI.EndChangeCheck())
{
EnumPopupSetting<DateFilter.Type>.Save(
mDateFilter.FilterType,
UnityConstants.BRANCHES_DATE_FILTER_SETTING_NAME);
((IRefreshableView)this).Refresh();
}
GUI.enabled = true;
}
internal void SetWorkingObjectInfo(WorkingObjectInfo homeInfo)
{
lock (mLock)
{
mLoadedBranchId = homeInfo.BranchInfo.BranchId;
}
mBranchesListView.SetLoadedBranchId(mLoadedBranchId);
}
internal void SetLaunchToolForTesting(
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
LaunchTool.IProcessExecutor processExecutor)
{
mShowDownloadPlasticExeWindow = showDownloadPlasticExeWindow;
mProcessExecutor = processExecutor;
}
void IRefreshableView.Refresh()
{
// VCS-1005209 - There are scenarios where the list of branches need to check for incoming changes.
// For example, deleting the active branch will automatically switch your workspace to the parent changeset,
// which might have incoming changes.
if (mDeveloperNewIncomingChangesUpdater != null)
mDeveloperNewIncomingChangesUpdater.Update(DateTime.Now);
if (mGluonNewIncomingChangesUpdater != null)
mGluonNewIncomingChangesUpdater.Update(DateTime.Now);
string query = QueryConstants.BuildBranchesQuery(
mDateFilter.GetLayoutFilter(), mShowHiddenBranches);
FillBranches(mWkInfo, query, BranchesSelection.
GetSelectedRepObjectInfos(mBranchesListView));
}
//IQueryRefreshableView
public void RefreshAndSelect(RepObjectInfo repObj)
{
string query = QueryConstants.BuildBranchesQuery(
mDateFilter.GetLayoutFilter(), mShowHiddenBranches);
FillBranches(mWkInfo, query, new List<RepObjectInfo> { repObj });
}
BranchInfo IBranchMenuOperations.GetSelectedBranch()
{
return BranchesSelection.GetSelectedBranch(mBranchesListView);
}
int IBranchMenuOperations.GetSelectedBranchesCount()
{
return BranchesSelection.GetSelectedBranchesCount(mBranchesListView);
}
bool IBranchMenuOperations.AreHiddenBranchesShown()
{
return mShowHiddenBranches;
}
void IBranchMenuOperations.CreateBranch()
{
CreateBranchForMode();
}
void IBranchMenuOperations.CreateTopLevelBranch() { }
void IBranchMenuOperations.SwitchToBranch()
{
SwitchToBranchForMode();
}
void IBranchMenuOperations.MergeBranch()
{
mBranchOperations.MergeBranch(
BranchesSelection.GetSelectedRepository(mBranchesListView),
BranchesSelection.GetSelectedBranch(mBranchesListView));
}
void IBranchMenuOperations.CherrypickBranch() { }
void IBranchMenuOperations.MergeToBranch() { }
void IBranchMenuOperations.PullBranch() { }
void IBranchMenuOperations.PullRemoteBranch() { }
void IBranchMenuOperations.SyncWithGit() { }
void IBranchMenuOperations.PushBranch() { }
void IBranchMenuOperations.DiffBranch()
{
LaunchDiffOperations.DiffBranch(
mShowDownloadPlasticExeWindow,
mProcessExecutor,
BranchesSelection.GetSelectedRepository(mBranchesListView),
BranchesSelection.GetSelectedBranch(mBranchesListView),
mIsGluonMode);
}
void IBranchMenuOperations.DiffWithAnotherBranch() { }
void IBranchMenuOperations.ViewChangesets() { }
void IBranchMenuOperations.RenameBranch()
{
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
BranchRenameData branchRenameData = RenameBranchDialog.GetBranchRenameData(
repSpec,
branchInfo,
mParentWindow);
mBranchOperations.RenameBranch(branchRenameData);
}
void IBranchMenuOperations.HideUnhideBranch()
{
if (mShowHiddenBranches)
{
mBranchOperations.UnhideBranch(
BranchesSelection.GetSelectedRepositories(mBranchesListView),
BranchesSelection.GetSelectedBranches(mBranchesListView));
return;
}
mBranchOperations.HideBranch(
BranchesSelection.GetSelectedRepositories(mBranchesListView),
BranchesSelection.GetSelectedBranches(mBranchesListView));
}
void IBranchMenuOperations.DeleteBranch()
{
var branchesToDelete = BranchesSelection.GetSelectedBranches(mBranchesListView);
if (!DeleteBranchDialog.ConfirmDelete(branchesToDelete))
return;
mBranchOperations.DeleteBranch(
BranchesSelection.GetSelectedRepositories(mBranchesListView),
branchesToDelete,
DeleteBranchOptions.IncludeChangesets,
!mShowHiddenBranches);
}
void IBranchMenuOperations.CreateCodeReview()
{
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
NewCodeReviewBehavior choice = SelectNewCodeReviewBehavior.For(repSpec.Server);
switch (choice)
{
case NewCodeReviewBehavior.CreateAndOpenInDesktop:
mBranchOperations.CreateCodeReview(repSpec, branchInfo, this);
break;
case NewCodeReviewBehavior.RequestFromUnityCloud:
OpenRequestReviewPage.ForBranch(repSpec, branchInfo.BranchId);
break;
case NewCodeReviewBehavior.Ask:
default:
break;
}
}
void ILaunchCodeReviewWindow.Show(
WorkspaceInfo wkInfo,
RepositorySpec repSpec,
ReviewInfo reviewInfo,
RepObjectInfo repObjectInfo,
bool bShowReviewChangesTab)
{
LaunchTool.OpenCodeReview(
mShowDownloadPlasticExeWindow,
mProcessExecutor,
repSpec,
reviewInfo.Id,
mIsGluonMode);
}
void IBranchMenuOperations.ViewPermissions() { }
void SearchField_OnDownOrUpArrowKeyPressed()
{
mBranchesListView.SetFocusAndEnsureSelectedItem();
}
void OnBranchesListViewSizeChanged()
{
if (!mShouldScrollToSelection)
return;
mShouldScrollToSelection = false;
TableViewOperations.ScrollToSelection(mBranchesListView);
}
void FillBranches(
WorkspaceInfo wkInfo,
string query,
List<RepObjectInfo> branchesToSelect)
{
if (mIsRefreshing)
return;
mIsRefreshing = true;
int defaultRow = TableViewOperations.
GetFirstSelectedRow(mBranchesListView);
((IProgressControls)mProgressControls).ShowProgress(
PlasticLocalization.GetString(
PlasticLocalization.Name.LoadingBranches));
ViewQueryResult queryResult = null;
IThreadWaiter waiter = ThreadWaiter.GetWaiter();
waiter.Execute(
/*threadOperationDelegate*/ delegate
{
long loadedBranchId = GetLoadedBranchId(wkInfo);
lock(mLock)
{
mLoadedBranchId = loadedBranchId;
}
queryResult = new ViewQueryResult(
PlasticGui.Plastic.API.FindQuery(wkInfo, query));
},
/*afterOperationDelegate*/ delegate
{
try
{
if (waiter.Exception != null)
{
ExceptionsHandler.DisplayException(waiter.Exception);
return;
}
UpdateBranchesList(
mBranchesListView,
queryResult,
mLoadedBranchId);
int branchesCount = GetBranchesCount(queryResult);
if (branchesCount == 0)
{
return;
}
BranchesSelection.SelectBranches(
mBranchesListView, branchesToSelect, defaultRow);
}
finally
{
((IProgressControls)mProgressControls).HideProgress();
mIsRefreshing = false;
}
});
}
static void UpdateBranchesList(
BranchesListView branchesListView,
ViewQueryResult queryResult,
long loadedBranchId)
{
branchesListView.BuildModel(
queryResult, loadedBranchId);
branchesListView.Refilter();
branchesListView.Sort();
branchesListView.Reload();
}
static string GetEmptyStateMessage(
BranchesListView branchesListView,
bool isOperationRunning,
bool showHiddenBranches,
bool hasFiltersApplied)
{
if (isOperationRunning ||
branchesListView.GetRows().Count > 0)
return string.Empty;
if (!showHiddenBranches)
return PlasticLocalization.Name.BranchesEmptyState.GetString();
return hasFiltersApplied ?
PlasticLocalization.Name.HiddenBranchesEmptyState.GetString() :
PlasticLocalization.Name.HiddenBranchesInRepositoryEmptyState.GetString();
}
static long GetLoadedBranchId(WorkspaceInfo wkInfo)
{
BranchInfo brInfo = PlasticGui.Plastic.API.GetWorkingBranch(wkInfo);
if (brInfo != null)
return brInfo.BranchId;
return -1;
}
static int GetBranchesCount(
ViewQueryResult queryResult)
{
if (queryResult == null)
return 0;
return queryResult.Count();
}
static bool HasFiltersApplied(
DateFilter dateFilter,
BranchesListView branchesListView)
{
return dateFilter.FilterType != DateFilter.Type.AllTime
|| branchesListView.searchString != string.Empty;
}
static void DoActionsToolbar(ProgressControlsForViews progressControls)
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
if (progressControls.IsOperationRunning())
{
DrawProgressForViews.ForIndeterminateProgress(
progressControls.ProgressData);
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
static void DoBranchesArea(
BranchesListView branchesListView,
EmptyStateData emptyStateData,
bool isOperationRunning,
bool showHiddenBranches,
bool hasFiltersApplied,
Action repaint)
{
EditorGUILayout.BeginVertical();
GUI.enabled = !isOperationRunning;
Rect rect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
branchesListView.OnGUI(rect);
emptyStateData.Update(
GetEmptyStateMessage(
branchesListView,
isOperationRunning,
showHiddenBranches,
hasFiltersApplied),
rect, Event.current.type, repaint);
if (!emptyStateData.IsEmpty())
DrawTreeViewEmptyState.For(emptyStateData);
GUI.enabled = true;
EditorGUILayout.EndVertical();
}
void BuildComponents(
WorkspaceInfo wkInfo,
IWorkspaceWindow workspaceWindow,
IViewSwitcher viewSwitcher,
IMergeViewLauncher mergeViewLauncher,
IUpdateReport updateReport,
NewIncomingChangesUpdater developerNewIncomingChangesUpdater,
IShelvedChangesUpdater shelvedChangesUpdater,
IShelvePendingChangesQuestionerBuilder shelvePendingChangesQuestionerBuilder,
SwitchAndShelve.IEnableSwitchAndShelveFeatureDialog enableSwitchAndShelveFeatureDialog,
EditorWindow parentWindow)
{
mSearchField = new SearchField();
mSearchField.downOrUpArrowKeyPressed += SearchField_OnDownOrUpArrowKeyPressed;
DateFilter.Type dateFilterType =
EnumPopupSetting<DateFilter.Type>.Load(
UnityConstants.BRANCHES_DATE_FILTER_SETTING_NAME,
DateFilter.Type.LastMonth);
mDateFilter = new DateFilter(dateFilterType);
BranchesListHeaderState headerState =
BranchesListHeaderState.GetDefault();
TreeHeaderSettings.Load(headerState,
UnityConstants.BRANCHES_TABLE_SETTINGS_NAME,
(int)BranchesListColumn.CreationDate, false);
mBranchesListView = new BranchesListView(
headerState,
BranchesListHeaderState.GetColumnNames(),
new BranchesViewMenu(this, mGluonNewIncomingChangesUpdater != null),
sizeChangedAction: OnBranchesListViewSizeChanged,
doubleClickAction: ((IBranchMenuOperations)this).DiffBranch);
mBranchesListView.Reload();
mBranchOperations = new BranchOperations(
wkInfo,
workspaceWindow,
mergeViewLauncher,
this,
ViewType.BranchesView,
mProgressControls,
updateReport,
new ContinueWithPendingChangesQuestionerBuilder(viewSwitcher, parentWindow),
shelvePendingChangesQuestionerBuilder,
new ApplyShelveWithConflictsQuestionerBuilder(),
developerNewIncomingChangesUpdater,
shelvedChangesUpdater,
enableSwitchAndShelveFeatureDialog);
}
bool mIsRefreshing;
bool mShowHiddenBranches;
bool mShouldScrollToSelection;
long mLoadedBranchId = -1;
object mLock = new object();
SearchField mSearchField;
DateFilter mDateFilter;
BranchesListView mBranchesListView;
BranchOperations mBranchOperations;
LaunchTool.IProcessExecutor mProcessExecutor;
LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow;
readonly EmptyStateData mEmptyStateData = new EmptyStateData();
readonly WorkspaceInfo mWkInfo;
readonly EditorWindow mParentWindow;
readonly ISaveAssets mSaveAssets;
readonly IGluonUpdateReport mGluonUpdateReport;
readonly WorkspaceWindow mWorkspaceWindow;
readonly ViewHost mViewHost;
readonly bool mIsGluonMode;
readonly ProgressControlsForViews mProgressControls;
readonly NewIncomingChangesUpdater mDeveloperNewIncomingChangesUpdater;
readonly GluonNewIncomingChangesUpdater mGluonNewIncomingChangesUpdater;
readonly IShelvedChangesUpdater mShelvedChangesUpdater;
readonly WorkspaceOperationsMonitor mWorkspaceOperationsMonitor;
readonly IShelvePendingChangesQuestionerBuilder mShelvePendingChangesQuestionerBuilder;
readonly SwitchAndShelve.IEnableSwitchAndShelveFeatureDialog mEnableSwitchAndShelveFeatureDialog;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2350e7d7f6d79024da24dea8f15a6881
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,122 @@
using Codice.CM.Common;
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.Branches.Dialogs;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
internal partial class BranchesTab
{
void SwitchToBranchForMode()
{
bool isCancelled;
mSaveAssets.UnderWorkspaceWithConfirmation(
mWkInfo.ClientPath, mWorkspaceOperationsMonitor,
out isCancelled);
if (isCancelled)
return;
if (mIsGluonMode)
{
SwitchToBranchForGluon();
return;
}
SwitchToBranchForDeveloper();
}
void SwitchToBranchForDeveloper()
{
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
mBranchOperations.SwitchToBranch(
repSpec,
branchInfo,
RefreshAsset.BeforeLongAssetOperation,
items => RefreshAsset.AfterLongAssetOperation(
ProjectPackages.ShouldBeResolvedFromUpdateReport(mWkInfo, items)));
}
void SwitchToBranchForGluon()
{
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
new SwitchToUIOperation().SwitchToBranch(
mWkInfo,
branchInfo,
mViewHost,
mGluonNewIncomingChangesUpdater,
new UnityPlasticGuiMessage(),
mProgressControls,
mWorkspaceWindow.GluonProgressOperationHandler,
mGluonUpdateReport,
mWorkspaceWindow,
mShelvePendingChangesQuestionerBuilder,
mShelvedChangesUpdater,
mEnableSwitchAndShelveFeatureDialog,
RefreshAsset.BeforeLongAssetOperation,
items => RefreshAsset.AfterLongAssetOperation(
ProjectPackages.ShouldBeResolvedFromPaths(mWkInfo, items)));
}
void CreateBranchForMode()
{
if (mIsGluonMode)
{
CreateBranchForGluon();
return;
}
CreateBranchForDeveloper();
}
void CreateBranchForDeveloper()
{
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
BranchCreationData branchCreationData = CreateBranchDialog.CreateBranchFromLastParentBranchChangeset(
mParentWindow,
repSpec,
branchInfo);
mBranchOperations.CreateBranch(
branchCreationData,
RefreshAsset.BeforeLongAssetOperation,
items => RefreshAsset.AfterLongAssetOperation(
ProjectPackages.ShouldBeResolvedFromUpdateReport(mWkInfo, items)));
}
void CreateBranchForGluon()
{
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
BranchCreationData branchCreationData = CreateBranchDialog.CreateBranchFromLastParentBranchChangeset(
mParentWindow,
repSpec,
branchInfo);
CreateBranchOperation.CreateBranch(
mWkInfo,
branchCreationData,
mViewHost,
mGluonNewIncomingChangesUpdater,
new UnityPlasticGuiMessage(),
mProgressControls,
mWorkspaceWindow.GluonProgressOperationHandler,
mGluonUpdateReport,
mWorkspaceWindow,
mShelvePendingChangesQuestionerBuilder,
mShelvedChangesUpdater,
mEnableSwitchAndShelveFeatureDialog,
RefreshAsset.BeforeLongAssetOperation,
items => RefreshAsset.AfterLongAssetOperation(
ProjectPackages.ShouldBeResolvedFromPaths(mWkInfo, items)));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 732707d2b1ec963458b4ab9ffe539cbe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,282 @@
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
internal class BranchesViewMenu
{
internal GenericMenu Menu { get { return mMenu; } }
internal BranchesViewMenu(
IBranchMenuOperations branchMenuOperations,
bool isGluonMode)
{
mBranchMenuOperations = branchMenuOperations;
mIsGluonMode = isGluonMode;
BuildComponents();
}
internal void Popup()
{
mMenu = new GenericMenu();
UpdateMenuItems(mMenu);
mMenu.ShowAsContext();
}
internal bool ProcessKeyActionIfNeeded(Event e)
{
BranchMenuOperations operationToExecute = GetMenuOperations(e);
if (operationToExecute == BranchMenuOperations.None)
return false;
BranchMenuOperations operations =
BranchMenuUpdater.GetAvailableMenuOperations(
mBranchMenuOperations.GetSelectedBranchesCount(),
mIsGluonMode,
false);
if (!operations.HasFlag(operationToExecute))
return false;
ProcessMenuOperation(operationToExecute, mBranchMenuOperations);
return true;
}
void CreateBranchMenuItem_Click()
{
mBranchMenuOperations.CreateBranch();
}
void SwitchToBranchMenuItem_Click()
{
mBranchMenuOperations.SwitchToBranch();
}
void RenameBranchMenuItem_Click()
{
mBranchMenuOperations.RenameBranch();
}
void HideUnhideBranchMenuItem_Click()
{
mBranchMenuOperations.HideUnhideBranch();
}
void DeleteBranchMenuItem_Click()
{
mBranchMenuOperations.DeleteBranch();
}
void MergeBranchMenuItem_Click()
{
mBranchMenuOperations.MergeBranch();
}
void DiffBranchMenuItem_Click()
{
mBranchMenuOperations.DiffBranch();
}
void CreateCodeReviewMenuItem_Click()
{
mBranchMenuOperations.CreateCodeReview();
}
void UpdateMenuItems(GenericMenu menu)
{
BranchInfo singleSelectedBranch = mBranchMenuOperations.GetSelectedBranch();
BranchMenuOperations operations = BranchMenuUpdater.GetAvailableMenuOperations(
mBranchMenuOperations.GetSelectedBranchesCount(), mIsGluonMode, false);
AddBranchMenuItem(
mCreateBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.CreateBranch,
CreateBranchMenuItem_Click);
AddBranchMenuItem(
mSwitchToBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.SwitchToBranch,
SwitchToBranchMenuItem_Click);
if (!mIsGluonMode)
{
menu.AddSeparator(string.Empty);
AddBranchMenuItem(
mMergeBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.MergeBranch,
MergeBranchMenuItem_Click);
}
menu.AddSeparator(string.Empty);
mDiffBranchMenuItemContent.text = string.Format("{0} {1}",
PlasticLocalization.Name.DiffBranchMenuItem.GetString(
GetShorten.BranchNameFromBranch(singleSelectedBranch)),
GetPlasticShortcut.ForDiff());
AddBranchMenuItem(
mDiffBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.DiffBranch,
DiffBranchMenuItem_Click);
menu.AddSeparator(string.Empty);
AddBranchMenuItem(
mRenameBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.Rename,
RenameBranchMenuItem_Click);
mHideUnhideBranchMenuItemContent.text = string.Format("{0} {1}",
mBranchMenuOperations.AreHiddenBranchesShown() ?
PlasticLocalization.Name.BranchMenuItemUnhideBranch.GetString() :
PlasticLocalization.Name.BranchMenuItemHideBranch.GetString(),
GetPlasticShortcut.ForHideUnhide());
AddBranchMenuItem(
mHideUnhideBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.HideUnhide,
HideUnhideBranchMenuItem_Click);
AddBranchMenuItem(
mDeleteBranchMenuItemContent,
menu,
operations,
BranchMenuOperations.Delete,
DeleteBranchMenuItem_Click);
menu.AddSeparator(string.Empty);
AddBranchMenuItem(
mCreateCodeReviewMenuItemContent,
menu,
operations,
BranchMenuOperations.CreateCodeReview,
CreateCodeReviewMenuItem_Click);
}
static void AddBranchMenuItem(
GUIContent menuItemContent,
GenericMenu menu,
BranchMenuOperations operations,
BranchMenuOperations operationsToCheck,
GenericMenu.MenuFunction menuFunction)
{
if (operations.HasFlag(operationsToCheck))
{
menu.AddItem(
menuItemContent,
false,
menuFunction);
return;
}
menu.AddDisabledItem(menuItemContent);
}
static void ProcessMenuOperation(
BranchMenuOperations operationToExecute,
IBranchMenuOperations branchMenuOperations)
{
if (operationToExecute == BranchMenuOperations.Delete)
{
branchMenuOperations.DeleteBranch();
return;
}
if (operationToExecute == BranchMenuOperations.MergeBranch)
{
branchMenuOperations.MergeBranch();
return;
}
if (operationToExecute == BranchMenuOperations.DiffBranch)
{
branchMenuOperations.DiffBranch();
return;
}
if (operationToExecute == BranchMenuOperations.HideUnhide)
{
branchMenuOperations.HideUnhideBranch();
return;
}
}
static BranchMenuOperations GetMenuOperations(Event e)
{
if (Keyboard.IsKeyPressed(e, KeyCode.Delete))
return BranchMenuOperations.Delete;
if (Keyboard.IsControlOrCommandKeyPressed(e) &&
Keyboard.IsKeyPressed(e, KeyCode.M))
return BranchMenuOperations.MergeBranch;
if (Keyboard.IsControlOrCommandKeyPressed(e) &&
Keyboard.IsKeyPressed(e, KeyCode.D))
return BranchMenuOperations.DiffBranch;
if (Keyboard.IsControlOrCommandKeyPressed(e) &&
Keyboard.IsKeyPressed(e, KeyCode.H))
return BranchMenuOperations.HideUnhide;
return BranchMenuOperations.None;
}
void BuildComponents()
{
mCreateBranchMenuItemContent = new GUIContent(
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemCreateBranch));
mSwitchToBranchMenuItemContent = new GUIContent(
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemSwitchToBranch));
mMergeBranchMenuItemContent = new GUIContent(string.Format("{0} {1}",
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemMergeFromBranch),
GetPlasticShortcut.ForMerge()));
mDiffBranchMenuItemContent = new GUIContent();
mRenameBranchMenuItemContent = new GUIContent(
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemRenameBranch));
mHideUnhideBranchMenuItemContent = new GUIContent();
mDeleteBranchMenuItemContent = new GUIContent(string.Format("{0} {1}",
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemDeleteBranch),
GetPlasticShortcut.ForDelete()));
mCreateCodeReviewMenuItemContent = new GUIContent(
PlasticLocalization.Name.BranchMenuCreateANewCodeReview.GetString());
}
GenericMenu mMenu;
GUIContent mCreateBranchMenuItemContent;
GUIContent mSwitchToBranchMenuItemContent;
GUIContent mMergeBranchMenuItemContent;
GUIContent mDiffBranchMenuItemContent;
GUIContent mRenameBranchMenuItemContent;
GUIContent mHideUnhideBranchMenuItemContent;
GUIContent mDeleteBranchMenuItemContent;
GUIContent mCreateCodeReviewMenuItemContent;
readonly IBranchMenuOperations mBranchMenuOperations;
readonly bool mIsGluonMode;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1f5156c89fd104459e8ec0cc3098899
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 16e16045695760047a9bd172458c5d6b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,226 @@
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using Codice.Client.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Progress;
namespace Unity.PlasticSCM.Editor.Views.Branches.Dialogs
{
class CreateBranchDialog : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
return new Rect(baseRect.x, baseRect.y, 710, 290);
}
}
protected override string GetTitle()
{
return PlasticLocalization.Name.CreateChildBranchTitle.GetString();
}
protected override void OnModalGUI()
{
DoTitleArea();
DoFieldsArea();
DoButtonsArea();
}
internal static BranchCreationData CreateBranchFromLastParentBranchChangeset(
EditorWindow parentWindow,
RepositorySpec repSpec,
BranchInfo parentBranchInfo)
{
string changesetStr = PlasticLocalization.Name.LastChangeset.GetString();
string explanation = BranchCreationUserInfo.GetFromObjectString(
repSpec, parentBranchInfo, changesetStr);
CreateBranchDialog dialog = Create(repSpec, parentBranchInfo, -1 , explanation);
ResponseType dialogueResult = dialog.RunModal(parentWindow);
BranchCreationData result = dialog.BuildCreationData();
result.Result = dialogueResult == ResponseType.Ok;
return result;
}
internal static BranchCreationData CreateBranchFromChangeset(
EditorWindow parentWindow,
RepositorySpec repSpec,
ChangesetExtendedInfo changesetInfo)
{
BranchInfo parentBranchInfo = BranchInfoCache.GetBranch(
repSpec, changesetInfo.BranchId);
string changesetStr = SpecPreffix.CHANGESET + changesetInfo.ChangesetId.ToString();
string explanation = BranchCreationUserInfo.GetFromObjectString(
repSpec, parentBranchInfo, changesetStr);
CreateBranchDialog dialog = Create(repSpec, parentBranchInfo, changesetInfo.ChangesetId, explanation);
ResponseType dialogueResult = dialog.RunModal(parentWindow);
BranchCreationData result = dialog.BuildCreationData();
result.Result = dialogueResult == ResponseType.Ok;
return result;
}
void DoTitleArea()
{
GUILayout.BeginVertical();
Title(PlasticLocalization.Name.CreateChildBranchTitle.GetString());
GUILayout.Space(5);
Paragraph(string.Format("{0} {1}",
PlasticLocalization.Name.CreateChildBranchExplanation.GetString(), mExplanation));
GUILayout.EndVertical();
}
void DoFieldsArea()
{
GUILayout.BeginVertical();
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label(
PlasticLocalization.Name.BranchNameEntry.GetString(),
GUILayout.Width(100));
GUI.SetNextControlName(NAME_FIELD_CONTROL_NAME);
mNewBranchName = GUILayout.TextField(mNewBranchName);
if (!mWasNameFieldFocused)
{
EditorGUI.FocusTextInControl(NAME_FIELD_CONTROL_NAME);
mWasNameFieldFocused = true;
}
GUILayout.Space(5);
}
GUILayout.Space(5);
using (new EditorGUILayout.HorizontalScope())
{
using (new EditorGUILayout.VerticalScope(GUILayout.Width(100)))
{
GUILayout.Space(49);
GUILayout.Label(
PlasticLocalization.Name.CommentsEntry.GetString(),
GUILayout.Width(100));
}
GUI.SetNextControlName(COMMENT_TEXTAREA_CONTROL_NAME);
mComment = GUILayout.TextArea(mComment, GUILayout.Height(100));
GUILayout.Space(5);
}
GUILayout.Space(5);
mSwitchToBranch = GUILayout.Toggle(mSwitchToBranch, PlasticLocalization.Name.SwitchToBranchCheckButton.GetString());
GUILayout.Space(5);
GUILayout.EndVertical();
}
void DoButtonsArea()
{
using (new EditorGUILayout.HorizontalScope())
{
using (new EditorGUILayout.HorizontalScope(GUILayout.MinWidth(500)))
{
GUILayout.Space(2);
DrawProgressForDialogs.For(
mProgressControls.ProgressData);
GUILayout.Space(2);
}
GUILayout.FlexibleSpace();
DoCreateButton();
DoCancelButton();
}
}
void DoCancelButton()
{
if (!NormalButton(PlasticLocalization.Name.CancelButton.GetString()))
return;
CancelButtonAction();
}
void DoCreateButton()
{
if (!NormalButton(PlasticLocalization.Name.CreateButton.GetString()))
return;
CreateButtonAction();
}
void CreateButtonAction()
{
BranchCreationValidation.AsyncValidation(
BuildCreationData(), this, mProgressControls);
}
static CreateBranchDialog Create(
RepositorySpec repSpec, BranchInfo parentBranchInfo, long changesetId, string explanation)
{
var instance = CreateInstance<CreateBranchDialog>();
instance.IsResizable = false;
instance.mEnterKeyAction = instance.CreateButtonAction;
instance.AddControlConsumingEnterKey(COMMENT_TEXTAREA_CONTROL_NAME);
instance.mEscapeKeyAction = instance.CloseButtonAction;
instance.mRepositorySpec = repSpec;
instance.mParentBranchInfo = parentBranchInfo;
instance.mNewBranchName = "";
instance.mComment = "";
instance.mSwitchToBranch = true;
instance.mProgressControls = new ProgressControlsForDialogs();
instance.mExplanation = explanation;
instance.mChangesetId = changesetId;
return instance;
}
BranchCreationData BuildCreationData()
{
return new BranchCreationData(
mRepositorySpec,
mParentBranchInfo,
mChangesetId,
mNewBranchName,
mComment,
null,
mSwitchToBranch);
}
ProgressControlsForDialogs mProgressControls;
RepositorySpec mRepositorySpec;
BranchInfo mParentBranchInfo;
long mChangesetId;
string mNewBranchName;
string mComment;
bool mSwitchToBranch;
string mExplanation;
bool mWasNameFieldFocused;
const string NAME_FIELD_CONTROL_NAME = "CreateBranchNameField";
const string COMMENT_TEXTAREA_CONTROL_NAME = "CreateBranchCommentTextArea";
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a0fc5252a48d8b34f945b4ae3ad45030
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using PlasticGui;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Views.Branches.Dialogs
{
internal class DeleteBranchDialog : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
var increaseFactor = mNumberOfBranches <= MAX_ITEMS_TO_SHOW ?
TEXT_LINE_HEIGHT * mNumberOfBranches :
TEXT_LINE_HEIGHT * (MAX_ITEMS_TO_SHOW + 1);
return new Rect(baseRect.x, baseRect.y, baseRect.width, baseRect.height + increaseFactor);
}
}
internal static bool ConfirmDelete(IList<BranchInfo> branches)
{
DeleteBranchDialog dialog = Create(branches);
return dialog.RunModal(null) == ResponseType.Ok;
}
protected override string GetTitle()
{
return mTitle;
}
protected override void OnModalGUI()
{
Paragraph(mMessage);
GUILayout.Space(5);
DoButtonsArea();
}
void DoButtonsArea()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
mConfirmDelete = ToggleEntry(
PlasticLocalization.Name.ConfirmationCheckBox.GetString(),
mConfirmDelete);
GUILayout.Space(10);
if (Application.platform == RuntimePlatform.WindowsEditor)
{
DoDeleteButton();
DoCancelButton();
return;
}
DoCancelButton();
DoDeleteButton();
}
}
void DoCancelButton()
{
if (!NormalButton(PlasticLocalization.Name.NoButton.GetString()))
return;
CancelButtonAction();
}
void DoDeleteButton()
{
GUI.enabled = IsDeleteButtonEnabled();
if (NormalButton(PlasticLocalization.Name.DeleteButton.GetString()))
DeleteButtonAction();
GUI.enabled = true;
}
void DeleteButtonAction()
{
if (!IsDeleteButtonEnabled())
return;
OkButtonAction();
}
bool IsDeleteButtonEnabled()
{
return mConfirmDelete;
}
static DeleteBranchDialog Create(IList<BranchInfo> branches)
{
var instance = CreateInstance<DeleteBranchDialog>();
instance.mMessage = BuildDeleteBranchesConfirmationMessage(branches);
instance.mEnterKeyAction = instance.DeleteButtonAction;
instance.mEscapeKeyAction = instance.CancelButtonAction;
instance.mNumberOfBranches = branches.Count;
instance.mTitle = PlasticLocalization.Name.ConfirmDeleteTitle.GetString();
return instance;
}
static string BuildDeleteBranchesConfirmationMessage(IList<BranchInfo> branchToDelete)
{
string[] itemNames = branchToDelete.Select(x => x.Name).ToArray();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine(PlasticLocalization.Name.DeleteBranchesExplanation.GetString());
stringBuilder.AppendLine();
int num = Math.Min(itemNames.Length, MAX_ITEMS_TO_SHOW);
for (int i = 0; i < num; i++)
{
stringBuilder.AppendLine(" " + (i + 1) + ". " + itemNames[i]);
}
if (itemNames.Length > MAX_ITEMS_TO_SHOW)
{
stringBuilder.AppendLine(PlasticLocalization.Name.DeleteOthersMessage.GetString(itemNames.Length - MAX_ITEMS_TO_SHOW));
}
stringBuilder.AppendLine();
stringBuilder.AppendLine(PlasticLocalization.Name.DeleteBranchesConfirmation.GetString());
return stringBuilder.ToString();
}
const int TEXT_LINE_HEIGHT = 15;
const int MAX_ITEMS_TO_SHOW = 10;
string mMessage;
string mTitle;
int mNumberOfBranches;
bool mConfirmDelete;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6780ea954e283bd4f82686f6e5ebafee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Progress;
namespace Unity.PlasticSCM.Editor.Views.Branches.Dialogs
{
internal class RenameBranchDialog : PlasticDialog
{
protected override Rect DefaultRect
{
get
{
var baseRect = base.DefaultRect;
return new Rect(baseRect.x, baseRect.y, 500, 200);
}
}
internal static BranchRenameData GetBranchRenameData(
RepositorySpec repSpec,
BranchInfo branchInfo,
EditorWindow parentWindow)
{
RenameBranchDialog dialog = Create(
repSpec,
branchInfo,
new ProgressControlsForDialogs());
ResponseType dialogResult = dialog.RunModal(parentWindow);
BranchRenameData result = dialog.BuildRenameData();
result.Result = dialogResult == ResponseType.Ok;
return result;
}
static RenameBranchDialog Create(
RepositorySpec repSpec,
BranchInfo branchInfo,
ProgressControlsForDialogs progressControls)
{
var instance = CreateInstance<RenameBranchDialog>();
instance.mEnterKeyAction = instance.OkButtonWithValidationAction;
instance.mEscapeKeyAction = instance.CancelButtonAction;
instance.mRepSpec = repSpec;
instance.mBranchInfo = branchInfo;
instance.mBranchName = GetShorten.BranchNameFromString(branchInfo.BranchName);
instance.mTitle = PlasticLocalization.GetString(
PlasticLocalization.Name.RenameBranchTitle);
instance.mProgressControls = progressControls;
return instance;
}
protected override string GetTitle()
{
return mTitle;
}
protected override void OnModalGUI()
{
Title(mTitle);
GUILayout.Space(10f);
DoInputArea();
GUILayout.Space(10f);
DrawProgressForDialogs.For(mProgressControls.ProgressData);
GUILayout.Space(10f);
DoButtonsArea();
}
void DoInputArea()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label(
PlasticLocalization.GetString(PlasticLocalization.Name.NewName),
GUILayout.ExpandWidth(false));
GUILayout.Space(10f);
GUI.SetNextControlName(RENAME_BRANCH_TEXTAREA_NAME);
mBranchName = GUILayout.TextField(
mBranchName,
GUILayout.ExpandWidth(true));
if (!mTextAreaFocused)
{
EditorGUI.FocusTextInControl(RENAME_BRANCH_TEXTAREA_NAME);
mTextAreaFocused = true;
}
}
}
void DoButtonsArea()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (Application.platform == RuntimePlatform.WindowsEditor)
{
DoOkButton();
DoCancelButton();
return;
}
DoCancelButton();
DoOkButton();
}
}
void DoOkButton()
{
if (!NormalButton(PlasticLocalization.GetString(
PlasticLocalization.Name.RenameButton)))
return;
OkButtonWithValidationAction();
}
void DoCancelButton()
{
if (!NormalButton(PlasticLocalization.GetString(
PlasticLocalization.Name.CancelButton)))
return;
CancelButtonAction();
}
void OkButtonWithValidationAction()
{
BranchRenameValidation.AsyncValidation(
BuildRenameData(),
this,
mProgressControls);
}
BranchRenameData BuildRenameData()
{
return new BranchRenameData(mRepSpec, mBranchInfo, mBranchName);
}
string mTitle;
string mBranchName;
bool mTextAreaFocused;
RepositorySpec mRepSpec;
BranchInfo mBranchInfo;
ProgressControlsForDialogs mProgressControls;
const string RENAME_BRANCH_TEXTAREA_NAME = "rename_branch_textarea";
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1de62e30afcba544e8e8da4b93a4fa39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System;
namespace Unity.PlasticSCM.Editor.Views.Branches
{
[Serializable]
internal class SerializableBranchesTabState
{
internal bool ShowHiddenBranches;
internal bool IsInitialized { get; private set; }
internal SerializableBranchesTabState(bool showHiddenBranches)
{
ShowHiddenBranches = showHiddenBranches;
IsInitialized = true;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9e592d81aca24e489c0bac69b894dd31
timeCreated: 1741940913