first commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15fe89692edc49a4891091bd0e1c6536
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebbbce5f7ed39ab45b6f43340727ba5e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,140 @@
|
||||
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,
|
||||
Branch,
|
||||
Guid
|
||||
}
|
||||
|
||||
[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 (mColumsAllowedToggleVisibility != null)
|
||||
TreeHeaderColumns.SetVisibilities(columns, mColumsAllowedToggleVisibility);
|
||||
}
|
||||
|
||||
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)),
|
||||
allowToggleVisibility = true,
|
||||
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 (mColumsAllowedToggleVisibility == null)
|
||||
mColumsAllowedToggleVisibility = TreeHeaderColumns.GetVisibilities(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
|
||||
[SerializeField]
|
||||
bool[] mColumsAllowedToggleVisibility;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4a41e458bcb22946bcfa6b165c90288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,418 @@
|
||||
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 : TreeView
|
||||
{
|
||||
internal GenericMenu Menu { get { return mMenu.Menu; } }
|
||||
|
||||
internal BranchesListView(
|
||||
BranchesListHeaderState headerState,
|
||||
List<string> columnNames,
|
||||
BranchesViewMenu menu,
|
||||
Action sizeChangedAction)
|
||||
: base(new TreeViewState())
|
||||
{
|
||||
mColumnNames = columnNames;
|
||||
mMenu = menu;
|
||||
mSizeChangedAction = sizeChangedAction;
|
||||
|
||||
multiColumnHeader = new MultiColumnHeader(headerState);
|
||||
multiColumnHeader.canSort = true;
|
||||
multiColumnHeader.sortingChanged += SortingChanged;
|
||||
|
||||
rowHeight = UnityConstants.TREEVIEW_ROW_HEIGHT;
|
||||
showAlternatingRowBackgrounds = false;
|
||||
|
||||
mCooldownFilterAction = new CooldownWindowDelayer(
|
||||
DelayedSearchChanged, UnityConstants.SEARCH_DELAYED_INPUT_ACTION_INTERVAL);
|
||||
}
|
||||
|
||||
public override IList<TreeViewItem> GetRows()
|
||||
{
|
||||
return mRows;
|
||||
}
|
||||
|
||||
internal void SetLoadedBranchId(long loadedBranchId)
|
||||
{
|
||||
mLoadedBranchId = loadedBranchId;
|
||||
}
|
||||
|
||||
protected override TreeViewItem BuildRoot()
|
||||
{
|
||||
return new TreeViewItem(0, -1, string.Empty);
|
||||
}
|
||||
|
||||
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 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 BranchListViewItem)
|
||||
{
|
||||
BranchListViewItem branchListViewItem = (BranchListViewItem)args.item;
|
||||
BranchInfo branchInfo = (BranchInfo)branchListViewItem.ObjectInfo;
|
||||
|
||||
BranchesListViewItemGUI(
|
||||
mQueryResult,
|
||||
rowHeight,
|
||||
branchListViewItem,
|
||||
args,
|
||||
branchInfo.BranchId == mLoadedBranchId,
|
||||
Repaint);
|
||||
return;
|
||||
}
|
||||
|
||||
base.RowGUI(args);
|
||||
}
|
||||
|
||||
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.Branch ||
|
||||
column == BranchesListColumn.Repository ||
|
||||
column == BranchesListColumn.Guid)
|
||||
{
|
||||
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>();
|
||||
List<TreeViewItem> mRows = new List<TreeViewItem>();
|
||||
|
||||
ViewQueryResult mQueryResult;
|
||||
long mLoadedBranchId;
|
||||
|
||||
readonly CooldownWindowDelayer mCooldownFilterAction;
|
||||
readonly Action mSizeChangedAction;
|
||||
readonly BranchesViewMenu mMenu;
|
||||
readonly List<string> mColumnNames;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b909cb14b9a08c45b5d03f0b61feecb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73306fe71bf092d4495ff28ee02b766b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,466 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews.Branches;
|
||||
using PlasticGui.WorkspaceWindow.Update;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
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;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Branches
|
||||
{
|
||||
internal class BranchesTab :
|
||||
IRefreshableView,
|
||||
IQueryRefreshableView,
|
||||
IBranchMenuOperations
|
||||
{
|
||||
internal BranchesListView Table { get { return mBranchesListView; } }
|
||||
internal IBranchMenuOperations Operations { get { return this; } }
|
||||
|
||||
internal BranchesTab(
|
||||
WorkspaceInfo wkInfo,
|
||||
IWorkspaceWindow workspaceWindow,
|
||||
IViewSwitcher viewSwitcher,
|
||||
IMergeViewLauncher mergeViewLauncher,
|
||||
IUpdateReport updateReport,
|
||||
NewIncomingChangesUpdater developerNewIncomingChangesUpdater,
|
||||
GluonNewIncomingChangesUpdater gluonNewIncomingChangesUpdater,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mParentWindow = parentWindow;
|
||||
mProgressControls = new ProgressControlsForViews();
|
||||
|
||||
mDeveloperNewIncomingChangesUpdater = developerNewIncomingChangesUpdater;
|
||||
mGluonNewIncomingChangesUpdater = gluonNewIncomingChangesUpdater;
|
||||
|
||||
BuildComponents(
|
||||
wkInfo,
|
||||
workspaceWindow,
|
||||
viewSwitcher,
|
||||
mergeViewLauncher,
|
||||
updateReport,
|
||||
developerNewIncomingChangesUpdater,
|
||||
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 void Update()
|
||||
{
|
||||
mProgressControls.UpdateProgress(mParentWindow);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DoActionsToolbar(mProgressControls);
|
||||
|
||||
DoBranchesArea(
|
||||
mBranchesListView,
|
||||
mProgressControls.IsOperationRunning());
|
||||
}
|
||||
|
||||
internal void DrawSearchFieldForBranchesTab()
|
||||
{
|
||||
DrawSearchField.For(
|
||||
mSearchField,
|
||||
mBranchesListView,
|
||||
UnityConstants.SEARCH_FIELD_WIDTH);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 = GetBranchesQuery(mDateFilter);
|
||||
|
||||
FillBranches(mWkInfo, query, BranchesSelection.
|
||||
GetSelectedRepObjectInfos(mBranchesListView));
|
||||
}
|
||||
|
||||
//IQueryRefreshableView
|
||||
public void RefreshAndSelect(RepObjectInfo repObj)
|
||||
{
|
||||
string query = GetBranchesQuery(mDateFilter);
|
||||
|
||||
FillBranches(mWkInfo, query, new List<RepObjectInfo> { repObj });
|
||||
}
|
||||
|
||||
int IBranchMenuOperations.GetSelectedBranchesCount()
|
||||
{
|
||||
return BranchesSelection.GetSelectedBranchesCount(mBranchesListView);
|
||||
}
|
||||
|
||||
void IBranchMenuOperations.CreateBranch()
|
||||
{
|
||||
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
|
||||
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
|
||||
|
||||
BranchCreationData branchCreationData = CreateBranchDialog.CreateBranchFromLastParentBranchChangeset(
|
||||
mParentWindow,
|
||||
repSpec,
|
||||
branchInfo);
|
||||
|
||||
mBranchOperations.CreateBranch(
|
||||
branchCreationData,
|
||||
RefreshAsset.BeforeLongAssetOperation,
|
||||
RefreshAsset.AfterLongAssetOperation);
|
||||
}
|
||||
|
||||
void IBranchMenuOperations.CreateTopLevelBranch() { }
|
||||
|
||||
void IBranchMenuOperations.SwitchToBranch()
|
||||
{
|
||||
RepositorySpec repSpec = BranchesSelection.GetSelectedRepository(mBranchesListView);
|
||||
BranchInfo branchInfo = BranchesSelection.GetSelectedBranch(mBranchesListView);
|
||||
|
||||
mBranchOperations.SwitchToBranch(
|
||||
repSpec,
|
||||
branchInfo,
|
||||
RefreshAsset.BeforeLongAssetOperation,
|
||||
RefreshAsset.AfterLongAssetOperation);
|
||||
}
|
||||
|
||||
void IBranchMenuOperations.MergeBranch() { }
|
||||
|
||||
void IBranchMenuOperations.CherrypickBranch() { }
|
||||
|
||||
void IBranchMenuOperations.MergeToBranch() { }
|
||||
|
||||
void IBranchMenuOperations.PullBranch() { }
|
||||
|
||||
void IBranchMenuOperations.PullRemoteBranch() { }
|
||||
|
||||
void IBranchMenuOperations.SyncWithGit() { }
|
||||
|
||||
void IBranchMenuOperations.PushBranch() { }
|
||||
|
||||
void IBranchMenuOperations.DiffBranch() { }
|
||||
|
||||
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.DeleteBranch()
|
||||
{
|
||||
var branchesToDelete = BranchesSelection.GetSelectedBranches(mBranchesListView);
|
||||
|
||||
if (!DeleteBranchDialog.ConfirmDelete(branchesToDelete))
|
||||
return;
|
||||
|
||||
mBranchOperations.DeleteBranch(
|
||||
BranchesSelection.GetSelectedRepositories(mBranchesListView),
|
||||
branchesToDelete,
|
||||
DeleteBranchOptions.IncludeChangesets);
|
||||
}
|
||||
|
||||
void IBranchMenuOperations.CreateCodeReview() { }
|
||||
|
||||
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 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 string GetBranchesQuery(DateFilter dateFilter)
|
||||
{
|
||||
if (dateFilter.FilterType == DateFilter.Type.AllTime)
|
||||
return QueryConstants.BranchesBeginningQuery;
|
||||
|
||||
string whereClause = QueryConstants.GetDateWhereClause(
|
||||
dateFilter.GetTimeAgo());
|
||||
|
||||
return string.Format("{0} {1}",
|
||||
QueryConstants.BranchesBeginningQuery,
|
||||
whereClause);
|
||||
}
|
||||
|
||||
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,
|
||||
bool isOperationRunning)
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
GUI.enabled = !isOperationRunning;
|
||||
|
||||
Rect rect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
|
||||
|
||||
branchesListView.OnGUI(rect);
|
||||
|
||||
GUI.enabled = true;
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void BuildComponents(
|
||||
WorkspaceInfo wkInfo,
|
||||
IWorkspaceWindow workspaceWindow,
|
||||
IViewSwitcher viewSwitcher,
|
||||
IMergeViewLauncher mergeViewLauncher,
|
||||
IUpdateReport updateReport,
|
||||
NewIncomingChangesUpdater developerNewIncomingChangesUpdater,
|
||||
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),
|
||||
sizeChangedAction: OnBranchesListViewSizeChanged);
|
||||
|
||||
mBranchesListView.Reload();
|
||||
|
||||
mBranchOperations = new BranchOperations(
|
||||
wkInfo,
|
||||
workspaceWindow,
|
||||
viewSwitcher,
|
||||
mergeViewLauncher,
|
||||
this,
|
||||
ViewType.BranchesView,
|
||||
mProgressControls,
|
||||
updateReport,
|
||||
new ContinueWithPendingChangesQuestionerBuilder(viewSwitcher, parentWindow),
|
||||
developerNewIncomingChangesUpdater);
|
||||
}
|
||||
|
||||
SearchField mSearchField;
|
||||
bool mIsRefreshing;
|
||||
|
||||
DateFilter mDateFilter;
|
||||
bool mShouldScrollToSelection;
|
||||
BranchesListView mBranchesListView;
|
||||
BranchOperations mBranchOperations;
|
||||
|
||||
long mLoadedBranchId = -1;
|
||||
object mLock = new object();
|
||||
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
readonly ProgressControlsForViews mProgressControls;
|
||||
readonly EditorWindow mParentWindow;
|
||||
readonly NewIncomingChangesUpdater mDeveloperNewIncomingChangesUpdater;
|
||||
readonly GluonNewIncomingChangesUpdater mGluonNewIncomingChangesUpdater;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2350e7d7f6d79024da24dea8f15a6881
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,166 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
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)
|
||||
{
|
||||
mBranchMenuOperations = branchMenuOperations;
|
||||
|
||||
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(),
|
||||
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 DeleteBranchMenuItem_Click()
|
||||
{
|
||||
mBranchMenuOperations.DeleteBranch();
|
||||
}
|
||||
|
||||
internal void UpdateMenuItems(GenericMenu menu)
|
||||
{
|
||||
BranchMenuOperations operations = BranchMenuUpdater.GetAvailableMenuOperations(
|
||||
mBranchMenuOperations.GetSelectedBranchesCount(), false);
|
||||
|
||||
AddBranchMenuItem(
|
||||
mCreateBranchMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
BranchMenuOperations.CreateBranch,
|
||||
CreateBranchMenuItem_Click);
|
||||
|
||||
AddBranchMenuItem(
|
||||
mSwitchToBranchMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
BranchMenuOperations.SwitchToBranch,
|
||||
SwitchToBranchMenuItem_Click);
|
||||
|
||||
menu.AddSeparator(string.Empty);
|
||||
|
||||
AddBranchMenuItem(
|
||||
mRenameBranchMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
BranchMenuOperations.Rename,
|
||||
RenameBranchMenuItem_Click);
|
||||
|
||||
AddBranchMenuItem(
|
||||
mDeleteBranchMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
BranchMenuOperations.Delete,
|
||||
DeleteBranchMenuItem_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;
|
||||
}
|
||||
}
|
||||
|
||||
static BranchMenuOperations GetMenuOperations(Event e)
|
||||
{
|
||||
if (Keyboard.IsKeyPressed(e, KeyCode.Delete))
|
||||
return BranchMenuOperations.Delete;
|
||||
|
||||
return BranchMenuOperations.None;
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
mCreateBranchMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemCreateBranch));
|
||||
mSwitchToBranchMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemSwitchToBranch));
|
||||
mRenameBranchMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemRenameBranch));
|
||||
mDeleteBranchMenuItemContent = new GUIContent(string.Format("{0} {1}",
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.BranchMenuItemDeleteBranch),
|
||||
GetPlasticShortcut.ForDelete()));
|
||||
}
|
||||
|
||||
GenericMenu mMenu;
|
||||
|
||||
GUIContent mCreateBranchMenuItemContent;
|
||||
GUIContent mSwitchToBranchMenuItemContent;
|
||||
GUIContent mRenameBranchMenuItemContent;
|
||||
GUIContent mDeleteBranchMenuItemContent;
|
||||
|
||||
readonly IBranchMenuOperations mBranchMenuOperations;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1f5156c89fd104459e8ec0cc3098899
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16e16045695760047a9bd172458c5d6b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,193 @@
|
||||
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
|
||||
{
|
||||
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.GetString(PlasticLocalization.Name.CreateChildBranchTitle);
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
DoTitleArea();
|
||||
|
||||
DoFieldsArea();
|
||||
|
||||
DoButtonsArea();
|
||||
}
|
||||
|
||||
internal static BranchCreationData CreateBranchFromLastParentBranchChangeset(
|
||||
EditorWindow parentWindow,
|
||||
RepositorySpec repSpec,
|
||||
BranchInfo parentBranchInfo )
|
||||
{
|
||||
string changesetStr = PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.LastChangeset);
|
||||
|
||||
string explanation = BranchCreationUserInfo.GetFromObjectString(
|
||||
repSpec, parentBranchInfo, changesetStr);
|
||||
|
||||
CreateBranchDialog dialog = Create(repSpec, parentBranchInfo, explanation);
|
||||
ResponseType dialogueResult = dialog.RunModal(parentWindow);
|
||||
|
||||
BranchCreationData result = dialog.BuildCreationData();
|
||||
result.Result = dialogueResult == ResponseType.Ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
void DoTitleArea()
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
Title(PlasticLocalization.GetString(PlasticLocalization.Name.CreateChildBranchTitle));
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
Paragraph(string.Format("{0} {1}", PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CreateChildBranchExplanation), mExplanation));
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
void DoFieldsArea()
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.BranchNameEntry),
|
||||
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.GetString(PlasticLocalization.Name.CommentsEntry),
|
||||
GUILayout.Width(100));
|
||||
}
|
||||
mComment = GUILayout.TextArea(mComment, GUILayout.Height(100));
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
mSwitchToBranch = GUILayout.Toggle(mSwitchToBranch, PlasticLocalization.GetString(PlasticLocalization.Name.SwitchToBranchCheckButton));
|
||||
|
||||
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.GetString(
|
||||
PlasticLocalization.Name.CancelButton)))
|
||||
{
|
||||
CancelButtonAction();
|
||||
}
|
||||
}
|
||||
|
||||
void DoCreateButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(PlasticLocalization.Name.CreateButton)))
|
||||
return;
|
||||
|
||||
BranchCreationValidation.AsyncValidation(
|
||||
BuildCreationData(), this, mProgressControls);
|
||||
}
|
||||
|
||||
static CreateBranchDialog Create(RepositorySpec repSpec, BranchInfo parentBranchInfo, string explanation)
|
||||
{
|
||||
var instance = CreateInstance<CreateBranchDialog>();
|
||||
instance.IsResizable = false;
|
||||
instance.mEscapeKeyAction = instance.CloseButtonAction;
|
||||
instance.mRepositorySpec = repSpec;
|
||||
instance.mParentBranchInfo = parentBranchInfo;
|
||||
instance.mNewBranchName = "";
|
||||
instance.mComment = "";
|
||||
instance.mSwitchToBranch = true;
|
||||
instance.mProgressControls = new ProgressControlsForDialogs();
|
||||
instance.mExplanation = explanation;
|
||||
return instance;
|
||||
}
|
||||
|
||||
BranchCreationData BuildCreationData()
|
||||
{
|
||||
return new BranchCreationData(
|
||||
mRepositorySpec,
|
||||
mParentBranchInfo,
|
||||
mParentBranchInfo.Changeset,
|
||||
mNewBranchName,
|
||||
mComment,
|
||||
null,
|
||||
mSwitchToBranch);
|
||||
}
|
||||
|
||||
ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
RepositorySpec mRepositorySpec;
|
||||
BranchInfo mParentBranchInfo;
|
||||
|
||||
string mNewBranchName;
|
||||
string mComment;
|
||||
bool mSwitchToBranch;
|
||||
string mExplanation;
|
||||
|
||||
bool mWasNameFieldFocused;
|
||||
const string NAME_FIELD_CONTROL_NAME = "CreateBranchNameField";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0fc5252a48d8b34f945b4ae3ad45030
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
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 = mConfirmDelete;
|
||||
|
||||
if (NormalButton(PlasticLocalization.Name.DeleteButton.GetString()))
|
||||
{
|
||||
OkButtonAction();
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
static DeleteBranchDialog Create(IList<BranchInfo> branches)
|
||||
{
|
||||
var instance = CreateInstance<DeleteBranchDialog>();
|
||||
instance.mMessage = BuildDeleteBranchesConfirmationMessage(branches);
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6780ea954e283bd4f82686f6e5ebafee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,164 @@
|
||||
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.mRepSpec = repSpec;
|
||||
instance.mBranchInfo = branchInfo;
|
||||
instance.mBranchName = BranchRenameUserInfo.GetShortBranchName(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";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1de62e30afcba544e8e8da4b93a4fa39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a83160f252281df4ebb018688dad5f08
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,17 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Changesets
|
||||
{
|
||||
class ChangesetListViewItem : TreeViewItem
|
||||
{
|
||||
internal object ObjectInfo { get; private set; }
|
||||
|
||||
internal ChangesetListViewItem(int id, object objectInfo)
|
||||
: base(id, 1)
|
||||
{
|
||||
ObjectInfo = objectInfo;
|
||||
|
||||
displayName = id.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6000865ce7fbfc643abdd3d085b4422e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,139 @@
|
||||
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.Changesets
|
||||
{
|
||||
internal enum ChangesetsListColumn
|
||||
{
|
||||
Name,
|
||||
CreationDate,
|
||||
CreatedBy,
|
||||
Comment,
|
||||
Branch,
|
||||
Repository,
|
||||
Guid
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class ChangesetsListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
|
||||
{
|
||||
internal static ChangesetsListHeaderState GetDefault()
|
||||
{
|
||||
return new ChangesetsListHeaderState(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.CreationDateColumn));
|
||||
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.CreatedByColumn));
|
||||
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.CommentColumn));
|
||||
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.BranchColumn));
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetColumnName(ChangesetsListColumn column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case ChangesetsListColumn.Name:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.NameColumn);
|
||||
case ChangesetsListColumn.CreationDate:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.CreationDateColumn);
|
||||
case ChangesetsListColumn.CreatedBy:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.CreatedByColumn);
|
||||
case ChangesetsListColumn.Comment:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.CommentColumn);
|
||||
case ChangesetsListColumn.Branch:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.BranchColumn);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (mHeaderTitles != null)
|
||||
TreeHeaderColumns.SetTitles(columns, mHeaderTitles);
|
||||
|
||||
if (mColumsAllowedToggleVisibility != null)
|
||||
TreeHeaderColumns.SetVisibilities(columns, mColumsAllowedToggleVisibility);
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
static Column[] BuildColumns()
|
||||
{
|
||||
return new Column[]
|
||||
{
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ChangesetsColumns.CHANGESET_NUMBER_WIDTH,
|
||||
minWidth = UnityConstants.ChangesetsColumns.CHANGESET_NUMBER_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ChangesetsListColumn.Name)),
|
||||
allowToggleVisibility = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ChangesetsColumns.CREATION_DATE_WIDTH,
|
||||
minWidth = UnityConstants.ChangesetsColumns.CREATION_DATE_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ChangesetsListColumn.CreationDate)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ChangesetsColumns.CREATED_BY_WIDTH,
|
||||
minWidth = UnityConstants.ChangesetsColumns.CREATED_BY_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ChangesetsListColumn.CreatedBy)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ChangesetsColumns.COMMENT_WIDTH,
|
||||
minWidth = UnityConstants.ChangesetsColumns.COMMENT_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ChangesetsListColumn.Comment)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ChangesetsColumns.BRANCH_WIDTH,
|
||||
minWidth = UnityConstants.ChangesetsColumns.BRANCH_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ChangesetsListColumn.Branch)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ChangesetsListHeaderState(Column[] columns)
|
||||
: base(columns)
|
||||
{
|
||||
if (mHeaderTitles == null)
|
||||
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
|
||||
|
||||
if (mColumsAllowedToggleVisibility == null)
|
||||
mColumsAllowedToggleVisibility = TreeHeaderColumns.GetVisibilities(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
|
||||
[SerializeField]
|
||||
bool[] mColumsAllowedToggleVisibility;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ff9581aa143f4d41b4e351881b8f459
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,450 @@
|
||||
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.Changesets
|
||||
{
|
||||
internal class ChangesetsListView : TreeView
|
||||
{
|
||||
internal GenericMenu Menu { get { return mMenu.Menu; } }
|
||||
|
||||
internal ChangesetsListView(
|
||||
ChangesetsListHeaderState headerState,
|
||||
List<string> columnNames,
|
||||
ChangesetsViewMenu menu,
|
||||
Action sizeChangedAction,
|
||||
Action selectionChangedAction,
|
||||
Action doubleClickAction)
|
||||
: base(new TreeViewState())
|
||||
{
|
||||
mColumnNames = columnNames;
|
||||
mMenu = menu;
|
||||
mSizeChangedAction = sizeChangedAction;
|
||||
mSelectionChangedAction = selectionChangedAction;
|
||||
mDoubleClickAction = doubleClickAction;
|
||||
|
||||
multiColumnHeader = new MultiColumnHeader(headerState);
|
||||
multiColumnHeader.canSort = true;
|
||||
multiColumnHeader.sortingChanged += SortingChanged;
|
||||
|
||||
rowHeight = UnityConstants.TREEVIEW_ROW_HEIGHT;
|
||||
showAlternatingRowBackgrounds = false;
|
||||
|
||||
mCooldownFilterAction = new CooldownWindowDelayer(
|
||||
DelayedSearchChanged, UnityConstants.SEARCH_DELAYED_INPUT_ACTION_INTERVAL);
|
||||
|
||||
mCooldownSelectionAction = new CooldownWindowDelayer(
|
||||
DelayedSelectionChanged, UnityConstants.SELECTION_DELAYED_INPUT_ACTION_INTERVAL);
|
||||
}
|
||||
|
||||
protected override void SelectionChanged(IList<int> selectedIds)
|
||||
{
|
||||
mCooldownSelectionAction.Ping();
|
||||
}
|
||||
|
||||
public override IList<TreeViewItem> GetRows()
|
||||
{
|
||||
return mRows;
|
||||
}
|
||||
|
||||
internal void SetLoadedChangesetId(long loadedChangesetId)
|
||||
{
|
||||
mLoadedChangesetId = loadedChangesetId;
|
||||
}
|
||||
|
||||
protected override TreeViewItem BuildRoot()
|
||||
{
|
||||
return new TreeViewItem(0, -1, string.Empty);
|
||||
}
|
||||
|
||||
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 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 ChangesetListViewItem)
|
||||
{
|
||||
ChangesetListViewItem changesetListViewItem = (ChangesetListViewItem)args.item;
|
||||
ChangesetInfo changesetInfo = (ChangesetInfo)changesetListViewItem.ObjectInfo;
|
||||
|
||||
ChangesetsListViewItemGUI(
|
||||
mQueryResult,
|
||||
rowHeight,
|
||||
changesetListViewItem,
|
||||
args,
|
||||
changesetInfo.ChangesetId == mLoadedChangesetId,
|
||||
Repaint);
|
||||
return;
|
||||
}
|
||||
|
||||
base.RowGUI(args);
|
||||
}
|
||||
|
||||
protected override void DoubleClickedItem(int id)
|
||||
{
|
||||
if (!HasSelection())
|
||||
return;
|
||||
|
||||
mDoubleClickAction();
|
||||
}
|
||||
|
||||
internal void BuildModel(
|
||||
ViewQueryResult queryResult,
|
||||
long loadedChangesetId)
|
||||
{
|
||||
mListViewItemIds.Clear();
|
||||
|
||||
mQueryResult = queryResult;
|
||||
mLoadedChangesetId = loadedChangesetId;
|
||||
}
|
||||
|
||||
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 DelayedSelectionChanged()
|
||||
{
|
||||
if (!HasSelection())
|
||||
return;
|
||||
|
||||
mSelectionChangedAction();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
ChangesetListViewItem changesetListViewItem =
|
||||
new ChangesetListViewItem(objectId, objectInfo);
|
||||
|
||||
rootItem.AddChild(changesetListViewItem);
|
||||
rows.Add(changesetListViewItem);
|
||||
}
|
||||
}
|
||||
|
||||
static void ClearRows(
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
if (rootItem.hasChildren)
|
||||
rootItem.children.Clear();
|
||||
|
||||
rows.Clear();
|
||||
}
|
||||
|
||||
static void ChangesetsListViewItemGUI(
|
||||
ViewQueryResult queryResult,
|
||||
float rowHeight,
|
||||
ChangesetListViewItem 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;
|
||||
}
|
||||
|
||||
ChangesetsListColumn column =
|
||||
(ChangesetsListColumn)args.GetColumn(visibleColumnIdx);
|
||||
|
||||
ChangesetsListViewItemCellGUI(
|
||||
cellRect,
|
||||
rowHeight,
|
||||
queryResult,
|
||||
item,
|
||||
column,
|
||||
avatarLoadedAction,
|
||||
args.selected,
|
||||
args.focused,
|
||||
isBoldText);
|
||||
}
|
||||
}
|
||||
|
||||
static void ChangesetsListViewItemCellGUI(
|
||||
Rect rect,
|
||||
float rowHeight,
|
||||
ViewQueryResult queryResult,
|
||||
ChangesetListViewItem item,
|
||||
ChangesetsListColumn column,
|
||||
Action avatarLoadedAction,
|
||||
bool isSelected,
|
||||
bool isFocused,
|
||||
bool isBoldText)
|
||||
{
|
||||
string columnText = RepObjectInfoView.GetColumnText(
|
||||
queryResult.GetRepositorySpec(item.ObjectInfo),
|
||||
queryResult.GetRepObjectInfo(item.ObjectInfo),
|
||||
ChangesetsListHeaderState.GetColumnName(column));
|
||||
|
||||
if (column == ChangesetsListColumn.CreatedBy)
|
||||
{
|
||||
DrawTreeViewItem.ForItemCell(
|
||||
rect,
|
||||
rowHeight,
|
||||
-1,
|
||||
GetAvatar.ForEmail(columnText, avatarLoadedAction),
|
||||
null,
|
||||
columnText,
|
||||
isSelected,
|
||||
isFocused,
|
||||
isBoldText,
|
||||
false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (column == ChangesetsListColumn.Branch ||
|
||||
column == ChangesetsListColumn.Repository ||
|
||||
column == ChangesetsListColumn.Guid)
|
||||
{
|
||||
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>();
|
||||
List<TreeViewItem> mRows = new List<TreeViewItem>();
|
||||
|
||||
ViewQueryResult mQueryResult;
|
||||
long mLoadedChangesetId;
|
||||
|
||||
readonly CooldownWindowDelayer mCooldownFilterAction;
|
||||
readonly CooldownWindowDelayer mCooldownSelectionAction;
|
||||
readonly Action mDoubleClickAction;
|
||||
readonly Action mSelectionChangedAction;
|
||||
readonly Action mSizeChangedAction;
|
||||
readonly ChangesetsViewMenu mMenu;
|
||||
readonly List<string> mColumnNames;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59e682a8b37338a46910fa9a939425e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Changesets
|
||||
{
|
||||
internal static class ChangesetsSelection
|
||||
{
|
||||
internal static void SelectChangesets(
|
||||
ChangesetsListView listView,
|
||||
List<RepObjectInfo> csetsToSelect,
|
||||
int defaultRow)
|
||||
{
|
||||
if (csetsToSelect == null || csetsToSelect.Count == 0)
|
||||
{
|
||||
TableViewOperations.SelectFirstRow(listView);
|
||||
return;
|
||||
}
|
||||
|
||||
listView.SelectRepObjectInfos(csetsToSelect);
|
||||
|
||||
if (listView.HasSelection())
|
||||
return;
|
||||
|
||||
TableViewOperations.SelectDefaultRow(listView, defaultRow);
|
||||
|
||||
if (listView.HasSelection())
|
||||
return;
|
||||
|
||||
TableViewOperations.SelectFirstRow(listView);
|
||||
}
|
||||
|
||||
internal static List<RepObjectInfo> GetSelectedRepObjectInfos(
|
||||
ChangesetsListView listView)
|
||||
{
|
||||
return listView.GetSelectedRepObjectInfos();
|
||||
}
|
||||
|
||||
internal static int GetSelectedChangesetsCount(
|
||||
ChangesetsListView listView)
|
||||
{
|
||||
return listView.GetSelection().Count;
|
||||
}
|
||||
|
||||
internal static ChangesetExtendedInfo GetSelectedChangeset(
|
||||
ChangesetsListView listView)
|
||||
{
|
||||
List<RepObjectInfo> selectedRepObjectsInfos = listView.GetSelectedRepObjectInfos();
|
||||
|
||||
if (selectedRepObjectsInfos.Count == 0)
|
||||
return null;
|
||||
|
||||
return (ChangesetExtendedInfo)selectedRepObjectsInfos[0];
|
||||
}
|
||||
|
||||
internal static RepositorySpec GetSelectedRepository(
|
||||
ChangesetsListView listView)
|
||||
{
|
||||
List<RepositorySpec> selectedRepositories = listView.GetSelectedRepositories();
|
||||
|
||||
if (selectedRepositories.Count == 0)
|
||||
return null;
|
||||
|
||||
return selectedRepositories[0];
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20341761c2011b441b2a3af227beeb71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 471badd5c87fb154885f11cdf1b49a00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,51 @@
|
||||
using UnityEditor;
|
||||
|
||||
using Codice.CM.Common;
|
||||
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Changesets
|
||||
{
|
||||
internal partial class ChangesetsTab
|
||||
{
|
||||
void SwitchToChangesetForMode(bool isGluonMode)
|
||||
{
|
||||
if (isGluonMode)
|
||||
{
|
||||
SwitchToChangesetForGluon();
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchToChangesetForDeveloper();
|
||||
}
|
||||
|
||||
void SwitchToChangesetForDeveloper()
|
||||
{
|
||||
mChangesetOperations.SwitchToChangeset(
|
||||
ChangesetsSelection.GetSelectedRepository(mChangesetsListView),
|
||||
ChangesetsSelection.GetSelectedChangeset(mChangesetsListView),
|
||||
RefreshAsset.BeforeLongAssetOperation,
|
||||
RefreshAsset.AfterLongAssetOperation);
|
||||
}
|
||||
|
||||
void SwitchToChangesetForGluon()
|
||||
{
|
||||
ChangesetExtendedInfo csetInfo = ChangesetsSelection.GetSelectedChangeset(mChangesetsListView);
|
||||
|
||||
SwitchToUIOperation.SwitchToChangeset(
|
||||
mWkInfo,
|
||||
csetInfo.BranchName,
|
||||
csetInfo.ChangesetId,
|
||||
mViewHost,
|
||||
null,
|
||||
new UnityPlasticGuiMessage(),
|
||||
mProgressControls,
|
||||
mWorkspaceWindow.GluonProgressOperationHandler,
|
||||
mGluonUpdateReport,
|
||||
mWorkspaceWindow,
|
||||
RefreshAsset.BeforeLongAssetOperation,
|
||||
RefreshAsset.AfterLongAssetOperation);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06e8f2c592322e640ae99a833427b552
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,369 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common.EventTracking;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews.Changesets;
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.Tool;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Changesets
|
||||
{
|
||||
internal class ChangesetsViewMenu
|
||||
{
|
||||
internal GenericMenu Menu { get { return mMenu; } }
|
||||
|
||||
public interface IMenuOperations
|
||||
{
|
||||
void DiffBranch();
|
||||
ChangesetExtendedInfo GetSelectedChangeset();
|
||||
}
|
||||
|
||||
internal ChangesetsViewMenu(
|
||||
WorkspaceInfo wkInfo,
|
||||
IChangesetMenuOperations changesetMenuOperations,
|
||||
IMenuOperations menuOperations,
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
bool isGluonMode)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mChangesetMenuOperations = changesetMenuOperations;
|
||||
mMenuOperations = menuOperations;
|
||||
mShowDownloadPlasticExeWindow = showDownloadPlasticExeWindow;
|
||||
mIsGluonMode = isGluonMode;
|
||||
|
||||
BuildComponents();
|
||||
}
|
||||
|
||||
internal void Popup()
|
||||
{
|
||||
mMenu = new GenericMenu();
|
||||
|
||||
UpdateMenuItems(mMenu);
|
||||
|
||||
mMenu.ShowAsContext();
|
||||
}
|
||||
|
||||
internal bool ProcessKeyActionIfNeeded(Event e)
|
||||
{
|
||||
int selectedChangesetsCount = mChangesetMenuOperations.GetSelectedChangesetsCount();
|
||||
|
||||
ChangesetMenuOperations operationToExecute = GetMenuOperations(
|
||||
e, selectedChangesetsCount > 1);
|
||||
|
||||
if (operationToExecute == ChangesetMenuOperations.None)
|
||||
return false;
|
||||
|
||||
ChangesetMenuOperations operations = ChangesetMenuUpdater.GetAvailableMenuOperations(
|
||||
selectedChangesetsCount,
|
||||
mIsGluonMode,
|
||||
mMenuOperations.GetSelectedChangeset().BranchId,
|
||||
mLoadedBranchId,
|
||||
false);
|
||||
|
||||
if (!operations.HasFlag(operationToExecute))
|
||||
return false;
|
||||
|
||||
ProcessMenuOperation(operationToExecute, mChangesetMenuOperations);
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void SetLoadedBranchId(long loadedBranchId)
|
||||
{
|
||||
mLoadedBranchId = loadedBranchId;
|
||||
}
|
||||
|
||||
void DiffChangesetMenuItem_Click()
|
||||
{
|
||||
if (mShowDownloadPlasticExeWindow.Show(
|
||||
mWkInfo,
|
||||
mIsGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromDiffChangeset,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromDiffChangeset,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromDiffChangeset))
|
||||
return;
|
||||
|
||||
mChangesetMenuOperations.DiffChangeset();
|
||||
}
|
||||
|
||||
void DiffSelectedChangesetsMenuItem_Click()
|
||||
{
|
||||
if (mShowDownloadPlasticExeWindow.Show(
|
||||
mWkInfo,
|
||||
mIsGluonMode,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticCloudFromDiffSelectedChangesets,
|
||||
TrackFeatureUseEvent.Features.InstallPlasticEnterpriseFromDiffSelectedChangesets,
|
||||
TrackFeatureUseEvent.Features.CancelPlasticInstallationFromDiffSelectedChangesets))
|
||||
return;
|
||||
|
||||
mChangesetMenuOperations.DiffSelectedChangesets();
|
||||
}
|
||||
|
||||
void RevertToChangesetMenuItem_Click()
|
||||
{
|
||||
mChangesetMenuOperations.RevertToChangeset();
|
||||
}
|
||||
|
||||
void DiffBranchMenuItem_Click()
|
||||
{
|
||||
mMenuOperations.DiffBranch();
|
||||
}
|
||||
|
||||
void SwitchToChangesetMenuItem_Click()
|
||||
{
|
||||
mChangesetMenuOperations.SwitchToChangeset();
|
||||
}
|
||||
|
||||
internal void UpdateMenuItems(GenericMenu menu)
|
||||
{
|
||||
ChangesetExtendedInfo singleSelectedChangeset = mMenuOperations.GetSelectedChangeset();
|
||||
|
||||
ChangesetMenuOperations operations = ChangesetMenuUpdater.GetAvailableMenuOperations(
|
||||
mChangesetMenuOperations.GetSelectedChangesetsCount(),
|
||||
mIsGluonMode,
|
||||
singleSelectedChangeset.BranchId,
|
||||
mLoadedBranchId,
|
||||
false);
|
||||
|
||||
AddDiffChangesetMenuItem(
|
||||
mDiffChangesetMenuItemContent,
|
||||
menu,
|
||||
singleSelectedChangeset,
|
||||
operations,
|
||||
DiffChangesetMenuItem_Click);
|
||||
|
||||
AddDiffSelectedChangesetsMenuItem(
|
||||
mDiffSelectedChangesetsMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
DiffSelectedChangesetsMenuItem_Click);
|
||||
|
||||
if (!IsOnMainBranch(singleSelectedChangeset))
|
||||
{
|
||||
menu.AddSeparator(string.Empty);
|
||||
|
||||
AddDiffBranchMenuItem(
|
||||
mDiffBranchMenuItemContent,
|
||||
menu,
|
||||
singleSelectedChangeset,
|
||||
operations,
|
||||
DiffBranchMenuItem_Click);
|
||||
}
|
||||
|
||||
menu.AddSeparator(string.Empty);
|
||||
|
||||
AddSwitchToChangesetMenuItem(
|
||||
mSwitchToChangesetMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
SwitchToChangesetMenuItem_Click);
|
||||
|
||||
if (mIsGluonMode)
|
||||
return;
|
||||
|
||||
AddBackToMenuItem(
|
||||
mRevertToChangesetMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
RevertToChangesetMenuItem_Click);
|
||||
}
|
||||
|
||||
void ProcessMenuOperation(
|
||||
ChangesetMenuOperations operationToExecute,
|
||||
IChangesetMenuOperations changesetMenuOperations)
|
||||
{
|
||||
if (operationToExecute == ChangesetMenuOperations.DiffChangeset)
|
||||
{
|
||||
DiffChangesetMenuItem_Click();
|
||||
return;
|
||||
}
|
||||
|
||||
if (operationToExecute == ChangesetMenuOperations.DiffSelectedChangesets)
|
||||
{
|
||||
DiffSelectedChangesetsMenuItem_Click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void AddDiffChangesetMenuItem(
|
||||
GUIContent menuItemContent,
|
||||
GenericMenu menu,
|
||||
ChangesetExtendedInfo changeset,
|
||||
ChangesetMenuOperations operations,
|
||||
GenericMenu.MenuFunction menuFunction)
|
||||
{
|
||||
string changesetName =
|
||||
changeset != null ?
|
||||
changeset.ChangesetId.ToString() :
|
||||
string.Empty;
|
||||
|
||||
menuItemContent.text = string.Format("{0} {1}",
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.AnnotateDiffChangesetMenuItem,
|
||||
changesetName),
|
||||
GetPlasticShortcut.ForDiff());
|
||||
|
||||
if (operations.HasFlag(ChangesetMenuOperations.DiffChangeset))
|
||||
{
|
||||
menu.AddItem(
|
||||
menuItemContent,
|
||||
false,
|
||||
menuFunction);
|
||||
return;
|
||||
}
|
||||
|
||||
menu.AddDisabledItem(
|
||||
menuItemContent);
|
||||
}
|
||||
|
||||
static void AddDiffSelectedChangesetsMenuItem(
|
||||
GUIContent menuItemContent,
|
||||
GenericMenu menu,
|
||||
ChangesetMenuOperations operations,
|
||||
GenericMenu.MenuFunction menuFunction)
|
||||
{
|
||||
if (operations.HasFlag(ChangesetMenuOperations.DiffSelectedChangesets))
|
||||
{
|
||||
menu.AddItem(
|
||||
menuItemContent,
|
||||
false,
|
||||
menuFunction);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
menu.AddDisabledItem(menuItemContent);
|
||||
}
|
||||
|
||||
static void AddBackToMenuItem(
|
||||
GUIContent menuItemContent,
|
||||
GenericMenu menu,
|
||||
ChangesetMenuOperations operations,
|
||||
GenericMenu.MenuFunction menuFunction)
|
||||
{
|
||||
if (operations.HasFlag(ChangesetMenuOperations.RevertToChangeset))
|
||||
{
|
||||
menu.AddItem(
|
||||
menuItemContent,
|
||||
false,
|
||||
menuFunction);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
menu.AddDisabledItem(menuItemContent);
|
||||
}
|
||||
|
||||
static void AddDiffBranchMenuItem(
|
||||
GUIContent menuItemContent,
|
||||
GenericMenu menu,
|
||||
ChangesetExtendedInfo changeset,
|
||||
ChangesetMenuOperations operations,
|
||||
GenericMenu.MenuFunction menuFunction)
|
||||
{
|
||||
string branchName = GetBranchName(changeset);
|
||||
|
||||
menuItemContent.text =
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.AnnotateDiffBranchMenuItem,
|
||||
branchName);
|
||||
|
||||
if (operations.HasFlag(ChangesetMenuOperations.DiffChangeset))
|
||||
{
|
||||
menu.AddItem(
|
||||
menuItemContent,
|
||||
false,
|
||||
menuFunction);
|
||||
return;
|
||||
}
|
||||
|
||||
menu.AddDisabledItem(
|
||||
menuItemContent);
|
||||
}
|
||||
|
||||
static void AddSwitchToChangesetMenuItem(
|
||||
GUIContent menuItemContent,
|
||||
GenericMenu menu,
|
||||
ChangesetMenuOperations operations,
|
||||
GenericMenu.MenuFunction menuFunction)
|
||||
{
|
||||
if (operations.HasFlag(ChangesetMenuOperations.SwitchToChangeset))
|
||||
{
|
||||
menu.AddItem(
|
||||
menuItemContent,
|
||||
false,
|
||||
menuFunction);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
menu.AddDisabledItem(menuItemContent);
|
||||
}
|
||||
|
||||
static string GetBranchName(ChangesetExtendedInfo changesetInfo)
|
||||
{
|
||||
if (changesetInfo == null)
|
||||
return string.Empty;
|
||||
|
||||
string branchName = changesetInfo.BranchName;
|
||||
|
||||
int lastIndex = changesetInfo.BranchName.LastIndexOf("/");
|
||||
|
||||
if (lastIndex == -1)
|
||||
return branchName;
|
||||
|
||||
return branchName.Substring(lastIndex + 1);
|
||||
}
|
||||
|
||||
static bool IsOnMainBranch(ChangesetExtendedInfo singleSeletedChangeset)
|
||||
{
|
||||
if (singleSeletedChangeset == null)
|
||||
return false;
|
||||
|
||||
return singleSeletedChangeset.BranchName == MAIN_BRANCH_NAME;
|
||||
}
|
||||
|
||||
static ChangesetMenuOperations GetMenuOperations(
|
||||
Event e, bool isMultipleSelection)
|
||||
{
|
||||
if (Keyboard.IsControlOrCommandKeyPressed(e) &&
|
||||
Keyboard.IsKeyPressed(e, KeyCode.D))
|
||||
return isMultipleSelection ?
|
||||
ChangesetMenuOperations.DiffSelectedChangesets :
|
||||
ChangesetMenuOperations.DiffChangeset;
|
||||
|
||||
return ChangesetMenuOperations.None;
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
mDiffChangesetMenuItemContent = new GUIContent(string.Empty);
|
||||
mDiffSelectedChangesetsMenuItemContent = new GUIContent(string.Format("{0} {1}",
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.ChangesetMenuItemDiffSelected),
|
||||
GetPlasticShortcut.ForDiff()));
|
||||
mDiffBranchMenuItemContent = new GUIContent();
|
||||
mSwitchToChangesetMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.ChangesetMenuItemSwitchToChangeset));
|
||||
mRevertToChangesetMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.GetString(PlasticLocalization.Name.ChangesetMenuItemRevertToChangeset));
|
||||
}
|
||||
|
||||
GenericMenu mMenu;
|
||||
|
||||
GUIContent mDiffChangesetMenuItemContent;
|
||||
GUIContent mDiffSelectedChangesetsMenuItemContent;
|
||||
GUIContent mDiffBranchMenuItemContent;
|
||||
GUIContent mSwitchToChangesetMenuItemContent;
|
||||
GUIContent mRevertToChangesetMenuItemContent;
|
||||
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
readonly IChangesetMenuOperations mChangesetMenuOperations;
|
||||
readonly IMenuOperations mMenuOperations;
|
||||
readonly LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow;
|
||||
readonly bool mIsGluonMode;
|
||||
|
||||
long mLoadedBranchId = -1;
|
||||
|
||||
const string MAIN_BRANCH_NAME = "/main";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 397f62458d0ad3441aaaa1a738bd4f94
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Changesets
|
||||
{
|
||||
internal class DateFilter
|
||||
{
|
||||
internal enum Type
|
||||
{
|
||||
LastWeek,
|
||||
Last15Days,
|
||||
LastMonth,
|
||||
Last3Months,
|
||||
LastYear,
|
||||
AllTime
|
||||
}
|
||||
|
||||
internal Type FilterType;
|
||||
|
||||
internal DateFilter(Type filterType)
|
||||
{
|
||||
FilterType = filterType;
|
||||
}
|
||||
|
||||
internal string GetTimeAgo()
|
||||
{
|
||||
switch (FilterType)
|
||||
{
|
||||
case DateFilter.Type.LastWeek:
|
||||
return QueryConstants.OneWeekAgo;
|
||||
case DateFilter.Type.Last15Days:
|
||||
return QueryConstants.HalfMonthAgo;
|
||||
case DateFilter.Type.LastMonth:
|
||||
return QueryConstants.OneMonthAgo;
|
||||
case DateFilter.Type.Last3Months:
|
||||
return QueryConstants.ThreeMonthsAgo;
|
||||
case DateFilter.Type.LastYear:
|
||||
return QueryConstants.OneYearAgo;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a4d62c64067bca4cbbd6f7fcad2e190
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,137 @@
|
||||
using Codice.CM.Common;
|
||||
using Unity.PlasticSCM.Editor.Tool;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Changesets
|
||||
{
|
||||
static class LaunchDiffOperations
|
||||
{
|
||||
internal static void DiffChangeset(
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
LaunchTool.IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
long changesetId,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (changesetId == -1)
|
||||
return;
|
||||
|
||||
string changesetFullSpec = GetChangesetFullSpec(
|
||||
repSpec, changesetId);
|
||||
|
||||
LaunchTool.OpenChangesetDiffs(
|
||||
showDownloadPlasticExeWindow,
|
||||
processExecutor,
|
||||
repSpec,
|
||||
changesetFullSpec,
|
||||
isGluonMode);
|
||||
}
|
||||
|
||||
internal static void DiffChangeset(
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
LaunchTool.IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
ChangesetInfo changesetInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (changesetInfo == null)
|
||||
return;
|
||||
|
||||
string changesetFullSpec = GetChangesetFullSpec(
|
||||
repSpec, changesetInfo.ChangesetId);
|
||||
|
||||
LaunchTool.OpenChangesetDiffs(
|
||||
showDownloadPlasticExeWindow,
|
||||
processExecutor,
|
||||
repSpec,
|
||||
changesetFullSpec,
|
||||
isGluonMode);
|
||||
}
|
||||
|
||||
internal static void DiffSelectedChangesets(
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
LaunchTool.IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
ChangesetInfo cset1,
|
||||
ChangesetInfo cset2,
|
||||
bool isGluonMode)
|
||||
{
|
||||
ChangesetInfo srcChangesetInfo;
|
||||
ChangesetInfo dstChangesetInfo;
|
||||
|
||||
GetSrcAndDstCangesets(
|
||||
cset1,
|
||||
cset2,
|
||||
out srcChangesetInfo,
|
||||
out dstChangesetInfo);
|
||||
|
||||
string srcChangesetFullSpec = GetChangesetFullSpec(
|
||||
repSpec, srcChangesetInfo.ChangesetId);
|
||||
|
||||
string dstChangesetFullSpec = GetChangesetFullSpec(
|
||||
repSpec, dstChangesetInfo.ChangesetId);
|
||||
|
||||
LaunchTool.OpenSelectedChangesetsDiffs(
|
||||
showDownloadPlasticExeWindow,
|
||||
processExecutor,
|
||||
repSpec,
|
||||
srcChangesetFullSpec,
|
||||
dstChangesetFullSpec,
|
||||
isGluonMode);
|
||||
}
|
||||
|
||||
internal static void DiffBranch(
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
LaunchTool.IProcessExecutor processExecutor,
|
||||
RepositorySpec repSpec,
|
||||
ChangesetExtendedInfo changesetExtendedInfo,
|
||||
bool isGluonMode)
|
||||
{
|
||||
if (changesetExtendedInfo == null)
|
||||
return;
|
||||
|
||||
string branchFullSpec = GetBranchFullSpec(
|
||||
repSpec, changesetExtendedInfo);
|
||||
|
||||
LaunchTool.OpenBranchDiffs(
|
||||
showDownloadPlasticExeWindow,
|
||||
processExecutor,
|
||||
repSpec,
|
||||
branchFullSpec,
|
||||
isGluonMode);
|
||||
}
|
||||
|
||||
static void GetSrcAndDstCangesets(
|
||||
ChangesetInfo cset1,
|
||||
ChangesetInfo cset2,
|
||||
out ChangesetInfo srcChangesetInfo,
|
||||
out ChangesetInfo dstChangesetInfo)
|
||||
{
|
||||
if (cset1.LocalTimeStamp < cset2.LocalTimeStamp)
|
||||
{
|
||||
srcChangesetInfo = cset1;
|
||||
dstChangesetInfo = cset2;
|
||||
return;
|
||||
}
|
||||
|
||||
srcChangesetInfo = cset2;
|
||||
dstChangesetInfo = cset1;
|
||||
}
|
||||
|
||||
static string GetChangesetFullSpec(
|
||||
RepositorySpec repSpec,
|
||||
long changesetId)
|
||||
{
|
||||
return string.Format("cs:{0}@{1}",
|
||||
changesetId, repSpec.ToString());
|
||||
}
|
||||
|
||||
static string GetBranchFullSpec(
|
||||
RepositorySpec repSpec,
|
||||
ChangesetExtendedInfo changesetExtendedInfo)
|
||||
{
|
||||
return string.Format("br:{0}@{1}",
|
||||
changesetExtendedInfo.BranchName,
|
||||
repSpec.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6483fd05e8bf42a47aee5e11dbf6db8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,208 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
|
||||
using Codice.Client.Commands;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.Update;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views
|
||||
{
|
||||
internal class ContinueWithPendingChangesQuestionerBuilder :
|
||||
SwitchController.IContinueWithPendingChangesQuestionerBuilder
|
||||
{
|
||||
internal ContinueWithPendingChangesQuestionerBuilder(
|
||||
IViewSwitcher viewSwitcher,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
mViewSwitcher = viewSwitcher;
|
||||
mParentWindow = parentWindow;
|
||||
}
|
||||
|
||||
public IContinueWithPendingChangesQuestioner Get(string title, string explanation)
|
||||
{
|
||||
return new ContinueWithPendingChangesQuestioner(
|
||||
title,
|
||||
explanation,
|
||||
mViewSwitcher,
|
||||
mParentWindow);
|
||||
}
|
||||
|
||||
IViewSwitcher mViewSwitcher;
|
||||
EditorWindow mParentWindow;
|
||||
}
|
||||
|
||||
internal class ContinueWithPendingChangesQuestioner : IContinueWithPendingChangesQuestioner
|
||||
{
|
||||
internal ContinueWithPendingChangesQuestioner(
|
||||
string title,
|
||||
string explanation,
|
||||
IViewSwitcher viewSwitcher,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
mTitle = title;
|
||||
mExplanation = explanation;
|
||||
mViewSwitcher = viewSwitcher;
|
||||
mParentWindow = parentWindow;
|
||||
}
|
||||
|
||||
public bool ContinueWithPendingChanges()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
GUIActionRunner.RunGUIAction(() =>
|
||||
{
|
||||
result = ConfirmContinueWithPendingChangesDialog.ConfirmContinue(
|
||||
mTitle,
|
||||
mExplanation,
|
||||
mViewSwitcher,
|
||||
mParentWindow);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string mTitle;
|
||||
string mExplanation;
|
||||
IViewSwitcher mViewSwitcher;
|
||||
EditorWindow mParentWindow;
|
||||
}
|
||||
|
||||
internal class ConfirmContinueWithPendingChangesDialog : PlasticDialog
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 500, 287);
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool ConfirmContinue(
|
||||
string title,
|
||||
string explanation,
|
||||
IViewSwitcher viewSwitcher,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
ConfirmContinueWithPendingChangesDialog dialog = Create(
|
||||
title,
|
||||
explanation,
|
||||
viewSwitcher);
|
||||
|
||||
if (dialog.RunModal(parentWindow) != ResponseType.Ok)
|
||||
return false;
|
||||
|
||||
if (dialog.mIsSwitchToConfirmationChecked)
|
||||
SavePreference();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static ConfirmContinueWithPendingChangesDialog Create(
|
||||
string title,
|
||||
string explanation,
|
||||
IViewSwitcher viewSwitcher)
|
||||
{
|
||||
var instance = CreateInstance<ConfirmContinueWithPendingChangesDialog>();
|
||||
instance.mTitle = title;
|
||||
instance.mExplanation = explanation;
|
||||
instance.mViewSwitcher = viewSwitcher;
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void SavePreference()
|
||||
{
|
||||
ClientConfigData data = ClientConfig.Get().GetClientConfigData();
|
||||
data.SetPendingChangesOnSwitchAction(UserAction.None);
|
||||
ClientConfig.Get().Save(data);
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
Title(mTitle);
|
||||
|
||||
Paragraph(mExplanation);
|
||||
|
||||
DoSwitchToConfirmationCheckButton();
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
DoButtonsArea();
|
||||
}
|
||||
|
||||
void DoSwitchToConfirmationCheckButton()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
mIsSwitchToConfirmationChecked = TitleToggle(
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.SwitchToConfirmationCheckButton),
|
||||
mIsSwitchToConfirmationChecked);
|
||||
}
|
||||
}
|
||||
|
||||
void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
DoContinueButton();
|
||||
DoCancelAndViewPendingChangesButton();
|
||||
DoCancelButton();
|
||||
return;
|
||||
}
|
||||
|
||||
DoCancelButton();
|
||||
DoCancelAndViewPendingChangesButton();
|
||||
DoContinueButton();
|
||||
}
|
||||
}
|
||||
|
||||
void DoContinueButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.SwitchToConfirmationContinueButton)))
|
||||
return;
|
||||
|
||||
OkButtonAction();
|
||||
}
|
||||
|
||||
void DoCancelButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CancelButton)))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
void DoCancelAndViewPendingChangesButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.SwitchToConfirmationCancelViewChangesButton)))
|
||||
return;
|
||||
|
||||
mViewSwitcher.ShowPendingChanges();
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
string mTitle;
|
||||
string mExplanation;
|
||||
IViewSwitcher mViewSwitcher;
|
||||
|
||||
bool mIsSwitchToConfirmationChecked;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3389e142c33d23546a31fc469443a2c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 173564ff53b74604b8e070b51861b3f9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.Configuration.CloudEdition;
|
||||
using PlasticGui.WorkspaceWindow.Home.Repositories;
|
||||
using PlasticGui.WorkspaceWindow.Home.Workspaces;
|
||||
using PlasticGui.WebApi;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.CreateWorkspace
|
||||
{
|
||||
internal class CreateWorkspaceView :
|
||||
IPlasticDialogCloser,
|
||||
IWorkspacesRefreshableView
|
||||
{
|
||||
internal interface ICreateWorkspaceListener
|
||||
{
|
||||
void OnWorkspaceCreated(WorkspaceInfo wkInfo, bool isGluonMode);
|
||||
}
|
||||
|
||||
internal CreateWorkspaceView(
|
||||
PlasticWindow parentWindow,
|
||||
ICreateWorkspaceListener listener,
|
||||
IPlasticAPI plasticApi,
|
||||
IPlasticWebRestApi plasticWebRestApi,
|
||||
string workspacePath)
|
||||
{
|
||||
mParentWindow = parentWindow;
|
||||
mCreateWorkspaceListener = listener;
|
||||
mWorkspacePath = workspacePath;
|
||||
mPlasticWebRestApi = plasticWebRestApi;
|
||||
|
||||
mProgressControls = new ProgressControlsForViews();
|
||||
mWorkspaceOperations = new WorkspaceOperations(this, mProgressControls, null);
|
||||
mCreateWorkspaceState = CreateWorkspaceViewState.BuildForProjectDefaults();
|
||||
|
||||
Initialize(plasticApi, plasticWebRestApi);
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
mProgressControls.UpdateProgress(mParentWindow);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
if (Event.current.type == EventType.Layout)
|
||||
{
|
||||
mProgressControls.ProgressData.CopyInto(
|
||||
mCreateWorkspaceState.ProgressData);
|
||||
}
|
||||
|
||||
string repository = mCreateWorkspaceState.Repository;
|
||||
|
||||
DrawCreateWorkspace.ForState(
|
||||
CreateRepository,
|
||||
ValidateAndCreateWorkspace,
|
||||
mParentWindow,
|
||||
mPlasticWebRestApi,
|
||||
mDefaultServer,
|
||||
ref mCreateWorkspaceState);
|
||||
|
||||
if (repository == mCreateWorkspaceState.Repository)
|
||||
return;
|
||||
|
||||
OnRepositoryChanged(
|
||||
mDialogUserAssistant,
|
||||
mCreateWorkspaceState,
|
||||
mWorkspacePath);
|
||||
}
|
||||
|
||||
void Initialize(IPlasticAPI plasticApi, IPlasticWebRestApi plasticWebRestApi)
|
||||
{
|
||||
((IProgressControls)mProgressControls).ShowProgress(string.Empty);
|
||||
|
||||
WorkspaceInfo[] allWorkspaces = null;
|
||||
IList allRepositories = null;
|
||||
string repositoryProject = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
mDefaultServer = GetDefaultServer.ToCreateWorkspace(plasticWebRestApi);
|
||||
|
||||
allWorkspaces = plasticApi.GetAllWorkspacesArray();
|
||||
allRepositories = plasticApi.GetAllRepositories(mDefaultServer, true);
|
||||
|
||||
if (OrganizationsInformation.IsUnityOrganization(mDefaultServer))
|
||||
{
|
||||
List<string> serverProjects = OrganizationsInformation.GetOrganizationProjects(mDefaultServer);
|
||||
|
||||
if (serverProjects.Count > 0)
|
||||
{
|
||||
repositoryProject = serverProjects.First();
|
||||
}
|
||||
}
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
((IProgressControls) mProgressControls).HideProgress();
|
||||
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
DisplayException(mProgressControls, waiter.Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
string serverSpecPart = string.Format("@{0}", ResolveServer.ToDisplayString(mDefaultServer));
|
||||
|
||||
mCreateWorkspaceState.Repository = ValidRepositoryName.Get(
|
||||
string.Format("{0}{1}", mCreateWorkspaceState.Repository, serverSpecPart),
|
||||
allRepositories);
|
||||
|
||||
if (repositoryProject != null)
|
||||
{
|
||||
mCreateWorkspaceState.Repository = string.Format("{0}/{1}", repositoryProject, mCreateWorkspaceState.Repository);
|
||||
}
|
||||
|
||||
string proposedWorkspaceName = mCreateWorkspaceState.Repository.Replace(serverSpecPart, string.Empty);
|
||||
|
||||
mCreateWorkspaceState.WorkspaceName = CreateWorkspaceDialogUserAssistant.GetNonExistingWkNameForName(
|
||||
proposedWorkspaceName, allWorkspaces);
|
||||
|
||||
mDialogUserAssistant = CreateWorkspaceDialogUserAssistant.ForWkPathAndName(
|
||||
mWorkspacePath,
|
||||
allWorkspaces);
|
||||
|
||||
OnRepositoryChanged(
|
||||
mDialogUserAssistant,
|
||||
mCreateWorkspaceState,
|
||||
mWorkspacePath);
|
||||
});
|
||||
}
|
||||
|
||||
static void OnRepositoryChanged(
|
||||
CreateWorkspaceDialogUserAssistant dialogUserAssistant,
|
||||
CreateWorkspaceViewState createWorkspaceState,
|
||||
string workspacePath)
|
||||
{
|
||||
if (dialogUserAssistant == null)
|
||||
return;
|
||||
|
||||
dialogUserAssistant.RepositoryChanged(
|
||||
createWorkspaceState.Repository,
|
||||
createWorkspaceState.WorkspaceName,
|
||||
workspacePath);
|
||||
|
||||
createWorkspaceState.WorkspaceName =
|
||||
dialogUserAssistant.GetProposedWorkspaceName();
|
||||
}
|
||||
|
||||
void CreateRepository(RepositoryCreationData data)
|
||||
{
|
||||
if (!data.Result)
|
||||
return;
|
||||
|
||||
((IProgressControls)mProgressControls).ShowProgress(
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.CreatingRepository,
|
||||
data.RepName));
|
||||
|
||||
RepositoryInfo createdRepository = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter();
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
createdRepository = PlasticGui.Plastic.API.CreateRepository(
|
||||
data.ServerName, data.RepName);
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
((IProgressControls)mProgressControls).HideProgress();
|
||||
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
DisplayException(mProgressControls, waiter.Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
if (createdRepository == null)
|
||||
return;
|
||||
|
||||
mCreateWorkspaceState.Repository = createdRepository.GetRepSpec().ToDisplayString();
|
||||
});
|
||||
}
|
||||
|
||||
void ValidateAndCreateWorkspace(
|
||||
CreateWorkspaceViewState state)
|
||||
{
|
||||
mWkCreationData = BuildCreationDataFromState(state, mWorkspacePath);
|
||||
|
||||
// validation calls IPlasticDialogCloser.CloseDialog()
|
||||
// when the validation is ok
|
||||
WorkspaceCreationValidation.AsyncValidation(
|
||||
mWkCreationData, this, mProgressControls);
|
||||
}
|
||||
|
||||
void IPlasticDialogCloser.CloseDialog()
|
||||
{
|
||||
((IProgressControls) mProgressControls).ShowProgress(string.Empty);
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter(10);
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
RepositorySpec repSpec = new SpecGenerator().GenRepositorySpec(
|
||||
false, mWkCreationData.Repository, CmConnection.Get().UnityOrgResolver);
|
||||
|
||||
bool repositoryExist = PlasticGui.Plastic.API.CheckRepositoryExists(
|
||||
repSpec.Server, repSpec.Name);
|
||||
|
||||
if (!repositoryExist)
|
||||
PlasticGui.Plastic.API.CreateRepository(repSpec.Server, repSpec.Name);
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
((IProgressControls)mProgressControls).HideProgress();
|
||||
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
DisplayException(mProgressControls, waiter.Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
mWkCreationData.Result = true;
|
||||
mWorkspaceOperations.CreateWorkspace(mWkCreationData);
|
||||
|
||||
// the operation calls IWorkspacesRefreshableView.RefreshAndSelect
|
||||
// when the workspace is created
|
||||
});
|
||||
}
|
||||
|
||||
void IWorkspacesRefreshableView.RefreshAndSelect(WorkspaceInfo wkInfo)
|
||||
{
|
||||
PerformInitialCheckin.IfRepositoryIsEmpty(
|
||||
wkInfo,
|
||||
mWkCreationData.Repository,
|
||||
mWkCreationData.IsGluonWorkspace,
|
||||
PlasticGui.Plastic.API,
|
||||
mProgressControls,
|
||||
mCreateWorkspaceListener,
|
||||
mParentWindow);
|
||||
}
|
||||
|
||||
static WorkspaceCreationData BuildCreationDataFromState(
|
||||
CreateWorkspaceViewState state,
|
||||
string workspacePath)
|
||||
{
|
||||
// We need a conversion here because the actual repSpec is the one to be used during wk creation
|
||||
RepositorySpec repSpec = new SpecGenerator().GenRepositorySpec(
|
||||
false, state.Repository, CmConnection.Get().UnityOrgResolver);
|
||||
|
||||
return new WorkspaceCreationData(
|
||||
state.WorkspaceName,
|
||||
workspacePath,
|
||||
repSpec.ToString(),
|
||||
state.WorkspaceMode == CreateWorkspaceViewState.WorkspaceModes.Gluon,
|
||||
false);
|
||||
}
|
||||
|
||||
static void DisplayException(
|
||||
IProgressControls progressControls,
|
||||
Exception ex)
|
||||
{
|
||||
ExceptionsHandler.LogException(
|
||||
"CreateWorkspaceView", ex);
|
||||
|
||||
progressControls.ShowError(
|
||||
ExceptionsHandler.GetCorrectExceptionMessage(ex));
|
||||
}
|
||||
|
||||
class GetDefaultServer
|
||||
{
|
||||
internal static string ToCreateWorkspace(IPlasticWebRestApi plasticWebRestApi)
|
||||
{
|
||||
string clientConfServer = PlasticGui.Plastic.ConfigAPI.GetClientConfServer();
|
||||
|
||||
if (!EditionToken.IsCloudEdition())
|
||||
return clientConfServer;
|
||||
|
||||
string cloudServer = PlasticGuiConfig.Get().
|
||||
Configuration.DefaultCloudServer;
|
||||
|
||||
if (!string.IsNullOrEmpty(cloudServer))
|
||||
return cloudServer;
|
||||
|
||||
CloudEditionCreds.Data config =
|
||||
CloudEditionCreds.GetFromClientConf();
|
||||
|
||||
cloudServer = GetFirstCloudServer.
|
||||
GetCloudServer(plasticWebRestApi, config.Email, config.Password);
|
||||
|
||||
if (string.IsNullOrEmpty(cloudServer))
|
||||
return clientConfServer;
|
||||
|
||||
SaveCloudServer.ToPlasticGuiConfig(cloudServer);
|
||||
|
||||
return cloudServer;
|
||||
}
|
||||
}
|
||||
|
||||
WorkspaceCreationData mWkCreationData;
|
||||
CreateWorkspaceViewState mCreateWorkspaceState;
|
||||
|
||||
CreateWorkspaceDialogUserAssistant mDialogUserAssistant;
|
||||
|
||||
string mDefaultServer;
|
||||
|
||||
readonly WorkspaceOperations mWorkspaceOperations;
|
||||
readonly ProgressControlsForViews mProgressControls;
|
||||
readonly string mWorkspacePath;
|
||||
readonly ICreateWorkspaceListener mCreateWorkspaceListener;
|
||||
readonly PlasticWindow mParentWindow;
|
||||
readonly IPlasticWebRestApi mPlasticWebRestApi;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5294f667272fcb2438a79369c92cc7e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.CreateWorkspace
|
||||
{
|
||||
internal class CreateWorkspaceViewState
|
||||
{
|
||||
internal enum WorkspaceModes
|
||||
{
|
||||
Developer,
|
||||
Gluon
|
||||
}
|
||||
|
||||
internal string Repository { get; set; }
|
||||
internal string WorkspaceName { get; set; }
|
||||
internal WorkspaceModes WorkspaceMode { get; set; }
|
||||
internal ProgressControlsForViews.Data ProgressData { get; set; }
|
||||
|
||||
internal static CreateWorkspaceViewState BuildForProjectDefaults()
|
||||
{
|
||||
string projectName = Application.productName;
|
||||
|
||||
return new CreateWorkspaceViewState()
|
||||
{
|
||||
Repository = projectName,
|
||||
WorkspaceName = projectName,
|
||||
WorkspaceMode = WorkspaceModes.Developer,
|
||||
ProgressData = new ProgressControlsForViews.Data()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41633509da720014cbd77f755b378ce7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cecb087091caedf48adcc1cd3b0ebd6d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,385 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common;
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.CM.Common;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.Home.Repositories;
|
||||
using PlasticGui.WebApi;
|
||||
using PlasticGui.WorkspaceWindow.Servers;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.CreateWorkspace.Dialogs
|
||||
{
|
||||
internal class CreateRepositoryDialog :
|
||||
PlasticDialog,
|
||||
KnownServersListOperations.IKnownServersList
|
||||
{
|
||||
protected override Rect DefaultRect
|
||||
{
|
||||
get
|
||||
{
|
||||
var baseRect = base.DefaultRect;
|
||||
return new Rect(baseRect.x, baseRect.y, 600, 310);
|
||||
}
|
||||
}
|
||||
|
||||
internal static RepositoryCreationData CreateRepository(
|
||||
EditorWindow parentWindow,
|
||||
IPlasticWebRestApi plasticWebRestApi,
|
||||
string proposedRepositoryName,
|
||||
string proposedServer,
|
||||
string lastUsedRepServer,
|
||||
string clientConfServer)
|
||||
{
|
||||
string server = CreateRepositoryDialogUserAssistant.GetProposedServer(
|
||||
proposedServer, lastUsedRepServer, clientConfServer);
|
||||
|
||||
CreateRepositoryDialog dialog = Create(
|
||||
plasticWebRestApi,
|
||||
new ProgressControlsForDialogs(),
|
||||
proposedRepositoryName,
|
||||
server);
|
||||
|
||||
ResponseType dialogResult = dialog.RunModal(parentWindow);
|
||||
|
||||
RepositoryCreationData result = dialog.BuildCreationData();
|
||||
|
||||
result.Result = dialogResult == ResponseType.Ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override void OnModalGUI()
|
||||
{
|
||||
Title(PlasticLocalization.Name.NewRepositoryTitle.GetString());
|
||||
|
||||
Paragraph(PlasticLocalization.Name.NewRepositoryExplanation.GetString());
|
||||
|
||||
Paragraph(PlasticLocalization.Name.CreateRepositoryDialogDetailedExplanation.GetString());
|
||||
|
||||
if (Event.current.type == EventType.Layout)
|
||||
{
|
||||
mProgressControls.ProgressData.CopyInto(mProgressData);
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
DoEntriesArea();
|
||||
|
||||
DrawProgressForDialogs.For(mProgressControls.ProgressData);
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoButtonsArea();
|
||||
|
||||
mProgressControls.ForcedUpdateProgress(this);
|
||||
}
|
||||
|
||||
protected override string GetTitle()
|
||||
{
|
||||
return PlasticLocalization.Name.NewRepositoryTitle.GetString();
|
||||
}
|
||||
|
||||
void KnownServersListOperations.IKnownServersList.FillValues(List<string> knownServers)
|
||||
{
|
||||
mKnownServers = knownServers.Select(ResolveServer.ToDisplayString).ToList();
|
||||
mKnownServers.Sort();
|
||||
|
||||
OnServerSelected(mSelectedServer);
|
||||
}
|
||||
|
||||
void DoEntriesArea()
|
||||
{
|
||||
mRepositoryName = TextEntry(
|
||||
PlasticLocalization.Name.RepositoryNameShortLabel.GetString(),
|
||||
mRepositoryName,
|
||||
REPONAME_CONTROL_NAME,
|
||||
ENTRY_WIDTH,
|
||||
ENTRY_X);
|
||||
|
||||
if (!mFocusIsAreadySet)
|
||||
{
|
||||
mFocusIsAreadySet = true;
|
||||
GUI.FocusControl(REPONAME_CONTROL_NAME);
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
mSelectedServer = ComboBox(
|
||||
PlasticLocalization.Name.RepositoryServerOrOrganizationLabel.GetString(),
|
||||
mSelectedServer,
|
||||
mKnownServers,
|
||||
OnServerSelected,
|
||||
ENTRY_WIDTH,
|
||||
ENTRY_X);
|
||||
|
||||
if (OrganizationsInformation.IsUnityOrganization(mSelectedServer))
|
||||
{
|
||||
GUILayout.Space(5);
|
||||
|
||||
DoOrganizationProjectsDropdown();
|
||||
DoCreateOrganizationProjectLink();
|
||||
}
|
||||
}
|
||||
|
||||
void DoOrganizationProjectsDropdown()
|
||||
{
|
||||
if (mSelectedProject == null)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
ComboBox(
|
||||
PlasticLocalization.Name.OrganizationProjectLabel.GetString(),
|
||||
mSelectedProject,
|
||||
mCurrentServerProjects,
|
||||
OnProjectSelected,
|
||||
ENTRY_WIDTH,
|
||||
ENTRY_X);
|
||||
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
void DoCreateOrganizationProjectLink()
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button(
|
||||
PlasticLocalization.Name.CreateOrganizationProjectLabel.GetString(),
|
||||
UnityStyles.LinkLabel,
|
||||
GUILayout.Height(20)))
|
||||
{
|
||||
// TODO refactor this code once the new changes in the OrganizationInfo are available
|
||||
string serverName = ResolveServer.FromUserInput(mSelectedServer, CmConnection.Get().UnityOrgResolver);
|
||||
string organizationName = ServerOrganizationParser.GetOrganizationFromServer(serverName);
|
||||
|
||||
Application.OpenURL(UnityUrl.UnityDashboard.UnityOrganizations.GetProjectsUrl(organizationName));
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
void OnServerSelected(object server)
|
||||
{
|
||||
((IProgressControls) mProgressControls).HideProgress();
|
||||
mProgressControls.ProgressData.StatusMessage = string.Empty;
|
||||
mProgressControls.ProgressData.StatusType = MessageType.None;
|
||||
|
||||
mIsLoadingProjects = false;
|
||||
|
||||
if (server == null || string.IsNullOrEmpty(server.ToString()))
|
||||
{
|
||||
mSelectedServer = null;
|
||||
mSelectedProject = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mSelectedServer = server.ToString();
|
||||
|
||||
// We need to ensure it is a known server because the dropdown is editable
|
||||
if (OrganizationsInformation.IsUnityOrganization(mSelectedServer) && mKnownServers.Contains(mSelectedServer))
|
||||
{
|
||||
LoadServerProjects(mSelectedServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSelectedProject = null;
|
||||
}
|
||||
|
||||
Repaint();
|
||||
}
|
||||
|
||||
void OnFocus()
|
||||
{
|
||||
OnServerSelected(mSelectedServer);
|
||||
}
|
||||
|
||||
void OnProjectSelected(object project)
|
||||
{
|
||||
mSelectedProject = project.ToString();
|
||||
|
||||
Repaint();
|
||||
}
|
||||
|
||||
void LoadServerProjects(string server)
|
||||
{
|
||||
mIsLoadingProjects = true;
|
||||
|
||||
((IProgressControls) mProgressControls).ShowProgress(
|
||||
PlasticLocalization.Name.RetrievingServerProjects.GetString());
|
||||
|
||||
List<string> serverProjects = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter();
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
string serverName = ResolveServer.FromUserInput(server, CmConnection.Get().UnityOrgResolver);
|
||||
|
||||
serverProjects = OrganizationsInformation.GetOrganizationProjects(serverName);
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
mIsLoadingProjects = false;
|
||||
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
((IProgressControls) mProgressControls).ShowError(
|
||||
PlasticLocalization.Name.ErrorRetrievingServerProjects.GetString());
|
||||
}
|
||||
|
||||
mCurrentServerProjects = serverProjects;
|
||||
|
||||
if (mCurrentServerProjects == null || mCurrentServerProjects.Count == 0)
|
||||
{
|
||||
mSelectedProject = null;
|
||||
|
||||
((IProgressControls) mProgressControls).ShowError(
|
||||
PlasticLocalization.Name.NoServerProjectsFound.GetString());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(mSelectedProject) || !mCurrentServerProjects.Contains(mSelectedProject))
|
||||
{
|
||||
mSelectedProject = mCurrentServerProjects.First();
|
||||
}
|
||||
|
||||
((IProgressControls) mProgressControls).HideProgress();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void DoButtonsArea()
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (mIsLoadingProjects)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
DoOkButton();
|
||||
DoCancelButton();
|
||||
return;
|
||||
}
|
||||
|
||||
DoCancelButton();
|
||||
DoOkButton();
|
||||
}
|
||||
}
|
||||
|
||||
void DoOkButton()
|
||||
{
|
||||
if (!AcceptButton(PlasticLocalization.Name.OkButton.GetString()))
|
||||
return;
|
||||
|
||||
OkButtonWithValidationAction();
|
||||
}
|
||||
|
||||
void DoCancelButton()
|
||||
{
|
||||
if (!NormalButton(PlasticLocalization.Name.CancelButton.GetString()))
|
||||
return;
|
||||
|
||||
CancelButtonAction();
|
||||
}
|
||||
|
||||
void OkButtonWithValidationAction()
|
||||
{
|
||||
RepositoryCreationValidation.AsyncValidation(
|
||||
BuildCreationData(),
|
||||
this,
|
||||
mProgressControls);
|
||||
}
|
||||
|
||||
RepositoryCreationData BuildCreationData()
|
||||
{
|
||||
string repositoryName = mSelectedProject != null
|
||||
? string.Format("{0}/{1}", mSelectedProject, mRepositoryName)
|
||||
: mRepositoryName;
|
||||
|
||||
return new RepositoryCreationData(
|
||||
repositoryName,
|
||||
ResolveServer.FromUserInput(mSelectedServer, CmConnection.Get().UnityOrgResolver));
|
||||
}
|
||||
|
||||
static CreateRepositoryDialog Create(
|
||||
IPlasticWebRestApi plasticWebRestApi,
|
||||
ProgressControlsForDialogs progressControls,
|
||||
string proposedRepositoryName,
|
||||
string proposedServer)
|
||||
{
|
||||
var instance = CreateInstance<CreateRepositoryDialog>();
|
||||
instance.mEnterKeyAction = instance.OkButtonWithValidationAction;
|
||||
instance.mEscapeKeyAction = instance.CancelButtonAction;
|
||||
instance.mPlasticWebRestApi = plasticWebRestApi;
|
||||
instance.mProgressControls = progressControls;
|
||||
instance.BuildComponents(proposedRepositoryName, proposedServer);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void BuildComponents(string proposedRepositoryName, string proposedServer)
|
||||
{
|
||||
mSelectedServer = ResolveServer.ToDisplayString(proposedServer);
|
||||
mSelectedProject = null;
|
||||
|
||||
mRepositoryName = proposedRepositoryName;
|
||||
if (OrganizationsInformation.IsUnityOrganization(proposedServer))
|
||||
{
|
||||
string[] repositoryNameParts = proposedRepositoryName.Split('/');
|
||||
|
||||
if (repositoryNameParts.Length > 1)
|
||||
{
|
||||
mRepositoryName = repositoryNameParts[repositoryNameParts.Length - 1].Trim();
|
||||
}
|
||||
}
|
||||
|
||||
KnownServersListOperations.GetCombinedServers(
|
||||
true,
|
||||
GetExtraServers(proposedServer),
|
||||
mProgressControls,
|
||||
this,
|
||||
mPlasticWebRestApi,
|
||||
CmConnection.Get().GetProfileManager());
|
||||
}
|
||||
|
||||
static List<string> GetExtraServers(string proposedServer)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
if (!string.IsNullOrEmpty(proposedServer))
|
||||
result.Add(proposedServer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
IPlasticWebRestApi mPlasticWebRestApi;
|
||||
bool mFocusIsAreadySet;
|
||||
|
||||
string mRepositoryName;
|
||||
string mSelectedServer;
|
||||
string mSelectedProject;
|
||||
bool mIsLoadingProjects;
|
||||
|
||||
List<string> mKnownServers = new List<string>();
|
||||
List<string> mCurrentServerProjects = new List<string>();
|
||||
|
||||
ProgressControlsForDialogs.Data mProgressData = new ProgressControlsForDialogs.Data();
|
||||
|
||||
ProgressControlsForDialogs mProgressControls;
|
||||
|
||||
const float ENTRY_WIDTH = 400;
|
||||
const float ENTRY_X = 175f;
|
||||
const string REPONAME_CONTROL_NAME = "CreateRepositoryDialog.RepositoryName";
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61f74d0a8a3f1f542b8afe99e65686df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.CreateWorkspace.Dialogs
|
||||
{
|
||||
internal enum RepositoriesListColumn
|
||||
{
|
||||
Name,
|
||||
Server
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class RepositoriesListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
|
||||
{
|
||||
internal static RepositoriesListHeaderState GetDefault()
|
||||
{
|
||||
return new RepositoriesListHeaderState(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.ServerColumn));
|
||||
return result;
|
||||
}
|
||||
|
||||
static string GetColumnName(RepositoriesListColumn column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case RepositoriesListColumn.Name:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.NameColumn);
|
||||
case RepositoriesListColumn.Server:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.ServerColumn);
|
||||
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 = 320,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(RepositoriesListColumn.Name)),
|
||||
minWidth = 200,
|
||||
allowToggleVisibility = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = 200,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(RepositoriesListColumn.Server)),
|
||||
minWidth = 200,
|
||||
allowToggleVisibility = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
RepositoriesListHeaderState(Column[] columns)
|
||||
: base(columns)
|
||||
{
|
||||
if (mHeaderTitles == null)
|
||||
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user