Ejemplo 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);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set the headers.
        /// </summary>
        /// <param name="host">The type of host.</param>
        /// <param name="presenter">The presenter to use.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            ISourceFileEditorDocument document = CurrentDocument;

            if (document != null)
            {
                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Cut.png");
                    presenter.ToolTip = "Cut";
                }
                else
                {
                    presenter.Header           = "Cut";
                    presenter.Icon             = VisualHelper.CreateIconHeader(null, "Cut.png");
                    presenter.InputGestureText = "Ctrl+X";
                }

                IsVisible = true;
                IsEnabled = !document.IsReadOnly;
            }
            else
            {
                IsVisible = false;
            }
        }
        /// <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);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Import the data.
        /// </summary>
        public override void Execute()
        {
            Project project = App.Instance.SalesForceApp.CurrentProject;

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

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

                    bool?result = dlg.ShowDialog();
                    if (result.HasValue && result.Value)
                    {
                        document.Content = System.IO.File.ReadAllText(dlg.FileName);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Set the visibility of the header.
        /// </summary>
        /// <param name="host">The type of host for this function.</param>
        /// <param name="presenter">The presenter to use when updating the view.</param>
        public override void Update(FunctionHost host, IFunctionPresenter presenter)
        {
            if (App.Instance.Content.ActiveDocument is ISourceFileEditorDocument)
            {
                ISourceFileEditorDocument document = App.Instance.Content.ActiveDocument as ISourceFileEditorDocument;
                IsVisible = true;

                if (host == FunctionHost.Toolbar)
                {
                    presenter.Header  = VisualHelper.CreateIconHeader(null, "Refresh.png");
                    presenter.ToolTip = String.Format("Refresh {0}", document.File.Name);
                }
                else
                {
                    presenter.Header = String.Format("Refresh {0}", document.File.Name);
                    presenter.Icon   = VisualHelper.CreateIconHeader(null, "Refresh.png");
                }
            }
            else
            {
                IsVisible = false;
            }
        }
Ejemplo 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);
                    }
                }
            }
        }