diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-10-18 09:59:14 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-10-18 09:59:14 +0400 |
commit | a6e1400af37feff0af739bdf7f4fa788016cc7b3 (patch) | |
tree | d6517af93b46326d3b680674e429fceb76697c09 /main/src/addins/VersionControl | |
parent | ad63357a0aa97c8b10f01ec3c1e54c54ec1f6f68 (diff) | |
parent | a4954f61e72d18c33e4803e20105407830ad623d (diff) |
Merge branch 'master' into newresolver
Conflicts:
main/src/addins/MonoDevelop.MacDev/Makefile.am
main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs
main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom.Parser/TypeResolverVisitor.cs
main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Dom/DomType.cs
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.NavigateToDialog/SearchResult.cs
main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs
Diffstat (limited to 'main/src/addins/VersionControl')
30 files changed, 845 insertions, 321 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml index 9cf5f4ad34..07a656579b 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml @@ -6,16 +6,16 @@ url = "http://www.monodevelop.com/" description = "Git support for the Version Control Add-in" category = "Version Control" - version = "2.8"> + version = "2.8.1"> <Runtime> <Import assembly="MonoDevelop.VersionControl.Git.dll"/> </Runtime> <Dependencies> - <Addin id="Core" version="2.8"/> - <Addin id="Ide" version="2.8"/> - <Addin id="VersionControl" version="2.8"/> + <Addin id="Core" version="2.8.1"/> + <Addin id="Ide" version="2.8.1"/> + <Addin id="VersionControl" version="2.8.1"/> </Dependencies> <Extension path="/MonoDevelop/VersionControl/VersionControlSystems"> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml index 2dcbea4b75..717c6c3c1c 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.addin.xml @@ -6,13 +6,13 @@ url = "http://taubz.for.net/code/diff"
description = "Subversion support for Linux and MacOSX"
category = "Version Control"
- version = "2.8">
+ version = "2.8.1">
<Dependencies>
- <Addin id="Core" version="2.8"/>
- <Addin id="Ide" version="2.8"/>
- <Addin id="VersionControl" version="2.8"/>
- <Addin id="VersionControl.Subversion" version="2.8"/>
+ <Addin id="Core" version="2.8.1"/>
+ <Addin id="Ide" version="2.8.1"/>
+ <Addin id="VersionControl" version="2.8.1"/>
+ <Addin id="VersionControl.Subversion" version="2.8.1"/>
</Dependencies> <Extension path = "/MonoDevelop/VersionControl/VersionControlSystems">
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml index df50f85962..9b3837be01 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.addin.xml @@ -7,12 +7,12 @@ description = "Subversion core engine"
category = "Version Control"
flags = "Hidden"
- version = "2.8">
+ version = "2.8.1">
<Dependencies>
- <Addin id="Core" version="2.8"/>
- <Addin id="Ide" version="2.8"/>
- <Addin id="VersionControl" version="2.8"/>
+ <Addin id="Core" version="2.8.1"/>
+ <Addin id="Ide" version="2.8.1"/>
+ <Addin id="VersionControl" version="2.8.1"/>
</Dependencies> <Extension path = "/MonoDevelop/Ide/Commands/VersionControl"> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/Makefile.am b/main/src/addins/VersionControl/MonoDevelop.VersionControl/Makefile.am index 9de563a6a4..87b78a41c3 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/Makefile.am +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/Makefile.am @@ -31,9 +31,11 @@ FILES = \ MonoDevelop.VersionControl.Views/MergeWidget.cs \ MonoDevelop.VersionControl.Views/StatusView.cs \ MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs \ + MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs \ MonoDevelop.VersionControl/AddRemoveMoveCommand.cs \ MonoDevelop.VersionControl/AnnotateCommand.cs \ MonoDevelop.VersionControl/BaseView.cs \ + MonoDevelop.VersionControl/BlameCommand.cs \ MonoDevelop.VersionControl/ChangeLogWriter.cs \ MonoDevelop.VersionControl/ChangeSet.cs \ MonoDevelop.VersionControl/CheckoutCommand.cs \ @@ -44,9 +46,17 @@ FILES = \ MonoDevelop.VersionControl/CommitMessageFormat.cs \ MonoDevelop.VersionControl/CommitMessageStyle.cs \ MonoDevelop.VersionControl/CreatePatchCommand.cs \ + MonoDevelop.VersionControl/DefaultBlameViewHandler.cs \ + MonoDevelop.VersionControl/DefaultDiffViewHandler.cs \ + MonoDevelop.VersionControl/DefaultLogViewHandler.cs \ + MonoDevelop.VersionControl/DefaultMergeViewHandler.cs \ + MonoDevelop.VersionControl/DiffCommand.cs \ MonoDevelop.VersionControl/FileUpdateEventHandler.cs \ MonoDevelop.VersionControl/IRepositoryEditor.cs \ + MonoDevelop.VersionControl/IVersionControlViewHandler.cs \ MonoDevelop.VersionControl/LockCommand.cs \ + MonoDevelop.VersionControl/LogCommand.cs \ + MonoDevelop.VersionControl/MergeCommand.cs \ MonoDevelop.VersionControl/PublishCommand.cs \ MonoDevelop.VersionControl/Repository.cs \ MonoDevelop.VersionControl/RevertCommand.cs \ diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs index 7b9b8482e4..d39f273e51 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameView.cs @@ -32,7 +32,11 @@ using Mono.TextEditor; using System.Linq; namespace MonoDevelop.VersionControl.Views { - internal class BlameView : BaseView, IAttachableViewContent, IUndoHandler, IClipboardHandler + public interface IBlameView : IAttachableViewContent + { + } + + internal class BlameView : BaseView, IBlameView, IUndoHandler, IClipboardHandler { BlameWidget widget; VersionControlDocumentInfo info; @@ -45,43 +49,29 @@ namespace MonoDevelop.VersionControl.Views } } - public static bool Show (VersionControlItemList items, bool test) - { - if (!test) { - Show (items); - return true; - } - else - return items.All (i => i.VersionInfo.CanAnnotate); - } - - public static void Show (VersionControlItemList items) - { - foreach (VersionControlItem item in items) { - var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); - DiffView.AttachViewContents (document, item); - document.Window.SwitchView (document.Window.FindView (typeof(BlameView))); - } - } - public BlameView (VersionControlDocumentInfo info) : base (GettextCatalog.GetString ("Blame")) { this.info = info; - } #region IAttachableViewContent implementation public void Selected () { info.Start (); - widget.Editor.Caret.Location = info.Document.Editor.Caret.Location; - widget.Editor.VAdjustment.Value = info.Document.Editor.VAdjustment.Value; + var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> (); + if (sourceEditor != null) { + widget.Editor.Caret.Location = sourceEditor.TextEditor.Caret.Location; + widget.Editor.VAdjustment.Value = sourceEditor.TextEditor.VAdjustment.Value; + } } public void Deselected () { - info.Document.Editor.Caret.Location = widget.Editor.Caret.Location; - info.Document.Editor.VAdjustment.Value = widget.Editor.VAdjustment.Value; + var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> (); + if (sourceEditor != null) { + sourceEditor.TextEditor.Caret.Location = widget.Editor.Caret.Location; + sourceEditor.TextEditor.VAdjustment.Value = widget.Editor.VAdjustment.Value; + } } public void BeforeSave () diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs index 26c19c63b1..f51021eca4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs @@ -85,7 +85,7 @@ namespace MonoDevelop.VersionControl.Views public Ide.Gui.Document Document { get { - return info.Document; + return info.Document.WorkbenchWindow.Document; } } public VersionControlItem VersionControlItem { @@ -101,6 +101,7 @@ namespace MonoDevelop.VersionControl.Views public BlameWidget (VersionControlDocumentInfo info) { this.info = info; + var sourceEditor = info.Document.GetContent<MonoDevelop.SourceEditor.SourceEditorView> (); vAdjustment = new Adjustment (0, 0, 0, 0, 0, 0); vAdjustment.Changed += HandleAdjustmentChanged; @@ -114,7 +115,7 @@ namespace MonoDevelop.VersionControl.Views hScrollBar = new HScrollbar (hAdjustment); AddChild (hScrollBar); - editor = new TextEditor (info.Document.Editor.Document, info.Document.Editor.Options); + editor = new TextEditor (sourceEditor.TextEditor.Document, sourceEditor.TextEditor.Options); AddChild (editor); editor.SetScrollAdjustments (hAdjustment, vAdjustment); @@ -502,10 +503,10 @@ namespace MonoDevelop.VersionControl.Views if (highlightAnnotation == null) return; int i = 1; - foreach (var content in widget.info.Document.Window.SubViewContents) { + foreach (var content in widget.info.Document.WorkbenchWindow.SubViewContents) { DiffView diffView = content as DiffView; if (diffView != null) { - widget.info.Document.Window.SwitchView (i); + widget.info.Document.WorkbenchWindow.SwitchView (i); var rev = widget.info.History.FirstOrDefault (h => h.ToString () == highlightAnnotation.Revision); if (rev == null) return; @@ -523,10 +524,10 @@ namespace MonoDevelop.VersionControl.Views if (highlightAnnotation == null) return; int i = 1; - foreach (var content in widget.info.Document.Window.SubViewContents) { + foreach (var content in widget.info.Document.WorkbenchWindow.SubViewContents) { LogView logView = content as LogView; if (logView != null) { - widget.info.Document.Window.SwitchView (i); + widget.info.Document.WorkbenchWindow.SwitchView (i); var rev = widget.info.History.FirstOrDefault (h => h.ToString () == highlightAnnotation.Revision); if (rev == null) return; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CellRendererDiff.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CellRendererDiff.cs index a0520f47f3..5940b39063 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CellRendererDiff.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/CellRendererDiff.cs @@ -265,8 +265,8 @@ namespace MonoDevelop.VersionControl.Views if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd) { int row = (p.Value.Y - block.YStart) / lineHeight; - double yrow = block.YStart + lineHeight * row + 0.5; - double xrow = cell_area.X + LeftPaddingBlock + 0.5; + double yrow = block.YStart + lineHeight * row; + double xrow = cell_area.X + LeftPaddingBlock; int wrow = cell_area.Width - 1 - LeftPaddingBlock; if (block.Type == BlockType.Added) ctx.Color = baseAddColor.AddLight (0.1).ToCairoColor (); @@ -414,12 +414,11 @@ namespace MonoDevelop.VersionControl.Views if (!IsChangeBlock (block.Type)) return; - x += 0.5; Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor; - double y = block.YStart + 0.5; + double y = block.YStart; int height = block.YEnd - block.YStart; - double markerx = x + LeftPaddingBlock - 0.5; + double markerx = x + LeftPaddingBlock; double rd = RoundedSectionRadius; if (block.SectionStart) { ctx.Arc (x + rd, y + rd, rd, 180 * (Math.PI / 180), 270 * (Math.PI / 180)); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs index 9611267d7b..5112875a88 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs @@ -35,11 +35,12 @@ using MonoDevelop.Ide; using MonoDevelop.Components; using System.ComponentModel; using MonoDevelop.Core; +using MonoDevelop.Ide.Gui; namespace MonoDevelop.VersionControl.Views { [ToolboxItem (true)] - class ComparisonWidget : EditorCompareWidgetBase + public class ComparisonWidget : EditorCompareWidgetBase { internal DropDownBox originalComboBox, diffComboBox; @@ -72,11 +73,12 @@ namespace MonoDevelop.VersionControl.Views protected override void CreateComponents () { - this.editors = new [] { new TextEditor (), new TextEditor ()}; - DiffEditor.Document.ReadOnly = true; - if (viewOnly) { - OriginalEditor.Document.ReadOnly = true; - } else { + this.editors = new [] { + new TextEditor (new Mono.TextEditor.Document (), new CommonTextEditorOptions ()), + new TextEditor (new Mono.TextEditor.Document (), new CommonTextEditorOptions ()), + }; + + if (!viewOnly) { originalComboBox = new DropDownBox (); originalComboBox.WindowRequestFunc = CreateComboBoxSelector; originalComboBox.Text = "Local"; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs index c13fbe8ee3..ca36faf2e7 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffView.cs @@ -32,97 +32,16 @@ using System.Collections.Generic; using System.Threading; using MonoDevelop.Core; using MonoDevelop.Ide.Gui.Content; +using Mono.Addins; +using MonoDevelop.Projects.Text; namespace MonoDevelop.VersionControl.Views { - public class VersionControlDocumentInfo + public interface IDiffView : IAttachableViewContent { - bool alreadyStarted = false; - - public Document Document { - get; - set; - } - - public VersionControlItem Item { - get; - set; - } - - public Revision[] History { - get; - set; - } - - public VersionInfo VersionInfo { - get; - set; - } - - public Repository Repository { - get; - set; - } - - public bool Started { - get { return alreadyStarted; } - } - - public VersionControlDocumentInfo (Document document, VersionControlItem item, Repository repository) - { - this.Document = document; - this.Item = item; - this.Repository = repository; - } - - public void Start () - { - if (alreadyStarted) - return; - alreadyStarted = true; - ThreadPool.QueueUserWorkItem (delegate { - lock (updateLock) { - try { - History = Item.Repository.GetHistory (Item.Path, null); - VersionInfo = Item.Repository.GetVersionInfo (Item.Path, false); - } catch (Exception ex) { - LoggingService.LogError ("Error retrieving history", ex); - } - - DispatchService.GuiDispatch (delegate { - OnUpdated (EventArgs.Empty); - }); - isUpdated = true; - } - }); - } - - object updateLock = new object (); - bool isUpdated = false; - - public void RunAfterUpdate (Action act) - { - if (isUpdated) { - act (); - return; - } - while (!isUpdated) - Thread.Sleep (10); - act (); - } - - protected virtual void OnUpdated (EventArgs e) - { - EventHandler handler = this.Updated; - if (handler != null) - handler (this, e); - } - - public event EventHandler Updated; - } - class DiffView : BaseView, IAttachableViewContent, IUndoHandler, IClipboardHandler + public class DiffView : BaseView, IDiffView, IUndoHandler, IClipboardHandler { DiffWidget widget; @@ -150,39 +69,7 @@ namespace MonoDevelop.VersionControl.Views return ComparisonWidget.Diff; } } - - public static void AttachViewContents (Document document, VersionControlItem item) - { - IWorkbenchWindow window = document.Window; - if (window.SubViewContents.Any (sub => sub is DiffView)) - return; - - VersionControlDocumentInfo info = new VersionControlDocumentInfo (document, item, item.Repository); - - DiffView comparisonView = new DiffView (info); - window.AttachViewContent (comparisonView); -// window.AttachViewContent (new PatchView (comparisonView, info)); - window.AttachViewContent (new BlameView (info)); - window.AttachViewContent (new LogView (info)); - - if (info.VersionInfo != null && info.VersionInfo.Status == VersionStatus.Conflicted) - window.AttachViewContent (new MergeView (info)); - } - public static void Show (VersionControlItemList items) - { - foreach (VersionControlItem item in items) { - var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); - DiffView.AttachViewContents (document, item); - document.Window.SwitchView (document.Window.FindView (typeof(DiffView))); - } - } - - public static bool CanShow (VersionControlItemList items) - { - return items.Any (i => i.VersionInfo.HasLocalChanges); - } - VersionControlDocumentInfo info; public DiffView (VersionControlDocumentInfo info) : base (GettextCatalog.GetString ("Changes")) { @@ -193,24 +80,12 @@ namespace MonoDevelop.VersionControl.Views { this.info = info; widget = new DiffWidget (info); - - ComparisonWidget.OriginalEditor.Document.MimeType = ComparisonWidget.DiffEditor.Document.MimeType = info.Document.Editor.Document.MimeType; - ComparisonWidget.OriginalEditor.Options.FontName = ComparisonWidget.DiffEditor.Options.FontName = info.Document.Editor.Options.FontName; - ComparisonWidget.OriginalEditor.Options.ColorScheme = ComparisonWidget.DiffEditor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme; - ComparisonWidget.OriginalEditor.Options.ShowFoldMargin = ComparisonWidget.DiffEditor.Options.ShowFoldMargin = false; - ComparisonWidget.OriginalEditor.Options.ShowIconMargin = ComparisonWidget.DiffEditor.Options.ShowIconMargin = false; - ComparisonWidget.SetRevision (ComparisonWidget.DiffEditor, baseRev); ComparisonWidget.SetRevision (ComparisonWidget.OriginalEditor, toRev); widget.ShowAll (); } - public override void Dispose () - { - base.Dispose (); - } - #region IAttachableViewContent implementation public int GetLineInCenter (Mono.TextEditor.TextEditor editor) @@ -223,8 +98,13 @@ namespace MonoDevelop.VersionControl.Views { info.Start (); ComparisonWidget.UpdateLocalText (); - ComparisonWidget.OriginalEditor.Document.IgnoreFoldings = true; - ComparisonWidget.OriginalEditor.Caret.Location = info.Document.Editor.Caret.Location; + var buffer = info.Document.GetContent<ITextBuffer> (); + if (buffer != null) { + int line, col; + buffer.GetLineColumnFromPosition (buffer.CursorPosition, out line, out col); + ComparisonWidget.OriginalEditor.SetCaretTo (line, col); + } + if (ComparisonWidget.Allocation.Height == 1 && ComparisonWidget.Allocation.Width == 1) { ComparisonWidget.SizeAllocated += HandleComparisonWidgetSizeAllocated; } else { @@ -235,20 +115,24 @@ namespace MonoDevelop.VersionControl.Views void HandleComparisonWidgetSizeAllocated (object o, Gtk.SizeAllocatedArgs args) { ComparisonWidget.SizeAllocated -= HandleComparisonWidgetSizeAllocated; - int line = GetLineInCenter (info.Document.Editor.Parent); - ComparisonWidget.OriginalEditor.CenterTo (line, 1); - ComparisonWidget.OriginalEditor.GrabFocus (); + var sourceEditorView = info.Document.GetContent<MonoDevelop.SourceEditor.SourceEditorView> (); + if (sourceEditorView != null) { + int line = GetLineInCenter (sourceEditorView.TextEditor); + ComparisonWidget.OriginalEditor.CenterTo (line, 1); + ComparisonWidget.OriginalEditor.GrabFocus (); + } } public void Deselected () { - info.Document.Editor.Caret.Location = ComparisonWidget.OriginalEditor.Caret.Location; - - int line = GetLineInCenter (ComparisonWidget.OriginalEditor); - if (Math.Abs (GetLineInCenter (info.Document.Editor.Parent) - line) > 2) - info.Document.Editor.CenterTo (line, 1); - - ComparisonWidget.OriginalEditor.Document.IgnoreFoldings = false; + var sourceEditor = info.Document.GetContent <MonoDevelop.SourceEditor.SourceEditorView> (); + if (sourceEditor != null) { + sourceEditor.TextEditor.Caret.Location = ComparisonWidget.OriginalEditor.Caret.Location; + + int line = GetLineInCenter (ComparisonWidget.OriginalEditor); + if (Math.Abs (GetLineInCenter (sourceEditor.TextEditor) - line) > 2) + sourceEditor.TextEditor.CenterTo (line, 1); + } } public void BeforeSave () diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs index a58fe6e046..24f3f1c094 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs @@ -26,6 +26,7 @@ using System; using System.Linq; using MonoDevelop.Core; +using MonoDevelop.Ide.Gui; namespace MonoDevelop.VersionControl.Views { @@ -88,24 +89,8 @@ namespace MonoDevelop.VersionControl.Views }; comparisonWidget.SetVersionControlInfo (info); this.buttonDiff.Clicked += HandleButtonDiffhandleClicked; - diffTextEditor = new global::Mono.TextEditor.TextEditor (); + diffTextEditor = new global::Mono.TextEditor.TextEditor (new Mono.TextEditor.Document (), new CommonTextEditorOptions ()); diffTextEditor.Document.MimeType = "text/x-diff"; - if (info.Document != null) { - diffTextEditor.Options.FontName = info.Document.Editor.Options.FontName; - diffTextEditor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme; - diffTextEditor.Options.ShowTabs = info.Document.Editor.Options.ShowTabs; - diffTextEditor.Options.ShowSpaces = info.Document.Editor.Options.ShowSpaces; - diffTextEditor.Options.ShowInvalidLines = info.Document.Editor.Options.ShowInvalidLines; - diffTextEditor.Options.ShowInvalidLines = info.Document.Editor.Options.ShowInvalidLines; - } else { - var options = MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance; - diffTextEditor.Options.FontName = options.FontName; - diffTextEditor.Options.ColorScheme = options.ColorScheme; - diffTextEditor.Options.ShowTabs = options.ShowTabs; - diffTextEditor.Options.ShowSpaces = options.ShowSpaces; - diffTextEditor.Options.ShowInvalidLines = options.ShowInvalidLines; - diffTextEditor.Options.ShowInvalidLines = options.ShowInvalidLines; - } diffTextEditor.Options.ShowFoldMargin = false; diffTextEditor.Options.ShowIconMargin = false; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs index 0bdb75428f..ae438f8b8d 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs @@ -38,6 +38,8 @@ using System.ComponentModel; using MonoDevelop.Core; using System.Globalization; using MonoDevelop.Components.Commands; +using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Projects.Text; namespace MonoDevelop.VersionControl.Views { @@ -267,33 +269,15 @@ namespace MonoDevelop.VersionControl.Views public void SetVersionControlInfo (VersionControlDocumentInfo info) { this.info = info; - - if (info.Document != null) { - foreach (var editor in editors) { - editor.Document.MimeType = info.Document.Editor.Document.MimeType; - editor.Options.FontName = info.Document.Editor.Options.FontName; - editor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme; - editor.Options.ShowSpaces = info.Document.Editor.Options.ShowSpaces; - editor.Options.ShowTabs = info.Document.Editor.Options.ShowTabs; - editor.Options.ShowEolMarkers = info.Document.Editor.Options.ShowEolMarkers; - editor.Options.ShowInvalidLines = info.Document.Editor.Options.ShowInvalidLines; - editor.Options.TabSize = info.Document.Editor.Options.TabSize; - editor.Options.ShowFoldMargin = false; - editor.Options.ShowIconMargin = false; - } - } else { - var options = MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance; - foreach (var editor in editors) { - editor.Options.FontName = options.FontName; - editor.Options.ColorScheme = options.ColorScheme; - editor.Options.ShowSpaces = options.ShowSpaces; - editor.Options.ShowTabs = options.ShowTabs; - editor.Options.ShowEolMarkers = options.ShowEolMarkers; - editor.Options.ShowInvalidLines = options.ShowInvalidLines; - editor.Options.TabSize = options.TabSize; - editor.Options.ShowFoldMargin = false; - editor.Options.ShowIconMargin = false; - } + + var mimeType = DesktopService.GetMimeTypeForUri (info.Item.Path); + foreach (var editor in editors) { + editor.Document.IgnoreFoldings = true; + editor.Document.MimeType = mimeType; + editor.Document.ReadOnly = true; + + editor.Options.ShowFoldMargin = false; + editor.Options.ShowIconMargin = false; } } @@ -475,6 +459,17 @@ namespace MonoDevelop.VersionControl.Views protected override void OnDestroyed () { base.OnDestroyed (); + + if (vAdjustment != null) { + vAdjustment.Destroy (); + hAdjustment.Destroy (); + foreach (var adj in attachedVAdjustments) + adj.Destroy (); + foreach (var adj in attachedHAdjustments) + adj.Destroy (); + vAdjustment = null; + } + children.ForEach (child => child.Child.Destroy ()); } @@ -620,9 +615,10 @@ namespace MonoDevelop.VersionControl.Views public void UpdateLocalText () { + var text = info.Document.GetContent<ITextFile> (); foreach (var data in dict.Values) { data.Document.TextReplaced -= HandleDataDocumentTextReplaced; - data.Document.Text = info.Document.Editor.Document.Text; + data.Document.Text = text.Text; data.Document.TextReplaced += HandleDataDocumentTextReplaced; } CreateDiff (); @@ -633,8 +629,12 @@ namespace MonoDevelop.VersionControl.Views if (info == null) throw new InvalidOperationException ("Version control info must be set before attaching the merge view to an editor."); dict[data.Document] = data; - data.Document.Text = info.Document.Editor.Document.Text; - data.Document.ReadOnly = false; + + var editor = info.Document.GetContent <ITextFile> (); + if (editor != null) + data.Document.Text = editor.Text; + data.Document.ReadOnly = info.Document.GetContent<IEditableTextFile> () == null; + CreateDiff (); data.Document.TextReplaced += HandleDataDocumentTextReplaced; } @@ -643,7 +643,9 @@ namespace MonoDevelop.VersionControl.Views { var data = dict[(Document)sender]; localUpdate.Remove (data); - info.Document.Editor.Replace (e.Offset, e.Count, e.Value); + var editor = info.Document.GetContent<IEditableTextFile> (); + editor.DeleteText (e.Offset, e.Count); + editor.InsertText (e.Offset, e.Value); localUpdate.Add (data); UpdateDiff (); } @@ -651,7 +653,6 @@ namespace MonoDevelop.VersionControl.Views public void RemoveLocal (TextEditorData data) { localUpdate.Remove (data); - data.Document.ReadOnly = true; data.Document.TextReplaced -= HandleDataDocumentTextReplaced; } @@ -1050,10 +1051,11 @@ namespace MonoDevelop.VersionControl.Views void DrawBar (Cairo.Context cr, double y, double h) { - const int barWidth = 8; + int barPadding = 3; + int barWidth = Allocation.Width - barPadding - barPadding; MonoDevelop.Components.CairoExtensions.RoundedRectangle (cr, - 0.5 + (Allocation.Width - barWidth) / 2, + barPadding, y, barWidth, h, diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogView.cs index 9d20d63449..4db0bddbef 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogView.cs @@ -9,7 +9,11 @@ using System.Linq; namespace MonoDevelop.VersionControl.Views { - public class LogView : BaseView, IAttachableViewContent + public interface ILogView : IAttachableViewContent + { + } + + public class LogView : BaseView, ILogView { string filepath; LogWidget widget; @@ -24,26 +28,6 @@ namespace MonoDevelop.VersionControl.Views } } - public static void Show (VersionControlItemList items, Revision since) - { - foreach (VersionControlItem item in items) { - if (!item.IsDirectory) { - var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); - if (document != null) { - DiffView.AttachViewContents (document, item); - document.Window.SwitchView (document.Window.FindView (typeof(LogView))); - } else { - VersionControlDocumentInfo info = new VersionControlDocumentInfo (null, item, item.Repository); - LogView logView = new LogView (info); - info.Document = IdeApp.Workbench.OpenDocument (logView, true); - logView.Selected (); - } - } else if (item.VersionInfo.CanLog) { - new Worker (item.Repository, item.Path, item.IsDirectory, since).Start (); - } - } - } - class Worker : Task { Repository vc; string filepath; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs index bb055798e7..01d5dc51c5 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/LogWidget.cs @@ -95,19 +95,21 @@ namespace MonoDevelop.VersionControl.Views protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { using (Cairo.Context cr = Gdk.CairoHelper.Create (window)) { - cr.Arc (cell_area.X + cell_area.Width / 2, cell_area.Y + cell_area.Height / 2, 5, 0, 2 * Math.PI); + cr.LineWidth = 2.0; + double center_x = cell_area.X + Math.Round ((double) (cell_area.Width / 2d)); + double center_y = cell_area.Y + Math.Round ((double) (cell_area.Height / 2d)); + cr.Arc (center_x, center_y, 5, 0, 2 * Math.PI); cr.Color = new Cairo.Color (0, 0, 0); cr.Stroke (); - double h = (cell_area.Height - 10) / 2; if (!FirstNode) { - cr.MoveTo (cell_area.X + cell_area.Width / 2, cell_area.Y - 1); - cr.LineTo (cell_area.X + cell_area.Width / 2, cell_area.Y + h); + cr.MoveTo (center_x, cell_area.Y - 2); + cr.LineTo (center_x, center_y - 5); cr.Stroke (); } if (!LastNode) { - cr.MoveTo (cell_area.X + cell_area.Width / 2, cell_area.Y + cell_area.Height + 1); - cr.LineTo (cell_area.X + cell_area.Width / 2, cell_area.Y + cell_area.Height - h); + cr.MoveTo (center_x, cell_area.Y + cell_area.Height + 2); + cr.LineTo (center_x, center_y + 5); cr.Stroke (); } } @@ -119,7 +121,7 @@ namespace MonoDevelop.VersionControl.Views this.Build (); this.info = info; if (info.Document != null) - this.preselectFile = info.Document.FileName; + this.preselectFile = info.Item.Path; revertButton = new Gtk.ToolButton (new Gtk.Image ("vc-revert-command", Gtk.IconSize.Menu), GettextCatalog.GetString ("Revert changes from this revision")); revertButton.IsImportant = true; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs index 6b7d858e44..724d062293 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeView.cs @@ -30,7 +30,11 @@ using MonoDevelop.Core; namespace MonoDevelop.VersionControl.Views { - class MergeView : BaseView, IAttachableViewContent + public interface IMergeView : IAttachableViewContent + { + } + + class MergeView : BaseView, IMergeView { MergeWidget widget; @@ -40,15 +44,6 @@ namespace MonoDevelop.VersionControl.Views } } - public static void Show (VersionControlItemList items) - { - foreach (VersionControlItem item in items) { - var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); - DiffView.AttachViewContents (document, item); - document.Window.SwitchView (document.Window.FindView (typeof (MergeView))); - } - } - public MergeView (VersionControlDocumentInfo info) : base (GettextCatalog.GetString ("Merge")) { widget = new MergeWidget (); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs index a6fe912c84..9ab8a99e25 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs @@ -53,6 +53,7 @@ namespace MonoDevelop.VersionControl.Views public MergeWidget () { + MainEditor.Document.TextReplaced += UpdateConflictsOnTextReplace; } protected override void UndoChange (TextEditor fromEditor, TextEditor toEditor, Hunk hunk) @@ -88,12 +89,15 @@ namespace MonoDevelop.VersionControl.Views MainEditor.Document.Text = System.IO.File.ReadAllText (fileName); this.CreateDiff (); - MainEditor.Document.TextReplaced += delegate { - this.UpdateDiff (); - }; Show (); } + protected override void OnDestroyed () + { + base.OnDestroyed (); + MainEditor.Document.TextReplaced -= UpdateConflictsOnTextReplace; + } + public string GetResultText () { return MainEditor.Text; @@ -222,7 +226,6 @@ namespace MonoDevelop.VersionControl.Views editors[2].Insert (editors[2].Document.Length, lastPart); UpdateDiff (); - MainEditor.Document.TextReplaced += UpdateConflictsOnTextReplace; } IEnumerable<ISegment> GetAllConflictingSegments () @@ -238,6 +241,7 @@ namespace MonoDevelop.VersionControl.Views void UpdateConflictsOnTextReplace (object sender, ReplaceEventArgs e) { + this.UpdateDiff (); Document.UpdateSegments (GetAllConflictingSegments (), e); } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs index 768dbd31a5..42f9856bf2 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/SubviewAttachmentHandler.cs @@ -24,7 +24,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; +using System.Linq; using MonoDevelop.Components.Commands; +using Mono.Addins; +using MonoDevelop.VersionControl; +using MonoDevelop.Ide.Gui; namespace MonoDevelop.VersionControl.Views { @@ -37,18 +41,27 @@ namespace MonoDevelop.VersionControl.Views void HandleDocumentOpened (object sender, Ide.Gui.DocumentEventArgs e) { - if (e.Document.Project == null) + if (!e.Document.IsFile || e.Document.Project == null) return; + var repo = VersionControlService.GetRepository (e.Document.Project); - if (repo == null) - return; - if (!e.Document.IsFile || !repo.GetVersionInfo (e.Document.FileName).IsVersioned) + if (repo == null || !repo.GetVersionInfo (e.Document.FileName).IsVersioned) return; - if (e.Document.Editor == null) - return; - var item = new VersionControlItem (repo, e.Document.Project, e.Document.FileName, false, null); - DiffView.AttachViewContents (e.Document, item); + var item = new VersionControlItem (repo, e.Document.Project, e.Document.FileName, false, null); + TryAttachView <IDiffView> (e.Document, item, DiffCommand.DiffViewHandlers); + TryAttachView <IBlameView> (e.Document, item, BlameCommand.BlameViewHandlers); + TryAttachView <ILogView> (e.Document, item, LogCommand.LogViewHandlers); + TryAttachView <IMergeView> (e.Document, item, MergeCommand.MergeViewHandlers); + } + + void TryAttachView <T>(Document document, VersionControlItem item, string type) + where T : IAttachableViewContent + { + var handler = AddinManager.GetExtensionObjects<IVersionControlViewHandler<T>> (type).FirstOrDefault (h => h.CanHandle (item)); + if (handler != null) { + document.Window.AttachViewContent (handler.CreateView (item, document.PrimaryView)); + } } } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs new file mode 100644 index 0000000000..369e59a276 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/VersionControlDocumentInfo.cs @@ -0,0 +1,126 @@ +// +// VersionControlView.cs +// +// Author: +// Mike Krüger <mkrueger@novell.com> +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using System.IO; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using System.Collections.Generic; +using System.Threading; +using MonoDevelop.Core; +using MonoDevelop.Ide.Gui.Content; +using Mono.Addins; + +namespace MonoDevelop.VersionControl.Views +{ + public class VersionControlDocumentInfo + { + bool alreadyStarted = false; + + public IViewContent Document { + get; + set; + } + + public VersionControlItem Item { + get; + set; + } + + public Revision[] History { + get; + set; + } + + public VersionInfo VersionInfo { + get; + set; + } + + public Repository Repository { + get; + set; + } + + public bool Started { + get { return alreadyStarted; } + } + + public VersionControlDocumentInfo (IViewContent document, VersionControlItem item, Repository repository) + { + this.Document = document; + this.Item = item; + this.Repository = repository; + } + + public void Start () + { + if (alreadyStarted) + return; + alreadyStarted = true; + ThreadPool.QueueUserWorkItem (delegate { + lock (updateLock) { + try { + History = Item.Repository.GetHistory (Item.Path, null); + VersionInfo = Item.Repository.GetVersionInfo (Item.Path, false); + } catch (Exception ex) { + LoggingService.LogError ("Error retrieving history", ex); + } + + DispatchService.GuiDispatch (delegate { + OnUpdated (EventArgs.Empty); + }); + isUpdated = true; + } + }); + } + + object updateLock = new object (); + bool isUpdated = false; + + public void RunAfterUpdate (Action act) + { + if (isUpdated) { + act (); + return; + } + while (!isUpdated) + Thread.Sleep (10); + act (); + } + + protected virtual void OnUpdated (EventArgs e) + { + EventHandler handler = this.Updated; + if (handler != null) + handler (this, e); + } + + public event EventHandler Updated; + + } +} diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj index 0f97797225..e78d3a869f 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.csproj @@ -218,6 +218,16 @@ <Compile Include="gtk-gui\MonoDevelop.VersionControl.Views.LogWidget.cs" /> <Compile Include="MonoDevelop.VersionControl\IRepositoryEditor.cs" /> <Compile Include="MonoDevelop.VersionControl\VersionControlOperation.cs" /> + <Compile Include="MonoDevelop.VersionControl.Views\VersionControlDocumentInfo.cs" /> + <Compile Include="MonoDevelop.VersionControl\IVersionControlViewHandler.cs" /> + <Compile Include="MonoDevelop.VersionControl\DefaultDiffViewHandler.cs" /> + <Compile Include="MonoDevelop.VersionControl\DefaultBlameViewHandler.cs" /> + <Compile Include="MonoDevelop.VersionControl\DefaultLogViewHandler.cs" /> + <Compile Include="MonoDevelop.VersionControl\DefaultMergeViewHandler.cs" /> + <Compile Include="MonoDevelop.VersionControl\LogCommand.cs" /> + <Compile Include="MonoDevelop.VersionControl\DiffCommand.cs" /> + <Compile Include="MonoDevelop.VersionControl\MergeCommand.cs" /> + <Compile Include="MonoDevelop.VersionControl\BlameCommand.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/BlameCommand.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/BlameCommand.cs new file mode 100644 index 0000000000..a6d4e04636 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/BlameCommand.cs @@ -0,0 +1,60 @@ +// +// BlameCommand.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using Mono.Addins; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class BlameCommand + { + internal static readonly string BlameViewHandlers = "/MonoDevelop/VersionControl/BlameViewHandler"; + + static bool CanShow (VersionControlItem item) + { + return !item.IsDirectory && AddinManager.GetExtensionObjects<IBlameViewHandler> (BlameViewHandlers).Any (h => h.CanHandle (item)); + } + + public static bool Show (VersionControlItemList items, bool test) + { + if (test) + return items.All (CanShow); + + foreach (var item in items) { + var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); + if (document != null) + document.Window.SwitchView (document.Window.FindView<IBlameView> ()); + } + + return true; + } + } +} + 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 cc5eaf566d..e3e0348feb 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs @@ -214,9 +214,8 @@ namespace MonoDevelop.VersionControl { protected override void Run () { - var doc = IdeApp.Workbench.ActiveDocument; - DiffView.AttachViewContents (doc, GetItem ()); - doc.Window.SwitchView (doc.Window.FindView (typeof (DiffView))); + var window = IdeApp.Workbench.ActiveDocument.Window; + window.SwitchView (window.FindView<IDiffView> ()); } } @@ -224,9 +223,8 @@ namespace MonoDevelop.VersionControl { protected override void Run () { - var doc = IdeApp.Workbench.ActiveDocument; - DiffView.AttachViewContents (doc, GetItem ()); - doc.Window.SwitchView (doc.Window.FindView (typeof (BlameView))); + var window = IdeApp.Workbench.ActiveDocument.Window; + window.SwitchView (window.FindView<IBlameView> ()); } } @@ -234,9 +232,8 @@ namespace MonoDevelop.VersionControl { protected override void Run () { - var doc = IdeApp.Workbench.ActiveDocument; - DiffView.AttachViewContents (doc, GetItem ()); - doc.Window.SwitchView (doc.Window.FindView (typeof (LogView))); + var window = IdeApp.Workbench.ActiveDocument.Window; + window.SwitchView (window.FindView<ILogView> ()); } } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultBlameViewHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultBlameViewHandler.cs new file mode 100644 index 0000000000..24a3d8c9bc --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultBlameViewHandler.cs @@ -0,0 +1,46 @@ +// +// DefaultBlameViewHandler.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class DefaultBlameViewHandler : IBlameViewHandler + { + public bool CanHandle (VersionControlItem item) + { + return DesktopService.GetMimeTypeIsText (DesktopService.GetMimeTypeForUri (item.Path)); + } + + public IBlameView CreateView (VersionControlItem item, IViewContent primaryView) + { + return new BlameView (new VersionControlDocumentInfo (primaryView, item, item.Repository)); + } + } +} diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultDiffViewHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultDiffViewHandler.cs new file mode 100644 index 0000000000..65a3d9cdde --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultDiffViewHandler.cs @@ -0,0 +1,47 @@ +// +// DefaultDiffViewHandler.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class DefaultDiffViewHandler : IDiffViewHandler + { + + public bool CanHandle (VersionControlItem item) + { + return DesktopService.GetMimeTypeIsText (DesktopService.GetMimeTypeForUri (item.Path)); + } + + public IDiffView CreateView (VersionControlItem item, IViewContent primaryView) + { + return new DiffView (new VersionControlDocumentInfo (primaryView, item, item.Repository)); + } + } +} diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultLogViewHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultLogViewHandler.cs new file mode 100644 index 0000000000..0e94e54ed6 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultLogViewHandler.cs @@ -0,0 +1,46 @@ +// +// DefaultLogViewHandler.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class DefaultLogViewHandler : ILogViewHandler + { + public bool CanHandle (VersionControlItem item) + { + return true; + } + + public ILogView CreateView (VersionControlItem item, IViewContent primaryView) + { + return new LogView (new VersionControlDocumentInfo (primaryView, item, item.Repository)); + } + } +} diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultMergeViewHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultMergeViewHandler.cs new file mode 100644 index 0000000000..d2cd2a6317 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DefaultMergeViewHandler.cs @@ -0,0 +1,46 @@ +// +// DefaultMergeViewHandler.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class DefaultMergeViewHandler : IMergeViewHandler + { + public bool CanHandle (VersionControlItem item) + { + return DesktopService.GetMimeTypeIsText (DesktopService.GetMimeTypeForUri (item.Path)); + } + + public IMergeView CreateView (VersionControlItem item, IViewContent primaryView) + { + return new MergeView (new VersionControlDocumentInfo (primaryView, item, item.Repository)); + } + } +} diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DiffCommand.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DiffCommand.cs new file mode 100644 index 0000000000..3155da86a8 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/DiffCommand.cs @@ -0,0 +1,60 @@ +// +// LogCommand.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using Mono.Addins; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class DiffCommand + { + internal static readonly string DiffViewHandlers = "/MonoDevelop/VersionControl/DiffViewHandler"; + + static bool CanShow (VersionControlItem item) + { + return !item.IsDirectory && AddinManager.GetExtensionObjects<IDiffViewHandler> (DiffViewHandlers).Any (h => h.CanHandle (item)); + } + + public static bool Show (VersionControlItemList items, bool test) + { + if (test) + return items.All (CanShow); + + foreach (var item in items) { + var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); + if (document != null) + document.Window.SwitchView (document.Window.FindView<IDiffView> ()); + } + + return true; + } + } +} + diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/IVersionControlViewHandler.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/IVersionControlViewHandler.cs new file mode 100644 index 0000000000..65ea04ede3 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/IVersionControlViewHandler.cs @@ -0,0 +1,61 @@ +// +// IVersionControlViewHandler.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Core; +using MonoDevelop.VersionControl.Views; +using MonoDevelop.Ide.Gui; + +namespace MonoDevelop.VersionControl { + + public interface IVersionControlViewHandler<T> + where T : IAttachableViewContent + { + bool CanHandle (VersionControlItem item); + T CreateView (VersionControlItem item, IViewContent primaryView); + } + + public interface IDiffViewHandler : IVersionControlViewHandler<IDiffView> + { + + } + + public interface IBlameViewHandler : IVersionControlViewHandler<IBlameView> + { + + } + + public interface ILogViewHandler : IVersionControlViewHandler<ILogView> + { + + } + + public interface IMergeViewHandler : IVersionControlViewHandler<IMergeView> + { + + } +} + diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/LogCommand.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/LogCommand.cs new file mode 100644 index 0000000000..0d002c8af3 --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/LogCommand.cs @@ -0,0 +1,66 @@ +// +// LogCommand.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using Mono.Addins; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class LogCommand + { + internal static readonly string LogViewHandlers = "/MonoDevelop/VersionControl/LogViewHandler"; + + static bool CanShow (VersionControlItem item) + { + return !item.IsDirectory && AddinManager.GetExtensionObjects<ILogViewHandler> (LogViewHandlers).Any (h => h.CanHandle (item)); + } + + public static bool Show (VersionControlItemList items, bool test) + { + if (test) + return items.All (CanShow); + + foreach (var item in items) { + var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); + if (document != null) { + document.Window.SwitchView (document.Window.FindView<ILogView> ()); + } else { + VersionControlDocumentInfo info = new VersionControlDocumentInfo (null, item, item.Repository); + LogView logView = new LogView (info); + info.Document = IdeApp.Workbench.OpenDocument (logView, true).PrimaryView; + logView.Selected (); + } + } + + return true; + } + } +} + diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/MergeCommand.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/MergeCommand.cs new file mode 100644 index 0000000000..06eff36b6b --- /dev/null +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/MergeCommand.cs @@ -0,0 +1,60 @@ +// +// MergeCommand.cs +// +// Author: +// Alan McGovern <alan@xamarin.com> +// +// Copyright 2011, Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.Linq; +using Mono.Addins; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.VersionControl.Views; + +namespace MonoDevelop.VersionControl +{ + public class MergeCommand + { + internal static readonly string MergeViewHandlers = "/MonoDevelop/VersionControl/MergeViewHandler"; + + static bool CanShow (VersionControlItem item) + { + return !item.IsDirectory && AddinManager.GetExtensionObjects<IMergeViewHandler> (MergeViewHandlers).Any (h => h.CanHandle (item)); + } + + public static bool Show (VersionControlItemList items, bool test) + { + if (test) + return items.All (CanShow); + + foreach (var item in items) { + var document = IdeApp.Workbench.OpenDocument (item.Path, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer); + if (document != null) + document.Window.SwitchView (document.Window.FindView<IMergeView> ()); + } + + return true; + } + } +} + diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs index eafa8f2846..1250bad1b6 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlNodeExtension.cs @@ -422,18 +422,10 @@ namespace MonoDevelop.VersionControl res = UpdateCommand.Update (items, test); break;
case Commands.Diff:
- if (!test) {
- DiffView.Show (items);
- } else {
- res = DiffView.CanShow (items);
- }
+ res = DiffCommand.Show (items, test);
break;
case Commands.Log:
- if (!test) {
- MonoDevelop.VersionControl.Views.LogView.Show (items, null);
- } else {
- res = MonoDevelop.VersionControl.Views.LogView.CanShow (items, null);
- }
+ res = LogCommand.Show (items, test);
break;
case Commands.Status:
res = StatusView.Show (items, test);
@@ -462,7 +454,7 @@ namespace MonoDevelop.VersionControl res = PublishCommand.Publish (it.WorkspaceObject, it.Path, test);
break;
case Commands.Annotate:
- res = BlameView.Show (items, test);
+ res = BlameCommand.Show (items, test);
break;
case Commands.CreatePatch:
res = CreatePatchCommand.CreatePatch (items, test);
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml index bfbd2347d9..1b738f85b8 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml @@ -7,7 +7,7 @@ description = "A MonoDevelop addin for using version control systems like Subversion" category = "Version Control" flags = "Hidden" - version = "2.8"> + version = "2.8.1"> <Runtime> <Import file="comment.png" /> @@ -24,9 +24,9 @@ </Runtime> <Dependencies> - <Addin id="Core" version="2.8"/> - <Addin id="Ide" version="2.8"/> - <Addin id="SourceEditor2" version="2.8"/> + <Addin id="Core" version="2.8.1"/> + <Addin id="Ide" version="2.8.1"/> + <Addin id="SourceEditor2" version="2.8.1"/> </Dependencies> <ExtensionPoint path = "/MonoDevelop/VersionControl/VersionControlSystems" name = "Version control systems"> @@ -54,6 +54,42 @@ <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet" /> </ExtensionPoint> + <ExtensionPoint path = "/MonoDevelop/VersionControl/DiffViewHandler" name = "Diff view handler"> + <Description>Handler used to create the a diff view which can display the current file.</Description> + <ExtensionNode name="Handler" objectType="MonoDevelop.VersionControl.IDiffViewHandler" /> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/VersionControl/DiffViewHandler"> + <Handler class = "MonoDevelop.VersionControl.DefaultDiffViewHandler" /> + </Extension> + + <ExtensionPoint path = "/MonoDevelop/VersionControl/BlameViewHandler" name = "Blame view handler"> + <Description>Handler used to create the a blame view which can display the current file.</Description> + <ExtensionNode name="Handler" objectType="MonoDevelop.VersionControl.IBlameViewHandler" /> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/VersionControl/BlameViewHandler"> + <Handler class = "MonoDevelop.VersionControl.DefaultBlameViewHandler" /> + </Extension> + + <ExtensionPoint path = "/MonoDevelop/VersionControl/LogViewHandler" name = "Log view handler"> + <Description>Handler used to create the a log view which can display the current file.</Description> + <ExtensionNode name="Handler" objectType="MonoDevelop.VersionControl.ILogViewHandler" /> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/VersionControl/LogViewHandler"> + <Handler class = "MonoDevelop.VersionControl.DefaultLogViewHandler" /> + </Extension> + + <ExtensionPoint path = "/MonoDevelop/VersionControl/MergeViewHandler" name = "Merge view handler"> + <Description>Handler used to create the a merge view which can display the current file.</Description> + <ExtensionNode name="Handler" objectType="MonoDevelop.VersionControl.IMergeViewHandler" /> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/VersionControl/MergeViewHandler"> + <Handler class = "MonoDevelop.VersionControl.DefaultMergeViewHandler" /> + </Extension> + <ExtensionPoint path = "/MonoDevelop/VersionControl/DiffView/ContextMenu" name = "Diff view context menu"> <Description>Context menu for the diff view.</Description> <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet" /> |