private void openWithDifftoolToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            ContextMenuDiffToolInfo selectionInfo = GetContextMenuDiffToolInfo();

            if (DiffFiles.SelectedItemsWithParent.Any())
            {
                selectedDiffCaptionMenuItem.Text    = _selectedRevision + ": (" + _revisionGrid.DescribeRevision(DiffFiles.Revision, 50) + ")";
                selectedDiffCaptionMenuItem.Visible = true;
                MenuUtil.SetAsCaptionMenuItem(selectedDiffCaptionMenuItem, DiffContextMenu);

                firstDiffCaptionMenuItem.Text = _firstRevision + ":";
                var parentDesc = DescribeSelectedParentRevision(true);
                if (parentDesc.IsNotNullOrWhitespace())
                {
                    firstDiffCaptionMenuItem.Text += " (" + parentDesc + ")";
                }

                firstDiffCaptionMenuItem.Visible = true;
                MenuUtil.SetAsCaptionMenuItem(firstDiffCaptionMenuItem, DiffContextMenu);
            }
            else
            {
                firstDiffCaptionMenuItem.Visible    = false;
                selectedDiffCaptionMenuItem.Visible = false;
            }

            firstToSelectedToolStripMenuItem.Enabled       = _revisionDiffContextMenuController.ShouldShowMenuFirstToSelected(selectionInfo);
            firstToLocalToolStripMenuItem.Enabled          = _revisionDiffContextMenuController.ShouldShowMenuFirstToLocal(selectionInfo);
            selectedToLocalToolStripMenuItem.Enabled       = _revisionDiffContextMenuController.ShouldShowMenuSelectedToLocal(selectionInfo);
            firstParentToLocalToolStripMenuItem.Enabled    = _revisionDiffContextMenuController.ShouldShowMenuFirstParentToLocal(selectionInfo);
            selectedParentToLocalToolStripMenuItem.Enabled = _revisionDiffContextMenuController.ShouldShowMenuSelectedParentToLocal(selectionInfo);
            firstParentToLocalToolStripMenuItem.Visible    = _revisionDiffContextMenuController.ShouldDisplayMenuFirstParentToLocal(selectionInfo);
            selectedParentToLocalToolStripMenuItem.Visible = _revisionDiffContextMenuController.ShouldDisplayMenuSelectedParentToLocal(selectionInfo);
        }
        private void openWithDifftoolToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            ContextMenuDiffToolInfo selectionInfo = GetContextMenuDiffToolInfo();

            if (DiffFiles.SelectedItemsWithParent.Any())
            {
                selectedDiffCaptionMenuItem.Text    = _selectedRevision + DescribeRevision(DiffFiles.Revision?.ObjectId, 50);
                selectedDiffCaptionMenuItem.Visible = true;
                MenuUtil.SetAsCaptionMenuItem(selectedDiffCaptionMenuItem, DiffContextMenu);

                firstDiffCaptionMenuItem.Text = _firstRevision.Text;
                var parentDesc = DescribeRevision(DiffFiles.SelectedItemParents.ToList());
                if (!string.IsNullOrWhiteSpace(parentDesc))
                {
                    firstDiffCaptionMenuItem.Text += parentDesc;
                }

                firstDiffCaptionMenuItem.Visible = true;
                MenuUtil.SetAsCaptionMenuItem(firstDiffCaptionMenuItem, DiffContextMenu);
            }
            else
            {
                firstDiffCaptionMenuItem.Visible    = false;
                selectedDiffCaptionMenuItem.Visible = false;
            }

            firstToSelectedToolStripMenuItem.Enabled       = _revisionDiffContextMenuController.ShouldShowMenuFirstToSelected(selectionInfo);
            firstToLocalToolStripMenuItem.Enabled          = _revisionDiffContextMenuController.ShouldShowMenuFirstToLocal(selectionInfo);
            selectedToLocalToolStripMenuItem.Enabled       = _revisionDiffContextMenuController.ShouldShowMenuSelectedToLocal(selectionInfo);
            firstParentToLocalToolStripMenuItem.Enabled    = _revisionDiffContextMenuController.ShouldShowMenuFirstParentToLocal(selectionInfo);
            selectedParentToLocalToolStripMenuItem.Enabled = _revisionDiffContextMenuController.ShouldShowMenuSelectedParentToLocal(selectionInfo);
            firstParentToLocalToolStripMenuItem.Visible    = _revisionDiffContextMenuController.ShouldDisplayMenuFirstParentToLocal(selectionInfo);
            selectedParentToLocalToolStripMenuItem.Visible = _revisionDiffContextMenuController.ShouldDisplayMenuSelectedParentToLocal(selectionInfo);
        }
Exemple #3
0
        public bool ShouldShowMenuSelectedParentToLocal(ContextMenuDiffToolInfo selectionInfo)
        {
            return(selectionInfo.SelectedRevision != null && selectionInfo.LocalExists &&
                   ShouldDisplayMenuSelectedParentToLocal(selectionInfo)

                   // Selected (B) parent exists
                   && !selectionInfo.AllAreNew);
        }
Exemple #4
0
        private void openWithDifftoolToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            ContextMenuDiffToolInfo selectionInfo = GetContextMenuDiffToolInfo();

            firstToSelectedToolStripMenuItem.Enabled = _revisionDiffContextMenuController.ShouldShowMenuFirstToSelected(selectionInfo);
            firstToLocalToolStripMenuItem.Enabled    = _revisionDiffContextMenuController.ShouldShowMenuFirstToLocal(selectionInfo);
            selectedToLocalToolStripMenuItem.Enabled = _revisionDiffContextMenuController.ShouldShowMenuSelectedToLocal(selectionInfo);
        }
        public bool ShouldShowMenuSelectedToLocal(ContextMenuDiffToolInfo selectionInfo)
        {
            return(selectionInfo.SelectedRevision != null && selectionInfo.LocalExists

                   // Selected (B) exists
                   && !selectionInfo.AllAreDeleted

                   // Selected (B) is not local
                   && selectionInfo.SelectedRevision.Guid != GitRevision.UnstagedGuid);
        }
Exemple #6
0
        public bool ShouldShowMenuFirstToLocal(ContextMenuDiffToolInfo selectionInfo)
        {
            return(selectionInfo.SelectedRevision != null && selectionInfo.LocalExists

                   // First (A) exists (Can only determine that A does not exist if A is parent and B is new)
                   && (!selectionInfo.FirstIsParent || !selectionInfo.AllAreNew)

                   // First (A) is not local
                   && (selectionInfo.SelectedItemParentRevs == null || !selectionInfo.SelectedItemParentRevs.Contains(ObjectId.WorkTreeId)));
        }
Exemple #7
0
        public bool ShouldShowMenuSelectedToLocal(ContextMenuDiffToolInfo selectionInfo)
        {
            return(selectionInfo.SelectedRevision != null && selectionInfo.LocalExists

                   // Selected (B) exists
                   && !selectionInfo.AllAreDeleted

                   // Selected (B) is not local
                   && selectionInfo.SelectedRevision.ObjectId != ObjectId.WorkTreeId);
        }
        private void openWithDifftoolToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            ContextMenuDiffToolInfo selectionInfo = GetContextMenuDiffToolInfo();

            aBToolStripMenuItem.Enabled             = _revisionDiffController.ShouldShowMenuAB(selectionInfo);
            aLocalToolStripMenuItem.Enabled         = _revisionDiffController.ShouldShowMenuALocal(selectionInfo);
            bLocalToolStripMenuItem.Enabled         = _revisionDiffController.ShouldShowMenuBLocal(selectionInfo);
            parentOfALocalToolStripMenuItem.Enabled = _revisionDiffController.ShouldShowMenuAParentLocal(selectionInfo);
            parentOfBLocalToolStripMenuItem.Enabled = _revisionDiffController.ShouldShowMenuBParentLocal(selectionInfo);
            parentOfALocalToolStripMenuItem.Visible = parentOfALocalToolStripMenuItem.Enabled || _revisionDiffController.ShouldShowMenuAParent(selectionInfo);
            parentOfBLocalToolStripMenuItem.Visible = parentOfBLocalToolStripMenuItem.Enabled || _revisionDiffController.ShouldShowMenuBParent(selectionInfo);
        }
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            IList <GitRevision> selectedRevisions = _revisionGrid.GetSelectedRevisions();

            //Should be blocked in the GUI but not an error to show to the user
            Debug.Assert(selectedRevisions.Count == 1 || selectedRevisions.Count == 2,
                         "Unexpectedly number of revisions for difftool" + selectedRevisions.Count);
            if (selectedRevisions.Count < 1)
            {
                return(null);
            }

            bool aIsLocal        = false;
            bool bIsLocal        = false;
            bool showParentItems = selectedRevisions.Count == 2;

            bool localExists = false;
            bool bIsNormal   = false; //B is not new or deleted (we cannot easily check A)

            bIsLocal = selectedRevisions[0].Guid == GitRevision.UnstagedGuid;

            if (selectedRevisions.Count == 2)
            {
                aIsLocal = selectedRevisions[0].Guid == GitRevision.UnstagedGuid;
            }
            //Temporary, until parent is set to HEAD instead of staged
            else
            {
                aIsLocal = bIsLocal;
                bIsLocal = bIsLocal || selectedRevisions[0].Guid == GitRevision.IndexGuid;
            }

            //enable *<->Local items only when local file exists
            //no simple way to check if A (or A/B parents) is normal, ignore that some menus should be disabled
            foreach (var item in DiffFiles.SelectedItems)
            {
                bIsNormal = bIsNormal || !(item.IsNew || item.IsDeleted);
                string filePath = FormBrowseUtil.GetFullPathFromGitItemStatus(Module, item);
                if (File.Exists(filePath) || Directory.Exists(filePath))
                {
                    localExists = true;
                    if (localExists && bIsNormal)
                    {
                        break;
                    }
                }
            }

            var selectionInfo = new ContextMenuDiffToolInfo(aIsLocal, bIsLocal, bIsNormal, localExists, showParentItems);

            return(selectionInfo);
        }
        private void openWithDifftoolToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            ContextMenuDiffToolInfo selectionInfo = GetContextMenuDiffToolInfo();

            aBToolStripMenuItem.Enabled             = _revisionDiffController.ShouldShowMenuAB(selectionInfo);
            aLocalToolStripMenuItem.Enabled         = _revisionDiffController.ShouldShowMenuALocal(selectionInfo);
            bLocalToolStripMenuItem.Enabled         = _revisionDiffController.ShouldShowMenuBLocal(selectionInfo);
            parentOfALocalToolStripMenuItem.Enabled = _revisionDiffController.ShouldShowMenuAParentLocal(selectionInfo);
            parentOfBLocalToolStripMenuItem.Enabled = _revisionDiffController.ShouldShowMenuBParentLocal(selectionInfo);
            //Nothing preventing to show the parents (as done in FormDiff)
            parentOfALocalToolStripMenuItem.Visible     =
                parentOfBLocalToolStripMenuItem.Visible = _revisionDiffController.ShouldShowMenuParents(selectionInfo);
        }
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);
            bool localExists   = _gitRevisionTester.AnyLocalFileExists(DiffFiles.SelectedItemsWithParent.Select(i => i.Item));

            IEnumerable <string> selectedItemParentRevs = DiffFiles.SelectedItemParents.Select(i => i.Guid);
            bool allAreNew     = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsNew);
            bool allAreDeleted = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsDeleted);

            var selectionInfo = new ContextMenuDiffToolInfo(DiffFiles.Revision, selectedItemParentRevs,
                                                            allAreNew: allAreNew,
                                                            allAreDeleted: allAreDeleted,
                                                            firstIsParent: firstIsParent,
                                                            firstParentsValid: _revisionGrid.IsFirstParentValid(),
                                                            localExists: localExists);

            return(selectionInfo);
        }
Exemple #12
0
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            bool firstIsParent = _revisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);
            bool localExists   = _revisionTester.AnyLocalFileExists(DiffFiles.SelectedItemsWithParent.Select(i => i.Item));

            IEnumerable <string> selectedItemParentRevs = DiffFiles.Revision.ParentGuids;
            bool allAreNew         = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsNew);
            bool allAreDeleted     = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsDeleted);
            var  revisions         = _revisionGrid.GetSelectedRevisions();
            bool firstParentsValid = revisions != null && revisions.Count > 1;

            var selectionInfo = new ContextMenuDiffToolInfo(_headRevision, selectedItemParentRevs,
                                                            allAreNew: allAreNew,
                                                            allAreDeleted: allAreDeleted,
                                                            firstIsParent: firstIsParent,
                                                            firstParentsValid: firstParentsValid,
                                                            localExists: localExists);

            return(selectionInfo);
        }
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            IList <GitRevision> selectedRevisions = _revisionGrid.GetSelectedRevisions();

            // Should be blocked in the GUI but not an error to show to the user
            Debug.Assert(selectedRevisions.Count == 1 || selectedRevisions.Count == 2,
                         "Unexpectedly number of revisions for difftool" + selectedRevisions.Count);
            if (selectedRevisions.Count < 1 || selectedRevisions.Count > 2)
            {
                return(null);
            }

#pragma warning disable SA1305 // Field names should not use Hungarian notation
            bool aIsLocal = selectedRevisions.Count == 2 && selectedRevisions[1].Guid == GitRevision.UnstagedGuid;
            bool bIsLocal = selectedRevisions[0].Guid == GitRevision.UnstagedGuid;
            bool multipleRevisionsSelected = selectedRevisions.Count == 2;

            bool localExists = false;
            bool bIsNormal   = false; // B is assumed to be new or deleted (check from DiffFiles)
#pragma warning restore SA1305        // Field names should not use Hungarian notation

            // enable *<->Local items only when (any) local file exists
            foreach (var item in DiffFiles.SelectedItems)
            {
                bIsNormal = bIsNormal || !(item.IsNew || item.IsDeleted);
                string filePath = _fullPathResolver.Resolve(item.Name);
                if (File.Exists(filePath) || Directory.Exists(filePath))
                {
                    localExists = true;
                    if (localExists && bIsNormal)
                    {
                        break;
                    }
                }
            }

            var selectionInfo = new ContextMenuDiffToolInfo(aIsLocal, bIsLocal, bIsNormal, localExists, multipleRevisionsSelected);
            return(selectionInfo);
        }
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);
            bool localExists   = _gitRevisionTester.AnyLocalFileExists(DiffFiles.SelectedItemsWithParent.Select(i => i.Item));

            IEnumerable <string> selectedItemParentRevs = DiffFiles.SelectedItemParents.Select(i => i.Guid);
            bool allAreNew     = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsNew);
            bool allAreDeleted = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsDeleted);
            var  revisions     = _revisionGrid.GetSelectedRevisions();

            // Parents to First (A) are only known if A is explicitly selected (there is no explicit search for parents to parents of a single selected revision)
            bool firstParentsValid = revisions != null && revisions.Count > 1;

            var selectionInfo = new ContextMenuDiffToolInfo(DiffFiles.Revision, selectedItemParentRevs,
                                                            allAreNew: allAreNew,
                                                            allAreDeleted: allAreDeleted,
                                                            firstIsParent: firstIsParent,
                                                            firstParentsValid: firstParentsValid,
                                                            localExists: localExists);

            return(selectionInfo);
        }
Exemple #15
0
 public bool ShouldShowMenuAParent(ContextMenuDiffToolInfo selectionInfo)
 {
     return(ShouldShowMenuALocal(selectionInfo) && selectionInfo.AIsLocal);
 }
Exemple #16
0
 public bool ShouldShowMenuFirstParentToLocal(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.SelectedRevision != null && selectionInfo.LocalExists &&
            ShouldDisplayMenuFirstParentToLocal(selectionInfo));
 }
Exemple #17
0
 public bool ShouldShowMenuBParent(ContextMenuDiffToolInfo selectionInfo)
 {
     return(ShouldShowMenuBLocal(selectionInfo) && (selectionInfo.BIsLocal || selectionInfo.MultipleRevisionsSelected));
 }
Exemple #18
0
 public bool ShouldShowMenuFirstToSelected(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.SelectedRevision != null);
 }
Exemple #19
0
 public bool ShouldDisplayMenuSelectedParentToLocal(ContextMenuDiffToolInfo selectionInfo)
 {
     // Not visible if same revision as ShouldShowMenuFirstToLocal()
     return(!selectionInfo.FirstIsParent);
 }
Exemple #20
0
 public bool ShouldDisplayMenuFirstParentToLocal(ContextMenuDiffToolInfo selectionInfo)
 {
     // First (A) parents may not be known, then hide this option
     return(selectionInfo.FirstParentsValid);
 }
 public bool ShouldShowMenuAB(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.BIsNormal);
 }
 public bool ShouldShowMenuALocal(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.LocalExists && !selectionInfo.AIsLocal);
 }
 public bool ShouldShowMenuAParentLocal(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.LocalExists);
 }
 public bool ShouldShowMenuParents(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.ShowParentItems);
 }
 public bool ShouldShowMenuBParentLocal(ContextMenuDiffToolInfo selectionInfo)
 {
     return(selectionInfo.LocalExists && selectionInfo.BIsNormal);
 }