internal bool ProcessKeyActionIfNeeded(Event e) { DiffTreeViewMenuOperations operationToExecute = GetMenuOperation(e); if (operationToExecute == DiffTreeViewMenuOperations.None) { return(false); } SelectedDiffsGroupInfo info = mOperations.GetSelectedDiffsGroupInfo(); DiffTreeViewMenuOperations operations = DiffTreeViewMenuUpdater.GetAvailableMenuOperations(info); if (!operations.HasFlag(operationToExecute)) { return(false); } ProcessMenuOperation(operationToExecute); return(true); }
void UpdateMenuItems(GenericMenu menu) { SelectedDiffsGroupInfo groupInfo = mOperations.GetSelectedDiffsGroupInfo(); DiffTreeViewMenuOperations operations = DiffTreeViewMenuUpdater.GetAvailableMenuOperations(groupInfo); if (operations == DiffTreeViewMenuOperations.None) { menu.AddDisabledItem(GetNoActionMenuItemContent()); return; } bool isMultipleSelection = groupInfo.SelectedItemsCount > 1; bool selectionHasMeta = mMetaMenuOperations.SelectionHasMeta(); if (operations.HasFlag(DiffTreeViewMenuOperations.SaveAs)) { menu.AddItem(mSaveRevisionAsMenuItemContent, false, SaveRevisionAsMenuItem_Click); } if (operations.HasFlag(DiffTreeViewMenuOperations.Diff)) { menu.AddItem(mDiffMenuItemContent, false, DiffMenuItem_Click); } else { menu.AddDisabledItem(mDiffMenuItemContent, false); } if (mMetaMenuOperations.SelectionHasMeta()) { if (operations.HasFlag(DiffTreeViewMenuOperations.Diff)) { menu.AddItem(mDiffMetaMenuItemContent, false, DiffMetaMenuItem_Click); } else { menu.AddDisabledItem(mDiffMetaMenuItemContent); } } menu.AddSeparator(string.Empty); if (operations.HasFlag(DiffTreeViewMenuOperations.History)) { menu.AddItem(mViewHistoryMenuItemContent, false, HistoryMenuItem_Click); } else { menu.AddDisabledItem(mViewHistoryMenuItemContent, false); } if (mMetaMenuOperations.SelectionHasMeta()) { if (operations.HasFlag(DiffTreeViewMenuOperations.History)) { menu.AddItem(mViewHistoryMetaMenuItemContent, false, HistoryMetaMenuItem_Click); } else { menu.AddDisabledItem(mViewHistoryMetaMenuItemContent, false); } } if (operations.HasFlag(DiffTreeViewMenuOperations.RevertChanges)) { menu.AddSeparator(string.Empty); mRevertMenuItemContent.text = GetRevertMenuItemText( isMultipleSelection, selectionHasMeta); menu.AddItem(mRevertMenuItemContent, false, RevertMenuItem_Click); } if (operations.HasFlag(DiffTreeViewMenuOperations.Undelete) || operations.HasFlag(DiffTreeViewMenuOperations.UndeleteToSpecifiedPaths)) { menu.AddSeparator(string.Empty); } if (operations.HasFlag(DiffTreeViewMenuOperations.Undelete)) { mUndeleteMenuItemContent.text = GetUndeleteMenuItemText( isMultipleSelection, selectionHasMeta); menu.AddItem(mUndeleteMenuItemContent, false, UndeleteMenuItem_Click); } if (operations.HasFlag(DiffTreeViewMenuOperations.UndeleteToSpecifiedPaths)) { mUndeleteToSpecifiedPathMenuItemContent.text = GetUndeleteToSpecifiedPathMenuItemText( isMultipleSelection, selectionHasMeta); menu.AddItem(mUndeleteToSpecifiedPathMenuItemContent, false, UndeleteToSpecifiedPathMenuItem_Click); } }