diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-09-26 09:30:22 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2015-09-26 09:30:22 +0300 |
commit | a7e17d0c5b1c7134e18f00441e972ff764e1b79e (patch) | |
tree | 9659c19e4701671df82bbd23722d92d742fd567f /main/src/addins/VersionControl | |
parent | 7bc7a27f2d953bf5012b504107d511f51952c1cb (diff) |
[VCS] Refactor some code and reduce code duplication.
Diffstat (limited to 'main/src/addins/VersionControl')
-rw-r--r-- | main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs index 2fc84f82da..64dd18ff92 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs @@ -106,7 +106,7 @@ namespace MonoDevelop.VersionControl return new VersionControlItem (repo, project, doc.FileName, false, null); } - protected override void Run () + protected sealed override void Run () { VersionControlItemList items = GetItems (); RunCommand (items, false); @@ -243,30 +243,28 @@ namespace MonoDevelop.VersionControl } } - class CurrentFileDiffHandler : FileVersionControlCommandHandler + class CurrentFileViewHandler<T> : FileVersionControlCommandHandler where T:IAttachableViewContent { - protected override void Run () + protected override bool RunCommand (VersionControlItemList items, bool test) { + if (test) + return true; + var window = IdeApp.Workbench.ActiveDocument.Window; - window.SwitchView (window.FindView<IDiffView> ()); + window.SwitchView (window.FindView<T> ()); + return true; } } + + class CurrentFileDiffHandler : CurrentFileViewHandler<IDiffView> + { + } - class CurrentFileBlameHandler : FileVersionControlCommandHandler + class CurrentFileBlameHandler : CurrentFileViewHandler<IBlameView> { - protected override void Run () - { - var window = IdeApp.Workbench.ActiveDocument.Window; - window.SwitchView (window.FindView<IBlameView> ()); - } } - class CurrentFileLogHandler : FileVersionControlCommandHandler + class CurrentFileLogHandler : CurrentFileViewHandler<ILogView> { - protected override void Run () - { - var window = IdeApp.Workbench.ActiveDocument.Window; - window.SwitchView (window.FindView<ILogView> ()); - } } } |