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); }
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); }
public bool ShouldShowMenuOpenRevision(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount == 1 && !selectionInfo.IsAnySubmodule && !selectionInfo.IsDisplayOnlyDiff && !(selectionInfo.SelectedRevision?.IsArtificial ?? false)); }
public bool ShouldShowMenuShowInFileTree(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount == 1 && !(selectionInfo.SelectedRevision?.IsArtificial ?? false) && !selectionInfo.IsDeleted && !selectionInfo.IsStatusOnly); }
public bool ShouldShowResetFileMenus(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount > 0 && !selectionInfo.IsBareRepository && selectionInfo.IsAnyTracked && !selectionInfo.IsDisplayOnlyDiff); }
public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount == 1 && !selectionInfo.IsAnySubmodule && !selectionInfo.IsDisplayOnlyDiff && !selectionInfo.IsBareRepository && selectionInfo.AllFilesExist && selectionInfo.SupportPatches && !(selectionInfo.SelectedRevision?.IsArtificial ?? false)); }
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); } }
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); }
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); }
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); }
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);
public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsSingleGitItemSelected && !selectionInfo.IsAnySubmodule && !selectionInfo.IsAnyCombinedDiff && !selectionInfo.IsBareRepository && !selectionInfo.SelectedRevision.IsArtificial); }
public bool ShouldShowMenuDeleteFile(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.AllFilesOrUntrackedDirectoriesExist && (selectionInfo.SelectedRevision?.IsArtificial ?? false)); }
public bool ShouldShowMenuEditWorkingDirectoryFile(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount == 1 && selectionInfo.AllFilesExist); }
public bool ShouldShowSubmoduleMenus(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsAnySubmodule && selectionInfo.SelectedRevision?.ObjectId == ObjectId.WorkTreeId && selectionInfo.AllDirectoriesExist); }
public bool ShouldShowMenuShowInFileTree(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsSingleGitItemSelected && !selectionInfo.SelectedRevision.IsArtificial); }
public bool ShouldShowMenuBlame(ContextMenuSelectionInfo selectionInfo) { return(ShouldShowMenuFileHistory(selectionInfo) && !selectionInfo.IsAnySubmodule); }
public bool ShouldShowMenuEditFile(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsSingleGitItemSelected && !selectionInfo.IsAnySubmodule && selectionInfo.SingleFileExists); }
// 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); }
public bool ShouldShowMenuCopyFileName(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount != 0); }
public bool ShouldShowMenuCherryPick(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount == 1 && !selectionInfo.IsAnySubmodule && !selectionInfo.IsAnyCombinedDiff && !selectionInfo.IsBareRepository && !(selectionInfo.SelectedRevision?.IsArtificial ?? false)); }
public bool ShouldShowMenuFileHistory(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsSingleGitItemSelected && selectionInfo.IsAnyTracked); }
public bool ShouldShowMenuCopyFileName(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount > 0 && !selectionInfo.IsStatusOnly); }
public bool ShouldShowSubmoduleMenus(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsAnySubmodule && selectionInfo.SelectedRevision.Guid == GitRevision.UnstagedGuid); }
public bool ShouldShowMenuShowInFolder(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount > 0 && !selectionInfo.IsStatusOnly); }
// Stage/unstage must limit the selected items, IsStaged is not reflecting Staged status public bool ShouldShowMenuStage(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsAnyItemWorkTree); }
public bool ShouldShowMenuFileHistory(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.SelectedGitItemCount == 1 && selectionInfo.IsAnyTracked); }
public bool ShouldShowMenuUnstage(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsAnyItemIndex); }
// 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); }
public bool ShouldShowMenuCopyFileName(ContextMenuSelectionInfo selectionInfo) { return(selectionInfo.IsAnyItemSelected); }