Пример #1
0
            static bool IsApplicableForOperation(
                string path,
                bool isDirectory,
                AssetMenuOperations operation,
                IAssetStatusCache assetStatusCache)
            {
                SelectedAssetGroupInfo info = SelectedAssetGroupInfo.BuildFromSingleFile(
                    path, isDirectory, assetStatusCache);

                return(AssetMenuUpdater.GetAvailableMenuOperations(info).HasFlag(operation));
            }
Пример #2
0
        internal static AssetMenuOperations GetAvailableMenuOperations(
            SelectedAssetGroupInfo info)
        {
            AssetMenuOperations result = AssetMenuOperations.None;

            if (info.SelectedCount == 0)
            {
                return(result);
            }

            if (info.IsControlledSelection &&
                info.IsCheckedInSelection &&
                info.IsFileSelection &&
                !info.HasAnyRemoteLockedInSelection)
            {
                result |= AssetMenuOperations.Checkout;
            }

            if (info.IsFileSelection &&
                info.IsPrivateSelection)
            {
                result |= AssetMenuOperations.Add;
            }

            if (info.IsFileSelection &&
                info.IsControlledSelection &&
                info.IsCheckedOutSelection)
            {
                result |= AssetMenuOperations.Checkin;
                result |= AssetMenuOperations.Undo;
            }

            if (info.SelectedCount == 1 &&
                info.IsControlledSelection &&
                !info.HasAnyAddedInSelection &&
                info.IsFileSelection)
            {
                result |= AssetMenuOperations.Diff;
            }

            if (info.SelectedCount == 1 &&
                info.IsControlledSelection &&
                !info.HasAnyAddedInSelection)
            {
                result |= AssetMenuOperations.History;
            }

            return(result);
        }
Пример #3
0
        static bool ShouldMenuItemBeEnabled(AssetMenuOperations operation)
        {
            if (sOperations == null)
            {
                return(false);
            }

            SelectedAssetGroupInfo selectedGroupInfo = SelectedAssetGroupInfo.
                                                       BuildFromAssetList(
                sAssetSelection.GetSelectedAssets(),
                sAssetStatusCache);

            AssetMenuOperations operations = AssetMenuUpdater.
                                             GetAvailableMenuOperations(selectedGroupInfo);

            return(operations.HasFlag(operation));
        }
Пример #4
0
        internal static SelectedAssetGroupInfo BuildFromAssetList(
            AssetList assetList,
            IAssetStatusCache statusCache)
        {
            bool isCheckedInSelection          = true;
            bool isControlledSelection         = true;
            bool isCheckedOutSelection         = true;
            bool isPrivateSelection            = true;
            bool isAddedSelection              = true;
            bool isFileSelection               = true;
            bool hasAnyAddedInSelection        = false;
            bool hasAnyRemoteLockedInSelection = false;

            int selectedCount = 0;

            foreach (Asset asset in assetList)
            {
                if (string.IsNullOrEmpty(asset.path))
                {
                    continue;
                }

                SelectedAssetGroupInfo singleFileGroupInfo = BuildFromSingleFile(
                    asset.path,
                    asset.isFolder,
                    statusCache);

                if (!singleFileGroupInfo.IsCheckedInSelection)
                {
                    isCheckedInSelection = false;
                }

                if (!singleFileGroupInfo.IsControlledSelection)
                {
                    isControlledSelection = false;
                }

                if (!singleFileGroupInfo.IsCheckedOutSelection)
                {
                    isCheckedOutSelection = false;
                }

                if (!singleFileGroupInfo.IsPrivateSelection)
                {
                    isPrivateSelection = false;
                }

                if (!singleFileGroupInfo.IsAddedSelection)
                {
                    isAddedSelection = false;
                }

                if (!singleFileGroupInfo.IsFileSelection)
                {
                    isFileSelection = false;
                }

                if (singleFileGroupInfo.HasAnyAddedInSelection)
                {
                    hasAnyAddedInSelection = true;
                }

                if (singleFileGroupInfo.HasAnyRemoteLockedInSelection)
                {
                    hasAnyRemoteLockedInSelection = true;
                }

                selectedCount++;
            }

            return(new SelectedAssetGroupInfo()
            {
                IsCheckedInSelection = isCheckedInSelection,
                IsCheckedOutSelection = isCheckedOutSelection,
                IsControlledSelection = isControlledSelection,
                IsPrivateSelection = isPrivateSelection,
                IsAddedSelection = isAddedSelection,
                IsFileSelection = isFileSelection,
                HasAnyAddedInSelection = hasAnyAddedInSelection,
                HasAnyRemoteLockedInSelection = hasAnyRemoteLockedInSelection,
                SelectedCount = selectedCount,
            });
        }