Exemplo n.º 1
0
        /// <summary>
        /// Do comparison.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;
            ISourceFileEditorDocument currentDocument = CurrentDocument;

            if (project != null && currentDocument != null)
            {
                SourceFileContent content = null;

                using (App.Wait("Comparing files"))
                    content = project.Client.Meta.GetSourceFileContent(currentDocument.File);

                if (currentDocument.Content == content.ContentValue)
                {
                    App.MessageUser("The version on the server is identical to your current version.",
                                    "Compare",
                                    System.Windows.MessageBoxImage.Information,
                                    new string[] { "OK" });
                }
                else
                {
                    string           diff     = DiffUtility.Diff(content.ContentValue, currentDocument.Content);
                    TextViewDocument document = new TextViewDocument(
                        project,
                        diff,
                        currentDocument.File.Name,
                        "Compare.png",
                        true);

                    App.Instance.Content.OpenDocument(document);
                }
            }
        }
        /// <summary>
        /// Do comparison.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;
            ISourceFileEditorDocument currentDocument = CurrentDocument;

            if (project != null && currentDocument != null)
            {
                string olderText = project.Repository.GetContent(currentDocument.File, null);
                string newerText = currentDocument.Content;

                if (olderText == currentDocument.Content)
                {
                    App.MessageUser("The most recent version in source control is identical to your current version.",
                                    "Compare",
                                    System.Windows.MessageBoxImage.Information,
                                    new string[] { "OK" });
                }
                else
                {
                    string           diff     = DiffUtility.Diff(olderText, currentDocument.Content);
                    TextViewDocument document = new TextViewDocument(
                        project,
                        diff,
                        currentDocument.File.Name,
                        "Compare.png",
                        true);

                    App.Instance.Content.OpenDocument(document);
                }
            }
        }
        /// <summary>
        /// Do comparison.
        /// </summary>
        public override void Execute()
        {
            ISourceFileEditorDocument currentDocument = CurrentDocument;

            if (currentDocument != null)
            {
                string extension = System.IO.Path.GetExtension(currentDocument.File.FileName);
                if (extension.StartsWith("."))
                {
                    extension = extension.Substring(1);
                }

                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Title       = "Select file to compare with";
                dlg.Multiselect = false;
                dlg.Filter      = String.Format("{0} Files|*.{1}|All Files|*.*", extension.ToUpper(), extension);

                bool?result = dlg.ShowDialog();
                if (result.HasValue && result.Value)
                {
                    string diff = DiffUtility.Diff(
                        System.IO.File.ReadAllText(dlg.FileName),
                        currentDocument.Content);

                    TextViewDocument document = new TextViewDocument(
                        App.Instance.SalesForceApp.CurrentProject,
                        diff,
                        currentDocument.File.Name,
                        "Compare.png",
                        true);

                    App.Instance.Content.OpenDocument(document);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Open the commit.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;
            SimpleRepositoryCommit commit   = GetSelectedCommit();
            CommitListDocument     document = App.Instance.Content.ActiveDocument as CommitListDocument;

            if (project != null && commit != null && document != null)
            {
                string text = null;
                using (App.Wait("Getting older version."))
                    text = project.Repository.GetContent(document.File, commit);

                string           title = String.Format("{0} [{1}]", document.File.Name, commit.ShaShort);
                TextViewDocument doc   = new TextViewDocument(project, text, title, "History.png", false);
                App.Instance.Content.OpenDocument(doc);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Open the commit.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;
            SimpleRepositoryCommit commit = GetSelectedCommit();
            string             detail     = GetSelectedDetail();
            CommitListDocument document   = App.Instance.Content.ActiveDocument as CommitListDocument;

            if (project != null && commit != null && detail != null && document != null)
            {
                string text = null;
                using (App.Wait("Getting older version."))
                    text = project.Repository.GetChangedFileDiff(detail, commit);

                string           title = detail;
                TextViewDocument doc   = new TextViewDocument(project, text, title, "Compare.png", true);
                App.Instance.Content.OpenDocument(doc);
            }
        }
        /// <summary>
        /// Open the commit.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;

            SimpleRepositoryCommit[] commits  = GetSelectedCommits();
            CommitListDocument       document = App.Instance.Content.ActiveDocument as CommitListDocument;

            if (project != null && commits != null && document != null)
            {
                string text = null;
                using (App.Wait("Creating diff."))
                    text = project.Repository.Diff(document.File, commits[1], commits[0]);

                string title = String.Format(
                    "{0} [{1}/{2}]",
                    document.File.Name,
                    commits[1].ShaShort,
                    commits[0].ShaShort);

                TextViewDocument doc = new TextViewDocument(project, text, title, "Compare.png", true);
                App.Instance.Content.OpenDocument(doc);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Do comparison.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;
            ISourceFileEditorDocument currentDocument = CurrentDocument;

            if (project != null && currentDocument != null)
            {
                string otherText = null;

                // get the project to compare with
                List <string> projectNames = new List <string>(Project.Projects);
                projectNames.Remove(project.ProjectName);

                SelectProjectWindow dlg = new SelectProjectWindow();
                dlg.ProjectNames = projectNames.ToArray();
                dlg.SelectLabel  = "Select";
                if (App.ShowDialog(dlg))
                {
                    // get the other text from the selected project
                    using (App.Wait("Getting file for comparison"))
                    {
                        using (Project otherProject = Project.OpenProject(dlg.SelectedProjectName))
                        {
                            SourceFile[] otherFiles = otherProject.Client.Meta.GetSourceFiles(
                                new SourceFileType[] { currentDocument.File.FileType },
                                false);

                            foreach (SourceFile otherFile in otherFiles)
                            {
                                if (otherFile.Name == currentDocument.File.Name)
                                {
                                    SourceFileContent otherContent = otherProject.Client.Meta.GetSourceFileContent(otherFile);
                                    otherText = otherContent.ContentValue;
                                    break;
                                }
                            }

                            if (otherText == null)
                            {
                                otherText = String.Empty;
                            }
                        }
                    }
                }

                // do comparison
                if (otherText != null)
                {
                    if (currentDocument.Content == otherText)
                    {
                        App.MessageUser("The version in the other project is identical to your current version.",
                                        "Compare",
                                        System.Windows.MessageBoxImage.Information,
                                        new string[] { "OK" });
                    }
                    else
                    {
                        string           diff     = DiffUtility.Diff(otherText, currentDocument.Content);
                        TextViewDocument document = new TextViewDocument(
                            project,
                            diff,
                            currentDocument.File.Name,
                            "Compare.png",
                            true);

                        App.Instance.Content.OpenDocument(document);
                    }
                }
            }
        }