コード例 #1
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            // First (A) is parent if one revision selected or if parent, then selected
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);

            // Combined diff is a display only diff, no manipulations
            bool isAnyCombinedDiff        = DiffFiles.SelectedItemParents.Any(item => item.Guid == DiffFiles.CombinedDiffGuid);
            bool isExactlyOneItemSelected = DiffFiles.SelectedItems.Count() == 1;
            bool isAnyItemSelected        = DiffFiles.SelectedItems.Any();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = DiffFiles.SelectedItems.Any(item => item.IsTracked);
            bool isAnySubmodule   = DiffFiles.SelectedItems.Any(item => item.IsSubmodule);
            bool singleFileExists = isExactlyOneItemSelected && File.Exists(_fullPathResolver.Resolve(DiffFiles.SelectedItem.Name));

            var selectionInfo = new ContextMenuSelectionInfo(DiffFiles.Revision,
                                                             firstIsParent: firstIsParent,
                                                             isAnyCombinedDiff: isAnyCombinedDiff,
                                                             isSingleGitItemSelected: isExactlyOneItemSelected,
                                                             isAnyItemSelected: isAnyItemSelected,
                                                             isBareRepository: isBareRepository,
                                                             singleFileExists: singleFileExists,
                                                             isAnyTracked: isAnyTracked,
                                                             isAnySubmodule: isAnySubmodule);

            return(selectionInfo);
        }
コード例 #2
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            // First (A) is parent if one revision selected or if parent, then selected
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents.Select(item => item.ObjectId), DiffFiles.Revision);

            // Combined diff is a display only diff, no manipulations
            bool isAnyCombinedDiff    = DiffFiles.SelectedItemParents.Any(item => item.ObjectId == ObjectId.CombinedDiffId);
            int  selectedGitItemCount = DiffFiles.SelectedItems.Count();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = DiffFiles.SelectedItems.Any(item => item.IsTracked);
            bool isAnyIndex       = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.Index);
            bool isAnyWorkTree    = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.WorkTree);
            bool isAnySubmodule   = DiffFiles.SelectedItems.Any(item => item.IsSubmodule);
            bool allFilesExist    = DiffFiles.SelectedItems.All(item => File.Exists(_fullPathResolver.Resolve(item.Name)));

            var selectionInfo = new ContextMenuSelectionInfo(DiffFiles.Revision,
                                                             firstIsParent: firstIsParent,
                                                             isAnyCombinedDiff: isAnyCombinedDiff,
                                                             selectedGitItemCount: selectedGitItemCount,
                                                             isAnyItemIndex: isAnyIndex,
                                                             isAnyItemWorkTree: isAnyWorkTree,
                                                             isBareRepository: isBareRepository,
                                                             allFilesExist: allFilesExist,
                                                             isAnyTracked: isAnyTracked,
                                                             isAnySubmodule: isAnySubmodule);

            return(selectionInfo);
        }
コード例 #3
0
 public bool ShouldShowMenuOpenRevision(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount == 1 &&
            !selectionInfo.IsAnySubmodule &&
            !selectionInfo.IsDisplayOnlyDiff &&
            !(selectionInfo.SelectedRevision?.IsArtificial ?? false));
 }
コード例 #4
0
 public bool ShouldShowMenuShowInFileTree(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount == 1 &&
            !(selectionInfo.SelectedRevision?.IsArtificial ?? false) &&
            !selectionInfo.IsDeleted &&
            !selectionInfo.IsStatusOnly);
 }
コード例 #5
0
 public bool ShouldShowResetFileMenus(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount > 0 &&
            !selectionInfo.IsBareRepository &&
            selectionInfo.IsAnyTracked &&
            !selectionInfo.IsDisplayOnlyDiff);
 }
コード例 #6
0
 public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount == 1 &&
            !selectionInfo.IsAnySubmodule &&
            !selectionInfo.IsDisplayOnlyDiff &&
            !selectionInfo.IsBareRepository &&
            selectionInfo.AllFilesExist &&
            selectionInfo.SupportPatches &&
            !(selectionInfo.SelectedRevision?.IsArtificial ?? false));
 }
コード例 #7
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            // First (A) is parent if one revision selected or if parent, then selected
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents.Select(item => item.ObjectId), DiffFiles.Revision);

            // Combined diff is a display only diff, no manipulations
            bool isAnyCombinedDiff    = DiffFiles.SelectedItemParents.Any(item => item.ObjectId == ObjectId.CombinedDiffId);
            int  selectedGitItemCount = DiffFiles.SelectedItems.Count();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = DiffFiles.SelectedItems.Any(item => item.IsTracked);
            bool isAnyIndex       = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.Index);
            bool isAnyWorkTree    = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.WorkTree);
            bool isAnySubmodule   = DiffFiles.SelectedItems.Any(item => item.IsSubmodule);

            (bool allFilesExist, bool allFilesOrUntrackedDirectoriesExist) = FileOrUntrackedDirExists(DiffFiles.SelectedItems);

            var selectionInfo = new ContextMenuSelectionInfo(DiffFiles.Revision,
                                                             firstIsParent: firstIsParent,
                                                             isAnyCombinedDiff: isAnyCombinedDiff,
                                                             selectedGitItemCount: selectedGitItemCount,
                                                             isAnyItemIndex: isAnyIndex,
                                                             isAnyItemWorkTree: isAnyWorkTree,
                                                             isBareRepository: isBareRepository,
                                                             allFilesExist: allFilesExist,
                                                             allFilesOrUntrackedDirectoriesExist: allFilesOrUntrackedDirectoriesExist,
                                                             isAnyTracked: isAnyTracked,
                                                             isAnySubmodule: isAnySubmodule);

            return(selectionInfo);

            (bool allFilesExist, bool allFilesOrUntrackedDirectoriesExist) FileOrUntrackedDirExists(IEnumerable <GitItemStatus> items)
            {
                bool allFilesExist = true;
                bool allFilesOrUntrackedDirectoriesExist = true;

                foreach (var item in items)
                {
                    var path       = _fullPathResolver.Resolve(item.Name);
                    var fileExists = File.Exists(path);
                    allFilesExist = allFilesExist && fileExists;
                    var fileOrUntrackedDirectoryExists = fileExists || (!item.IsTracked && Directory.Exists(path));
                    allFilesOrUntrackedDirectoriesExist = allFilesOrUntrackedDirectoriesExist && fileOrUntrackedDirectoryExists;

                    if (allFilesExist == false && allFilesOrUntrackedDirectoriesExist == false)
                    {
                        break;
                    }
                }

                return(allFilesExist, allFilesOrUntrackedDirectoriesExist);
            }
        }
コード例 #8
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            IList <GitRevision> selectedRevisions = _revisionGrid.GetSelectedRevisions();

            bool isAnyCombinedDiff        = DiffFiles.SelectedItemParents.Any(item => item == DiffFiles.CombinedDiff.Text);
            bool isExactlyOneItemSelected = DiffFiles.SelectedItems.Count() == 1;
            var  isCombinedDiff           = isExactlyOneItemSelected && DiffFiles.CombinedDiff.Text == DiffFiles.SelectedItemParent;
            var  selectedItemStatus       = DiffFiles.SelectedItem;

            var selectionInfo = new ContextMenuSelectionInfo(selectedRevisions, selectedItemStatus, isAnyCombinedDiff, isExactlyOneItemSelected, isCombinedDiff);

            return(selectionInfo);
        }
コード例 #9
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            IList <GitRevision> selectedRevisions = _revisionGrid.GetSelectedRevisions();

            bool isAnyCombinedDiff        = DiffFiles.SelectedItemParents.Any(item => item == DiffFiles.CombinedDiff.Text);
            bool isExactlyOneItemSelected = DiffFiles.SelectedItems.Count() == 1;
            bool isAnyItemSelected        = DiffFiles.SelectedItems.Count() > 0;
            var  isCombinedDiff           = isExactlyOneItemSelected && DiffFiles.CombinedDiff.Text == DiffFiles.SelectedItemParent;
            var  selectedItemStatus       = DiffFiles.SelectedItem;
            bool isBareRepository         = Module.IsBareRepository();
            bool singleFileExists         = isExactlyOneItemSelected && File.Exists(FormBrowseUtil.GetFullPathFromGitItemStatus(Module, DiffFiles.SelectedItem));

            var selectionInfo = new ContextMenuSelectionInfo(selectedRevisions, selectedItemStatus, isAnyCombinedDiff, isExactlyOneItemSelected, isCombinedDiff, isAnyItemSelected, isBareRepository, singleFileExists);

            return(selectionInfo);
        }
コード例 #10
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            IList <GitRevision> selectedRevisions = _revisionGrid.GetSelectedRevisions();

            bool isAnyCombinedDiff        = DiffFiles.SelectedItemParents.Any(item => item.Guid == DiffFiles.CombinedDiff.Text);
            bool isExactlyOneItemSelected = DiffFiles.SelectedItems.Count() == 1;
            bool isAnyItemSelected        = DiffFiles.SelectedItems.Count() > 0;
            var  isCombinedDiff           = isExactlyOneItemSelected && DiffFiles.CombinedDiff.Text == DiffFiles.SelectedItemParent?.Guid;
            var  selectedItemStatus       = DiffFiles.SelectedItem;
            bool isBareRepository         = Module.IsBareRepository();
            bool singleFileExists         = isExactlyOneItemSelected && File.Exists(_fullPathResolver.Resolve(DiffFiles.SelectedItem.Name));

            var selectionInfo = new ContextMenuSelectionInfo(selectedRevisions, selectedItemStatus, isAnyCombinedDiff, isExactlyOneItemSelected, isCombinedDiff, isAnyItemSelected, isBareRepository, singleFileExists);

            return(selectionInfo);
        }
コード例 #11
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            var selectedItems = DiffFiles.SelectedItems.ToList();

            // Some items are not supported if more than one revision is selected
            var revisions   = selectedItems.SecondRevs().ToList();
            var selectedRev = revisions.Count() != 1 ? null : revisions.FirstOrDefault();

            // First (A) is parent if one revision selected or if parent, then selected
            var parentIds = selectedItems.FirstIds().ToList();

            // Combined diff, range diff etc are for display only, no manipulations
            bool isStatusOnly         = selectedItems.Any(item => item.Item.IsRangeDiff || item.Item.IsStatusOnly);
            bool isDisplayOnlyDiff    = parentIds.Contains(ObjectId.CombinedDiffId) || isStatusOnly;
            int  selectedGitItemCount = selectedItems.Count();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = selectedItems.Any(item => item.Item.IsTracked);
            bool isAnyIndex       = selectedItems.Any(item => item.Item.Staged == StagedStatus.Index);
            bool isAnyWorkTree    = selectedItems.Any(item => item.Item.Staged == StagedStatus.WorkTree);
            bool supportPatches   = selectedGitItemCount == 1 && DiffText.HasAnyPatches();
            bool isDeleted        = selectedItems.Any(item => item.Item.IsDeleted);
            bool isAnySubmodule   = selectedItems.Any(item => item.Item.IsSubmodule);

            (bool allFilesExist, bool allDirectoriesExist, bool allFilesOrUntrackedDirectoriesExist) = FileOrUntrackedDirExists(selectedItems, _fullPathResolver);

            var selectionInfo = new ContextMenuSelectionInfo(
                selectedRevision: selectedRev,
                isDisplayOnlyDiff: isDisplayOnlyDiff,
                isStatusOnly: isStatusOnly,
                selectedGitItemCount: selectedGitItemCount,
                isAnyItemIndex: isAnyIndex,
                isAnyItemWorkTree: isAnyWorkTree,
                isBareRepository: isBareRepository,
                allFilesExist: allFilesExist,
                allDirectoriesExist: allDirectoriesExist,
                allFilesOrUntrackedDirectoriesExist: allFilesOrUntrackedDirectoriesExist,
                isAnyTracked: isAnyTracked,
                supportPatches: supportPatches,
                isDeleted: isDeleted,
                isAnySubmodule: isAnySubmodule);

            return(selectionInfo);
コード例 #12
0
 public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsSingleGitItemSelected && !selectionInfo.IsAnySubmodule &&
            !selectionInfo.IsAnyCombinedDiff && !selectionInfo.IsBareRepository &&
            !selectionInfo.SelectedRevision.IsArtificial);
 }
コード例 #13
0
 public bool ShouldShowMenuDeleteFile(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.AllFilesOrUntrackedDirectoriesExist && (selectionInfo.SelectedRevision?.IsArtificial ?? false));
 }
コード例 #14
0
 public bool ShouldShowMenuEditWorkingDirectoryFile(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount == 1 && selectionInfo.AllFilesExist);
 }
コード例 #15
0
 public bool ShouldShowSubmoduleMenus(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsAnySubmodule && selectionInfo.SelectedRevision?.ObjectId == ObjectId.WorkTreeId && selectionInfo.AllDirectoriesExist);
 }
コード例 #16
0
 public bool ShouldShowMenuShowInFileTree(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsSingleGitItemSelected && !selectionInfo.SelectedRevision.IsArtificial);
 }
コード例 #17
0
 public bool ShouldShowMenuBlame(ContextMenuSelectionInfo selectionInfo)
 {
     return(ShouldShowMenuFileHistory(selectionInfo) && !selectionInfo.IsAnySubmodule);
 }
コード例 #18
0
 public bool ShouldShowMenuEditFile(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsSingleGitItemSelected && !selectionInfo.IsAnySubmodule && selectionInfo.SingleFileExists);
 }
コード例 #19
0
        // The enabling of menu items is related to how the actions have been implemented

        public bool ShouldShowDifftoolMenus(ContextMenuSelectionInfo selectionInfo)
        {
            return(selectionInfo.SelectedGitItemCount != 0 && !selectionInfo.IsAnyCombinedDiff && selectionInfo.IsAnyTracked);
        }
コード例 #20
0
 public bool ShouldShowMenuCopyFileName(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount != 0);
 }
コード例 #21
0
 public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount == 1 && !selectionInfo.IsAnySubmodule &&
            !selectionInfo.IsAnyCombinedDiff && !selectionInfo.IsBareRepository &&
            !(selectionInfo.SelectedRevision?.IsArtificial ?? false));
 }
コード例 #22
0
 public bool ShouldShowMenuFileHistory(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsSingleGitItemSelected && selectionInfo.IsAnyTracked);
 }
コード例 #23
0
 public bool ShouldShowMenuCopyFileName(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount > 0 && !selectionInfo.IsStatusOnly);
 }
コード例 #24
0
 public bool ShouldShowSubmoduleMenus(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsAnySubmodule && selectionInfo.SelectedRevision.Guid == GitRevision.UnstagedGuid);
 }
コード例 #25
0
 public bool ShouldShowMenuShowInFolder(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount > 0 && !selectionInfo.IsStatusOnly);
 }
コード例 #26
0
 // Stage/unstage must limit the selected items, IsStaged is not reflecting Staged status
 public bool ShouldShowMenuStage(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsAnyItemWorkTree);
 }
コード例 #27
0
 public bool ShouldShowMenuFileHistory(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.SelectedGitItemCount == 1 && selectionInfo.IsAnyTracked);
 }
コード例 #28
0
 public bool ShouldShowMenuUnstage(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsAnyItemIndex);
 }
コード例 #29
0
        // The enabling of menu items is related to how the actions have been implemented

        public bool ShouldShowDifftoolMenus(ContextMenuSelectionInfo selectionInfo)
        {
            return(selectionInfo.SelectedGitItemCount > 0 && !selectionInfo.IsDisplayOnlyDiff);
        }
コード例 #30
0
 public bool ShouldShowMenuCopyFileName(ContextMenuSelectionInfo selectionInfo)
 {
     return(selectionInfo.IsAnyItemSelected);
 }