Example #1
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);
            }
Example #2
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);
            }