예제 #1
0
		async void CreateWiget ()
		{
			if (widget == null) {
				widget = new DiffWidget (info);
				try {
					ComparisonWidget.DiffEditor.Document.Text = await info.Item.Repository.GetBaseTextAsync (info.Item.Path);
				} catch (Exception ex) {
					LoggingService.LogInternalError ("Error fetching text from repository ", ex);
				}

				ComparisonWidget.SetLocal (ComparisonWidget.OriginalEditor.GetTextEditorData ());
				widget.ShowAll ();
			}
		}
예제 #2
0
            public void ActivateItem(int n)
            {
                var textEditor = (MonoTextEditor)box.Tag;

                if (n == 0)
                {
                    box.SetItem(GettextCatalog.GetString("Local"), null, new object());
                    widget.SetLocal(textEditor.GetTextEditorData());
                    return;
                }
                widget.RemoveLocal(textEditor.GetTextEditorData());
                textEditor.Document.IsReadOnly = true;

                if (n == 1)
                {
                    box.SetItem(GettextCatalog.GetString("Base"), null, new object());
                    if (textEditor == widget.editors[0])
                    {
                        widget.diffRevision = null;
                    }
                    else
                    {
                        widget.originalRevision = null;
                    }
                    Task.Run(async() => {
                        try {
                            return(await widget.info.Item.Repository.GetBaseTextAsync(widget.info.Item.Path));
                        } catch (Exception ex) {
                            var text = string.Format(GettextCatalog.GetString("Error while getting the base text of {0}:\n{1}"), widget.info.Item.Path, ex.ToString());
                            await Runtime.RunInMainThread(() => MessageService.ShowError(text));
                            return(text);
                        }
                    }).ContinueWith(t => {
                        var editor = (MonoTextEditor)box.Tag;
                        if (editor.IsDisposed)
                        {
                            return;
                        }
                        editor.Document.Text = t.Result;
                        widget.CreateDiff();
                    }, Runtime.MainTaskScheduler);
                    return;
                }

                Revision rev = widget.info.History[n - 2];

                widget.SetRevision(textEditor, rev);
            }
예제 #3
0
            public void ActivateItem(int n)
            {
                if (n == 0)
                {
                    box.SetItem("Local", null, new object());
                    widget.SetLocal(((TextEditor)box.Tag).GetTextEditorData());
                    return;
                }
                widget.RemoveLocal(((TextEditor)box.Tag).GetTextEditorData());
                ((TextEditor)box.Tag).Document.ReadOnly = true;
                if (n == 1)
                {
                    box.SetItem("Base", null, new object());
                    if (((TextEditor)box.Tag) == widget.editors[0])
                    {
                        widget.diffRevision = null;
                    }
                    else
                    {
                        widget.originalRevision = null;
                    }
                    string text;
                    try
                    {
                        text = widget.info.Item.Repository.GetBaseText(widget.info.Item.Path);
                    }
                    catch (Exception ex)
                    {
                        text = string.Format(GettextCatalog.GetString("Error while getting the base text of {0}:\n{1}"), widget.info.Item.Path, ex.ToString());
                        MessageService.ShowError(text);
                    }

                    ((TextEditor)box.Tag).Document.Text = text;
                    widget.CreateDiff();
                    return;
                }

                Revision rev = widget.info.History[n - 2];

                widget.SetRevision((TextEditor)box.Tag, rev);
            }
예제 #4
0
		public ComparisonView (VersionControlDocumentInfo info) : base ("Comparison")
		{
			this.info = info;
			widget = new ComparisonWidget (info);
			
			widget.OriginalEditor.Document.MimeType = widget.DiffEditor.Document.MimeType = info.Document.Editor.Document.MimeType;
			widget.OriginalEditor.Options.FontName = widget.DiffEditor.Options.FontName = info.Document.Editor.Options.FontName;
			widget.OriginalEditor.Options.ColorScheme = widget.DiffEditor.Options.ColorScheme = info.Document.Editor.Options.ColorScheme;
			widget.OriginalEditor.Options.ShowFoldMargin = widget.DiffEditor.Options.ShowFoldMargin = false;
			widget.OriginalEditor.Options.ShowIconMargin = widget.DiffEditor.Options.ShowIconMargin = false;
			widget.DiffEditor.Document.Text = info.Item.Repository.GetBaseText (info.Item.Path);
			widget.SetLocal (widget.OriginalEditor.GetTextEditorData ());
			widget.ShowAll ();
		}