/// <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() { 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() { 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); } } }
/// <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); } } } }