first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Shelves
|
||||
{
|
||||
class ShelveListViewItem : TreeViewItem
|
||||
{
|
||||
internal object ObjectInfo { get; private set; }
|
||||
|
||||
internal ShelveListViewItem(int id, object objectInfo)
|
||||
: base(id, 1)
|
||||
{
|
||||
ObjectInfo = objectInfo;
|
||||
|
||||
displayName = id.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcc8e3fcf0e9fb0478604e86fa679bcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Shelves
|
||||
{
|
||||
internal enum ShelvesListColumn
|
||||
{
|
||||
Name,
|
||||
CreationDate,
|
||||
Comment,
|
||||
CreatedBy,
|
||||
Repository
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal class ShelvesListHeaderState : MultiColumnHeaderState, ISerializationCallbackReceiver
|
||||
{
|
||||
internal static ShelvesListHeaderState GetDefault()
|
||||
{
|
||||
return new ShelvesListHeaderState(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.CommentColumn));
|
||||
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.CreatedByColumn));
|
||||
result.Add(PlasticLocalization.GetString(PlasticLocalization.Name.RepositoryColumn));
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetColumnName(ShelvesListColumn column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case ShelvesListColumn.Name:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.NameColumn);
|
||||
case ShelvesListColumn.CreationDate:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.CreationDateColumn);
|
||||
case ShelvesListColumn.Comment:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.CommentColumn);
|
||||
case ShelvesListColumn.CreatedBy:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.CreatedByColumn);
|
||||
case ShelvesListColumn.Repository:
|
||||
return PlasticLocalization.GetString(PlasticLocalization.Name.RepositoryColumn);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (mHeaderTitles != null)
|
||||
TreeHeaderColumns.SetTitles(columns, mHeaderTitles);
|
||||
|
||||
if (mColumnsAllowedToggleVisibility != null)
|
||||
TreeHeaderColumns.SetVisibilities(columns, mColumnsAllowedToggleVisibility);
|
||||
}
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
static Column[] BuildColumns()
|
||||
{
|
||||
return new Column[]
|
||||
{
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ShelvesColumns.SHELVES_NAME_WIDTH,
|
||||
minWidth = UnityConstants.ShelvesColumns.SHELVES_NAME_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ShelvesListColumn.Name)),
|
||||
allowToggleVisibility = false,
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ShelvesColumns.CREATION_DATE_WIDTH,
|
||||
minWidth = UnityConstants.ShelvesColumns.CREATION_DATE_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ShelvesListColumn.CreationDate)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ShelvesColumns.COMMENT_WIDTH,
|
||||
minWidth = UnityConstants.ShelvesColumns.COMMENT_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ShelvesListColumn.Comment)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ShelvesColumns.CREATEDBY_WIDTH,
|
||||
minWidth = UnityConstants.ShelvesColumns.CREATEDBY_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ShelvesListColumn.CreatedBy)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
},
|
||||
new Column()
|
||||
{
|
||||
width = UnityConstants.ShelvesColumns.REPOSITORY_WIDTH,
|
||||
minWidth = UnityConstants.ShelvesColumns.REPOSITORY_MIN_WIDTH,
|
||||
headerContent = new GUIContent(
|
||||
GetColumnName(ShelvesListColumn.Repository)),
|
||||
sortingArrowAlignment = TextAlignment.Right
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ShelvesListHeaderState(Column[] columns)
|
||||
: base(columns)
|
||||
{
|
||||
if (mHeaderTitles == null)
|
||||
mHeaderTitles = TreeHeaderColumns.GetTitles(columns);
|
||||
|
||||
if (mColumnsAllowedToggleVisibility == null)
|
||||
mColumnsAllowedToggleVisibility = TreeHeaderColumns.GetVisibilities(columns);
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
string[] mHeaderTitles;
|
||||
|
||||
[SerializeField]
|
||||
bool[] mColumnsAllowedToggleVisibility;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c197d289bbe8d4e418c3de49a40fd1b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,403 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
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.Shelves
|
||||
{
|
||||
internal class ShelvesListView : PlasticTreeView
|
||||
{
|
||||
internal GenericMenu Menu { get { return mMenu.Menu; } }
|
||||
|
||||
internal ShelvesListView(
|
||||
ShelvesListHeaderState headerState,
|
||||
List<string> columnNames,
|
||||
ShelvesViewMenu menu,
|
||||
Action sizeChangedAction,
|
||||
Action selectionChangedAction,
|
||||
Action doubleClickAction)
|
||||
{
|
||||
mColumnNames = columnNames;
|
||||
mMenu = menu;
|
||||
mSizeChangedAction = sizeChangedAction;
|
||||
mSelectionChangedAction = selectionChangedAction;
|
||||
mDoubleClickAction = doubleClickAction;
|
||||
|
||||
multiColumnHeader = new MultiColumnHeader(headerState);
|
||||
multiColumnHeader.canSort = true;
|
||||
multiColumnHeader.sortingChanged += SortingChanged;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
protected override IList<TreeViewItem> BuildRows(
|
||||
TreeViewItem rootItem)
|
||||
{
|
||||
if (mQueryResult == null)
|
||||
{
|
||||
ClearRows(rootItem, mRows);
|
||||
|
||||
return mRows;
|
||||
}
|
||||
|
||||
RegenerateRows(
|
||||
mListViewItemIds,
|
||||
mQueryResult.GetObjects(),
|
||||
rootItem,
|
||||
mRows);
|
||||
|
||||
return mRows;
|
||||
}
|
||||
|
||||
protected override void SearchChanged(string newSearch)
|
||||
{
|
||||
mCooldownFilterAction.Ping();
|
||||
}
|
||||
|
||||
protected override void ContextClickedItem(int id)
|
||||
{
|
||||
mMenu.Popup();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect rect)
|
||||
{
|
||||
if (Event.current.type == EventType.Layout)
|
||||
{
|
||||
if (IsSizeChanged(treeViewRect, mLastRect))
|
||||
mSizeChangedAction();
|
||||
}
|
||||
|
||||
mLastRect = treeViewRect;
|
||||
|
||||
base.OnGUI(rect);
|
||||
|
||||
Event e = Event.current;
|
||||
|
||||
if (e.type != EventType.KeyDown)
|
||||
return;
|
||||
|
||||
bool isProcessed = mMenu.ProcessKeyActionIfNeeded(e);
|
||||
|
||||
if (isProcessed)
|
||||
e.Use();
|
||||
}
|
||||
|
||||
protected override void RowGUI(RowGUIArgs args)
|
||||
{
|
||||
if (args.item is ShelveListViewItem)
|
||||
{
|
||||
ShelveListViewItem shelveListViewItem = (ShelveListViewItem)args.item;
|
||||
|
||||
ShelvesListViewItemGUI(
|
||||
mQueryResult,
|
||||
rowHeight,
|
||||
shelveListViewItem,
|
||||
args,
|
||||
Repaint);
|
||||
return;
|
||||
}
|
||||
|
||||
base.RowGUI(args);
|
||||
}
|
||||
|
||||
protected override void DoubleClickedItem(int id)
|
||||
{
|
||||
if (GetSelection().Count != 1)
|
||||
return;
|
||||
|
||||
mDoubleClickAction();
|
||||
}
|
||||
|
||||
internal void BuildModel(ViewQueryResult queryResult)
|
||||
{
|
||||
mListViewItemIds.Clear();
|
||||
|
||||
mQueryResult = queryResult;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
ShelveListViewItem shelveListViewItem =
|
||||
new ShelveListViewItem(objectId, objectInfo);
|
||||
|
||||
rootItem.AddChild(shelveListViewItem);
|
||||
rows.Add(shelveListViewItem);
|
||||
}
|
||||
}
|
||||
|
||||
static void ClearRows(
|
||||
TreeViewItem rootItem,
|
||||
List<TreeViewItem> rows)
|
||||
{
|
||||
if (rootItem.hasChildren)
|
||||
rootItem.children.Clear();
|
||||
|
||||
rows.Clear();
|
||||
}
|
||||
|
||||
static void ShelvesListViewItemGUI(
|
||||
ViewQueryResult queryResult,
|
||||
float rowHeight,
|
||||
ShelveListViewItem item,
|
||||
RowGUIArgs args,
|
||||
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;
|
||||
}
|
||||
|
||||
ShelvesListColumn column =
|
||||
(ShelvesListColumn)args.GetColumn(visibleColumnIdx);
|
||||
|
||||
ShelvesListViewItemCellGUI(
|
||||
cellRect,
|
||||
rowHeight,
|
||||
queryResult,
|
||||
item,
|
||||
column,
|
||||
avatarLoadedAction,
|
||||
args.selected,
|
||||
args.focused);
|
||||
}
|
||||
}
|
||||
|
||||
static void ShelvesListViewItemCellGUI(
|
||||
Rect rect,
|
||||
float rowHeight,
|
||||
ViewQueryResult queryResult,
|
||||
ShelveListViewItem item,
|
||||
ShelvesListColumn column,
|
||||
Action avatarLoadedAction,
|
||||
bool isSelected,
|
||||
bool isFocused)
|
||||
{
|
||||
string columnText = RepObjectInfoView.GetColumnText(
|
||||
queryResult.GetRepositorySpec(item.ObjectInfo),
|
||||
queryResult.GetRepObjectInfo(item.ObjectInfo),
|
||||
ShelvesListHeaderState.GetColumnName(column));
|
||||
|
||||
if (column == ShelvesListColumn.CreatedBy)
|
||||
{
|
||||
DrawTreeViewItem.ForItemCell(
|
||||
rect,
|
||||
rowHeight,
|
||||
-1,
|
||||
GetAvatar.ForEmail(columnText, avatarLoadedAction),
|
||||
null,
|
||||
columnText,
|
||||
isSelected,
|
||||
isFocused,
|
||||
false,
|
||||
false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (column == ShelvesListColumn.Repository)
|
||||
{
|
||||
DrawTreeViewItem.ForSecondaryLabel(
|
||||
rect, columnText, isSelected, isFocused, false);
|
||||
return;
|
||||
}
|
||||
|
||||
DrawTreeViewItem.ForLabel(
|
||||
rect, columnText, isSelected, isFocused, false);
|
||||
}
|
||||
|
||||
static bool IsSizeChanged(
|
||||
Rect currentRect, Rect lastRect)
|
||||
{
|
||||
if (currentRect.width != lastRect.width)
|
||||
return true;
|
||||
|
||||
if (currentRect.height != lastRect.height)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Rect mLastRect;
|
||||
|
||||
ListViewItemIds<object> mListViewItemIds = new ListViewItemIds<object>();
|
||||
|
||||
ViewQueryResult mQueryResult;
|
||||
|
||||
readonly CooldownWindowDelayer mCooldownFilterAction;
|
||||
readonly CooldownWindowDelayer mCooldownSelectionAction;
|
||||
readonly Action mDoubleClickAction;
|
||||
readonly Action mSelectionChangedAction;
|
||||
readonly Action mSizeChangedAction;
|
||||
readonly ShelvesViewMenu mMenu;
|
||||
readonly List<string> mColumnNames;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12617ab1a25fb574c85cdfaf5129d59d
|
||||
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.Shelves
|
||||
{
|
||||
internal static class ShelvesSelection
|
||||
{
|
||||
internal static void SelectShelves(
|
||||
ShelvesListView listView,
|
||||
List<RepObjectInfo> shelvesToSelect,
|
||||
int defaultRow)
|
||||
{
|
||||
if (shelvesToSelect == null || shelvesToSelect.Count == 0)
|
||||
{
|
||||
TableViewOperations.SelectFirstRow(listView);
|
||||
return;
|
||||
}
|
||||
|
||||
listView.SelectRepObjectInfos(shelvesToSelect);
|
||||
|
||||
if (listView.HasSelection())
|
||||
return;
|
||||
|
||||
TableViewOperations.SelectDefaultRow(listView, defaultRow);
|
||||
|
||||
if (listView.HasSelection())
|
||||
return;
|
||||
|
||||
TableViewOperations.SelectFirstRow(listView);
|
||||
}
|
||||
|
||||
internal static List<RepObjectInfo> GetSelectedRepObjectInfos(
|
||||
ShelvesListView listView)
|
||||
{
|
||||
return listView.GetSelectedRepObjectInfos();
|
||||
}
|
||||
|
||||
internal static int GetSelectedShelvesCount(
|
||||
ShelvesListView listView)
|
||||
{
|
||||
return listView.GetSelection().Count;
|
||||
}
|
||||
|
||||
internal static ChangesetInfo GetSelectedShelve(
|
||||
ShelvesListView listView)
|
||||
{
|
||||
List<RepObjectInfo> selectedRepObjectsInfos = listView.GetSelectedRepObjectInfos();
|
||||
|
||||
if (selectedRepObjectsInfos.Count == 0)
|
||||
return null;
|
||||
|
||||
return (ChangesetInfo)selectedRepObjectsInfos[0];
|
||||
}
|
||||
|
||||
internal static List<ChangesetInfo> GetSelectedShelves(
|
||||
ShelvesListView listView)
|
||||
{
|
||||
return listView.GetSelectedRepObjectInfos().Cast<ChangesetInfo>().ToList();
|
||||
}
|
||||
|
||||
internal static RepositorySpec GetSelectedRepository(
|
||||
ShelvesListView listView)
|
||||
{
|
||||
List<RepositorySpec> selectedRepositories = listView.GetSelectedRepositories();
|
||||
|
||||
if (selectedRepositories.Count == 0)
|
||||
return null;
|
||||
|
||||
return selectedRepositories[0];
|
||||
}
|
||||
|
||||
internal static List<RepositorySpec> GetSelectedRepositories(
|
||||
ShelvesListView listView)
|
||||
{
|
||||
return listView.GetSelectedRepositories();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2ca16ee0b283be4f95ca8c96e549d3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,493 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
using Codice.Client.Common.Threading;
|
||||
using Codice.CM.Common;
|
||||
using Codice.CM.Common.Mount;
|
||||
using GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer;
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews.Shelves;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils;
|
||||
using Unity.PlasticSCM.Editor.AssetUtils.Processor;
|
||||
using Unity.PlasticSCM.Editor.Tool;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
using Unity.PlasticSCM.Editor.UI.Progress;
|
||||
using Unity.PlasticSCM.Editor.UI.Tree;
|
||||
using Unity.PlasticSCM.Editor.Views.Changesets;
|
||||
using Unity.PlasticSCM.Editor.Views.Diff;
|
||||
|
||||
using GluonShelveOperations = GluonGui.WorkspaceWindow.Views.Shelves.ShelveOperations;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Shelves
|
||||
{
|
||||
internal partial class ShelvesTab :
|
||||
IRefreshableView,
|
||||
IShelveMenuOperations
|
||||
{
|
||||
internal string EmptyStateMessage { get { return mEmptyStateData.Content.text; } }
|
||||
internal ShelvesListView Table { get { return mShelvesListView; } }
|
||||
internal IShelveMenuOperations Operations { get { return this; } }
|
||||
internal IProgressControls ProgressControls { get { return mProgressControls; } }
|
||||
|
||||
internal ShelvesTab(
|
||||
WorkspaceInfo wkInfo,
|
||||
RepositorySpec repSpec,
|
||||
WorkspaceWindow workspaceWindow,
|
||||
ChangesetInfo shelveToSelect,
|
||||
IViewSwitcher viewSwitcher,
|
||||
IMergeViewLauncher mergeViewLauncher,
|
||||
GluonShelveOperations.ICheckinView pendingChangesTab,
|
||||
IProgressOperationHandler progressOperationHandler,
|
||||
IUpdateProgress updateProgress,
|
||||
IHistoryViewLauncher historyViewLauncher,
|
||||
IShelvedChangesUpdater shelvedChangesUpdater,
|
||||
LaunchTool.IShowDownloadPlasticExeWindow showDownloadPlasticExeWindow,
|
||||
LaunchTool.IProcessExecutor processExecutor,
|
||||
WorkspaceOperationsMonitor workspaceOperationsMonitor,
|
||||
ISaveAssets saveAssets,
|
||||
EditorWindow parentWindow,
|
||||
bool isGluonMode)
|
||||
{
|
||||
mWkInfo = wkInfo;
|
||||
mRepSpec = repSpec;
|
||||
mRefreshView = workspaceWindow;
|
||||
mMergeViewLauncher = mergeViewLauncher;
|
||||
mPendingChangesTab = pendingChangesTab;
|
||||
mProgressOperationHandler = progressOperationHandler;
|
||||
mUpdateProgress = updateProgress;
|
||||
mShelvedChangesUpdater = shelvedChangesUpdater;
|
||||
mShowDownloadPlasticExeWindow = showDownloadPlasticExeWindow;
|
||||
mProcessExecutor = processExecutor;
|
||||
mWorkspaceOperationsMonitor = workspaceOperationsMonitor;
|
||||
mSaveAssets = saveAssets;
|
||||
mParentWindow = parentWindow;
|
||||
mIsGluonMode = isGluonMode;
|
||||
|
||||
mProgressControls = new ProgressControlsForViews();
|
||||
|
||||
BuildComponents(
|
||||
wkInfo,
|
||||
workspaceWindow,
|
||||
workspaceWindow,
|
||||
viewSwitcher,
|
||||
historyViewLauncher,
|
||||
parentWindow);
|
||||
|
||||
mSplitterState = PlasticSplitterGUILayout.InitSplitterState(
|
||||
new float[] { 0.50f, 0.50f },
|
||||
new int[] { 100, (int)UnityConstants.DIFF_PANEL_MIN_WIDTH },
|
||||
new int[] { 100000, 100000 }
|
||||
);
|
||||
|
||||
RefreshAndSelect(shelveToSelect);
|
||||
}
|
||||
|
||||
internal void OnEnable()
|
||||
{
|
||||
mDiffPanel.OnEnable();
|
||||
|
||||
mSearchField.downOrUpArrowKeyPressed +=
|
||||
SearchField_OnDownOrUpArrowKeyPressed;
|
||||
}
|
||||
|
||||
internal void OnDisable()
|
||||
{
|
||||
mDiffPanel.OnDisable();
|
||||
|
||||
mSearchField.downOrUpArrowKeyPressed -=
|
||||
SearchField_OnDownOrUpArrowKeyPressed;
|
||||
|
||||
TreeHeaderSettings.Save(
|
||||
mShelvesListView.multiColumnHeader.state,
|
||||
UnityConstants.SHELVES_TABLE_SETTINGS_NAME);
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
mDiffPanel.Update();
|
||||
|
||||
mProgressControls.UpdateProgress(mParentWindow);
|
||||
}
|
||||
|
||||
internal void OnGUI()
|
||||
{
|
||||
DoActionsToolbar(mProgressControls);
|
||||
|
||||
PlasticSplitterGUILayout.BeginHorizontalSplit(mSplitterState);
|
||||
|
||||
DoShelvesArea(
|
||||
mShelvesListView,
|
||||
mEmptyStateData,
|
||||
mProgressControls.IsOperationRunning(),
|
||||
mParentWindow.Repaint);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
Rect border = GUILayoutUtility.GetRect(1, 0, 1, 100000);
|
||||
EditorGUI.DrawRect(border, UnityStyles.Colors.BarBorder);
|
||||
|
||||
DoChangesArea(mDiffPanel);
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
PlasticSplitterGUILayout.EndHorizontalSplit();
|
||||
}
|
||||
|
||||
internal void DrawSearchFieldForTab()
|
||||
{
|
||||
DrawSearchField.For(
|
||||
mSearchField,
|
||||
mShelvesListView,
|
||||
UnityConstants.SEARCH_FIELD_WIDTH);
|
||||
}
|
||||
|
||||
internal void DrawOwnerFilter()
|
||||
{
|
||||
GUI.enabled = !mProgressControls.IsOperationRunning();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
mOwnerFilter = (OwnerFilter)
|
||||
EditorGUILayout.EnumPopup(
|
||||
mOwnerFilter,
|
||||
EditorStyles.toolbarDropDown,
|
||||
GUILayout.Width(100));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EnumPopupSetting<OwnerFilter>.Save(
|
||||
mOwnerFilter,
|
||||
UnityConstants.SHELVES_OWNER_FILTER_SETTING_NAME);
|
||||
|
||||
((IRefreshableView)this).Refresh();
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
void IRefreshableView.Refresh()
|
||||
{
|
||||
RefreshAndSelect(null);
|
||||
}
|
||||
|
||||
//IQueryRefreshableView
|
||||
public void RefreshAndSelect(RepObjectInfo repObj)
|
||||
{
|
||||
List<RepObjectInfo> shelvesToSelect = repObj == null ?
|
||||
ShelvesSelection.GetSelectedRepObjectInfos(mShelvesListView) :
|
||||
new List<RepObjectInfo> { repObj };
|
||||
|
||||
FillShelves(
|
||||
mWkInfo,
|
||||
QueryConstants.BuildShelvesQuery(mOwnerFilter == OwnerFilter.MyShelves),
|
||||
shelvesToSelect);
|
||||
}
|
||||
|
||||
int IShelveMenuOperations.GetSelectedShelvesCount()
|
||||
{
|
||||
return ShelvesSelection.GetSelectedShelvesCount(mShelvesListView);
|
||||
}
|
||||
|
||||
void IShelveMenuOperations.OpenSelectedShelveInNewWindow()
|
||||
{
|
||||
LaunchDiffOperations.DiffChangeset(
|
||||
mShowDownloadPlasticExeWindow,
|
||||
mProcessExecutor,
|
||||
ShelvesSelection.GetSelectedRepository(mShelvesListView),
|
||||
ShelvesSelection.GetSelectedShelve(mShelvesListView),
|
||||
mIsGluonMode);
|
||||
}
|
||||
|
||||
void IShelveMenuOperations.ApplyShelveInWorkspace()
|
||||
{
|
||||
bool isCancelled;
|
||||
mSaveAssets.UnderWorkspaceWithConfirmation(
|
||||
mWkInfo.ClientPath, mWorkspaceOperationsMonitor,
|
||||
out isCancelled);
|
||||
|
||||
if (isCancelled)
|
||||
return;
|
||||
|
||||
ChangesetInfo shelveToApply = ShelvesSelection.GetSelectedShelve(mShelvesListView);
|
||||
|
||||
if (mIsGluonMode)
|
||||
{
|
||||
GluonShelveOperations.ApplyPartialShelveset(
|
||||
mWkInfo,
|
||||
shelveToApply,
|
||||
mRefreshView,
|
||||
PlasticExeLauncher.BuildForResolveConflicts(
|
||||
mWkInfo, true, mShowDownloadPlasticExeWindow),
|
||||
this,
|
||||
mProgressControls,
|
||||
mPendingChangesTab,
|
||||
mUpdateProgress,
|
||||
mProgressOperationHandler,
|
||||
mShelvedChangesUpdater);
|
||||
return;
|
||||
}
|
||||
|
||||
ShelveOperations.ApplyShelveInWorkspace(
|
||||
mRepSpec,
|
||||
shelveToApply,
|
||||
mMergeViewLauncher,
|
||||
mProgressOperationHandler);
|
||||
}
|
||||
|
||||
void IShelveMenuOperations.DeleteShelve()
|
||||
{
|
||||
ShelveOperations.DeleteShelve(
|
||||
ShelvesSelection.GetSelectedRepositories(mShelvesListView),
|
||||
ShelvesSelection.GetSelectedShelves(mShelvesListView),
|
||||
this,
|
||||
mProgressControls,
|
||||
mShelvedChangesUpdater);
|
||||
}
|
||||
|
||||
void SearchField_OnDownOrUpArrowKeyPressed()
|
||||
{
|
||||
mShelvesListView.SetFocusAndEnsureSelectedItem();
|
||||
}
|
||||
|
||||
void OnShelvesListViewSizeChanged()
|
||||
{
|
||||
if (!mShouldScrollToSelection)
|
||||
return;
|
||||
|
||||
mShouldScrollToSelection = false;
|
||||
TableViewOperations.ScrollToSelection(mShelvesListView);
|
||||
}
|
||||
|
||||
void OnSelectionChanged()
|
||||
{
|
||||
List<RepObjectInfo> selectedShelves = ShelvesSelection.
|
||||
GetSelectedRepObjectInfos(mShelvesListView);
|
||||
|
||||
if (selectedShelves.Count != 1)
|
||||
return;
|
||||
|
||||
mDiffPanel.UpdateInfo(
|
||||
MountPointWithPath.BuildWorkspaceRootMountPoint(
|
||||
ShelvesSelection.GetSelectedRepository(mShelvesListView)),
|
||||
(ChangesetInfo)selectedShelves[0]);
|
||||
}
|
||||
|
||||
void FillShelves(
|
||||
WorkspaceInfo wkInfo,
|
||||
string query,
|
||||
List<RepObjectInfo> shelvesToSelect)
|
||||
{
|
||||
if (mIsRefreshing)
|
||||
return;
|
||||
|
||||
mIsRefreshing = true;
|
||||
|
||||
int defaultRow = TableViewOperations.
|
||||
GetFirstSelectedRow(mShelvesListView);
|
||||
|
||||
((IProgressControls)mProgressControls).ShowProgress(
|
||||
PlasticLocalization.GetString(
|
||||
PlasticLocalization.Name.LoadingShelves));
|
||||
|
||||
ViewQueryResult queryResult = null;
|
||||
|
||||
IThreadWaiter waiter = ThreadWaiter.GetWaiter();
|
||||
waiter.Execute(
|
||||
/*threadOperationDelegate*/ delegate
|
||||
{
|
||||
queryResult = new ViewQueryResult(
|
||||
PlasticGui.Plastic.API.FindQuery(wkInfo, query));
|
||||
},
|
||||
/*afterOperationDelegate*/ delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
if (waiter.Exception != null)
|
||||
{
|
||||
mDiffPanel.ClearInfo();
|
||||
|
||||
ExceptionsHandler.DisplayException(waiter.Exception);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateShelvesList(mShelvesListView, queryResult);
|
||||
|
||||
int shelvesCount = GetShelvesCount(queryResult);
|
||||
|
||||
if (shelvesCount == 0)
|
||||
{
|
||||
mDiffPanel.ClearInfo();
|
||||
return;
|
||||
}
|
||||
|
||||
ShelvesSelection.SelectShelves(
|
||||
mShelvesListView, shelvesToSelect, defaultRow);
|
||||
}
|
||||
finally
|
||||
{
|
||||
((IProgressControls)mProgressControls).HideProgress();
|
||||
mIsRefreshing = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void UpdateShelvesList(
|
||||
ShelvesListView shelvesListView,
|
||||
ViewQueryResult queryResult)
|
||||
{
|
||||
shelvesListView.BuildModel(queryResult);
|
||||
|
||||
shelvesListView.Refilter();
|
||||
|
||||
shelvesListView.Sort();
|
||||
|
||||
shelvesListView.Reload();
|
||||
}
|
||||
|
||||
static int GetShelvesCount(ViewQueryResult queryResult)
|
||||
{
|
||||
if (queryResult == null)
|
||||
return 0;
|
||||
|
||||
return queryResult.Count();
|
||||
}
|
||||
|
||||
static void DoActionsToolbar(ProgressControlsForViews progressControls)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
|
||||
|
||||
if (progressControls.IsOperationRunning())
|
||||
{
|
||||
DrawProgressForViews.ForIndeterminateProgress(
|
||||
progressControls.ProgressData);
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
void DoShelvesArea(
|
||||
ShelvesListView shelvesListView,
|
||||
EmptyStateData emptyStateData,
|
||||
bool isOperationRunning,
|
||||
Action repaint)
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
GUI.enabled = !isOperationRunning;
|
||||
|
||||
Rect rect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
|
||||
|
||||
shelvesListView.OnGUI(rect);
|
||||
|
||||
emptyStateData.Update(
|
||||
GetEmptyStateMessage(shelvesListView),
|
||||
rect, Event.current.type, repaint);
|
||||
|
||||
if (!emptyStateData.IsEmpty())
|
||||
DrawTreeViewEmptyState.For(emptyStateData);
|
||||
|
||||
GUI.enabled = true;
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static void DoChangesArea(DiffPanel diffPanel)
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
diffPanel.OnGUI();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
static string GetEmptyStateMessage(ShelvesListView shelvesListView)
|
||||
{
|
||||
if (shelvesListView.GetRows().Count > 0)
|
||||
return string.Empty;
|
||||
|
||||
return string.IsNullOrEmpty(shelvesListView.searchString) ?
|
||||
PlasticLocalization.Name.NoShelvesCreatedExplanation.GetString() :
|
||||
PlasticLocalization.Name.ShelvesEmptyState.GetString();
|
||||
}
|
||||
|
||||
void BuildComponents(
|
||||
WorkspaceInfo wkInfo,
|
||||
IWorkspaceWindow workspaceWindow,
|
||||
IRefreshView refreshView,
|
||||
IViewSwitcher viewSwitcher,
|
||||
IHistoryViewLauncher historyViewLauncher,
|
||||
EditorWindow parentWindow)
|
||||
{
|
||||
mSearchField = new SearchField();
|
||||
mSearchField.downOrUpArrowKeyPressed += SearchField_OnDownOrUpArrowKeyPressed;
|
||||
|
||||
mOwnerFilter = EnumPopupSetting<OwnerFilter>.Load(
|
||||
UnityConstants.SHELVES_OWNER_FILTER_SETTING_NAME,
|
||||
OwnerFilter.MyShelves);
|
||||
|
||||
ShelvesListHeaderState headerState =
|
||||
ShelvesListHeaderState.GetDefault();
|
||||
|
||||
TreeHeaderSettings.Load(
|
||||
headerState,
|
||||
UnityConstants.SHELVES_TABLE_SETTINGS_NAME,
|
||||
(int)ShelvesListColumn.Name,
|
||||
false);
|
||||
|
||||
mShelvesListView = new ShelvesListView(
|
||||
headerState,
|
||||
ShelvesListHeaderState.GetColumnNames(),
|
||||
new ShelvesViewMenu(this),
|
||||
sizeChangedAction: OnShelvesListViewSizeChanged,
|
||||
selectionChangedAction: OnSelectionChanged,
|
||||
doubleClickAction: ((IShelveMenuOperations)this).OpenSelectedShelveInNewWindow);
|
||||
|
||||
mShelvesListView.Reload();
|
||||
|
||||
mDiffPanel = new DiffPanel(
|
||||
wkInfo, workspaceWindow, refreshView, viewSwitcher,
|
||||
historyViewLauncher, mShowDownloadPlasticExeWindow,
|
||||
parentWindow, mIsGluonMode);
|
||||
}
|
||||
|
||||
internal enum OwnerFilter
|
||||
{
|
||||
MyShelves,
|
||||
AllShelves
|
||||
}
|
||||
|
||||
bool mIsRefreshing;
|
||||
bool mShouldScrollToSelection;
|
||||
OwnerFilter mOwnerFilter;
|
||||
|
||||
object mSplitterState;
|
||||
SearchField mSearchField;
|
||||
ShelvesListView mShelvesListView;
|
||||
DiffPanel mDiffPanel;
|
||||
|
||||
readonly EmptyStateData mEmptyStateData = new EmptyStateData();
|
||||
readonly ProgressControlsForViews mProgressControls;
|
||||
readonly bool mIsGluonMode;
|
||||
readonly EditorWindow mParentWindow;
|
||||
readonly LaunchTool.IProcessExecutor mProcessExecutor;
|
||||
readonly WorkspaceOperationsMonitor mWorkspaceOperationsMonitor;
|
||||
readonly ISaveAssets mSaveAssets;
|
||||
readonly LaunchTool.IShowDownloadPlasticExeWindow mShowDownloadPlasticExeWindow;
|
||||
readonly IShelvedChangesUpdater mShelvedChangesUpdater;
|
||||
readonly IUpdateProgress mUpdateProgress;
|
||||
readonly IProgressOperationHandler mProgressOperationHandler;
|
||||
readonly GluonShelveOperations.ICheckinView mPendingChangesTab;
|
||||
readonly IMergeViewLauncher mMergeViewLauncher;
|
||||
readonly IRefreshView mRefreshView;
|
||||
readonly WorkspaceInfo mWkInfo;
|
||||
readonly RepositorySpec mRepSpec;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a496dda1132f2942b00c4f1c427454d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,162 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using PlasticGui;
|
||||
using PlasticGui.WorkspaceWindow.QueryViews.Shelves;
|
||||
using Unity.PlasticSCM.Editor.UI;
|
||||
|
||||
namespace Unity.PlasticSCM.Editor.Views.Shelves
|
||||
{
|
||||
internal class ShelvesViewMenu
|
||||
{
|
||||
internal GenericMenu Menu { get { return mMenu; } }
|
||||
|
||||
internal ShelvesViewMenu(IShelveMenuOperations shelveMenuOperations)
|
||||
{
|
||||
mShelveMenuOperations = shelveMenuOperations;
|
||||
|
||||
BuildComponents();
|
||||
}
|
||||
|
||||
internal void Popup()
|
||||
{
|
||||
mMenu = new GenericMenu();
|
||||
|
||||
UpdateMenuItems(mMenu);
|
||||
|
||||
mMenu.ShowAsContext();
|
||||
}
|
||||
|
||||
internal bool ProcessKeyActionIfNeeded(Event e)
|
||||
{
|
||||
ShelveMenuOperations operationToExecute = GetMenuOperations(e);
|
||||
|
||||
if (operationToExecute == ShelveMenuOperations.None)
|
||||
return false;
|
||||
|
||||
ShelveMenuOperations operations = ShelveMenuUpdater.GetAvailableMenuOperations(
|
||||
mShelveMenuOperations.GetSelectedShelvesCount());
|
||||
|
||||
if (!operations.HasFlag(operationToExecute))
|
||||
return false;
|
||||
|
||||
ProcessMenuOperation(operationToExecute);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ApplyShelveInWorkspace_Click()
|
||||
{
|
||||
mShelveMenuOperations.ApplyShelveInWorkspace();
|
||||
}
|
||||
|
||||
void DeleteShelve_Click()
|
||||
{
|
||||
mShelveMenuOperations.DeleteShelve();
|
||||
}
|
||||
|
||||
void OpenShelveInNewWindow_Click()
|
||||
{
|
||||
mShelveMenuOperations.OpenSelectedShelveInNewWindow();
|
||||
}
|
||||
|
||||
void UpdateMenuItems(GenericMenu menu)
|
||||
{
|
||||
ShelveMenuOperations operations = ShelveMenuUpdater.GetAvailableMenuOperations(
|
||||
mShelveMenuOperations.GetSelectedShelvesCount());
|
||||
|
||||
AddShelveMenuItem(
|
||||
mApplyShelveInWorkspaceMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
ShelveMenuOperations.ApplyShelveInWorkspace,
|
||||
ApplyShelveInWorkspace_Click);
|
||||
|
||||
AddShelveMenuItem(
|
||||
mDeleteShelveMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
ShelveMenuOperations.Delete,
|
||||
DeleteShelve_Click);
|
||||
|
||||
menu.AddSeparator(string.Empty);
|
||||
|
||||
AddShelveMenuItem(
|
||||
mOpenShelveInNewWindowMenuItemContent,
|
||||
menu,
|
||||
operations,
|
||||
ShelveMenuOperations.ViewShelve,
|
||||
OpenShelveInNewWindow_Click);
|
||||
}
|
||||
|
||||
void ProcessMenuOperation(
|
||||
ShelveMenuOperations operationToExecute)
|
||||
{
|
||||
if (operationToExecute == ShelveMenuOperations.ApplyShelveInWorkspace)
|
||||
{
|
||||
ApplyShelveInWorkspace_Click();
|
||||
return;
|
||||
}
|
||||
|
||||
if (operationToExecute == ShelveMenuOperations.Delete)
|
||||
{
|
||||
DeleteShelve_Click();
|
||||
return;
|
||||
}
|
||||
|
||||
if (operationToExecute == ShelveMenuOperations.ViewShelve)
|
||||
{
|
||||
OpenShelveInNewWindow_Click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void AddShelveMenuItem(
|
||||
GUIContent menuItemContent,
|
||||
GenericMenu menu,
|
||||
ShelveMenuOperations operations,
|
||||
ShelveMenuOperations operationsToCheck,
|
||||
GenericMenu.MenuFunction menuFunction)
|
||||
{
|
||||
if (operations.HasFlag(operationsToCheck))
|
||||
{
|
||||
menu.AddItem(
|
||||
menuItemContent,
|
||||
false,
|
||||
menuFunction);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
menu.AddDisabledItem(menuItemContent);
|
||||
}
|
||||
|
||||
static ShelveMenuOperations GetMenuOperations( Event e)
|
||||
{
|
||||
if (Keyboard.IsKeyPressed(e, KeyCode.Delete))
|
||||
return ShelveMenuOperations.Delete;
|
||||
|
||||
return ShelveMenuOperations.None;
|
||||
}
|
||||
|
||||
void BuildComponents()
|
||||
{
|
||||
mApplyShelveInWorkspaceMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.Name.ShelveMenuItemApplyShelveInWorkspace.GetString());
|
||||
|
||||
mDeleteShelveMenuItemContent = new GUIContent(string.Format("{0} {1}",
|
||||
PlasticLocalization.Name.ShelveMenuItemDeleteShelve.GetString(),
|
||||
GetPlasticShortcut.ForDelete()));
|
||||
|
||||
mOpenShelveInNewWindowMenuItemContent = new GUIContent(
|
||||
PlasticLocalization.Name.ShelveMenuItemOpenShelveInNewWindow.GetString());
|
||||
}
|
||||
|
||||
GenericMenu mMenu;
|
||||
|
||||
GUIContent mApplyShelveInWorkspaceMenuItemContent;
|
||||
GUIContent mDeleteShelveMenuItemContent;
|
||||
GUIContent mOpenShelveInNewWindowMenuItemContent;
|
||||
|
||||
readonly IShelveMenuOperations mShelveMenuOperations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8e89e66728f4cf4b2835b9e6c0a1690
|
||||
timeCreated: 1737548212
|
||||
Reference in New Issue
Block a user