Пример #1
0
        /// <summary>
        /// Opens a new project.
        /// </summary>
        public override void Execute()
        {
            SelectProjectWindow dlg = new SelectProjectWindow();

            dlg.ProjectNames = Project.Projects;
            dlg.SelectLabel  = "Open";
            if (App.ShowDialog(dlg))
            {
                App.Instance.SalesForceApp.OpenProject(Project.OpenProject(dlg.SelectedProjectName));
            }
        }
Пример #2
0
        /// <summary>
        /// Delete a project.
        /// </summary>
        public override void Execute()
        {
            SelectProjectWindow dlg = new SelectProjectWindow();

            dlg.ProjectNames = Project.Projects;
            dlg.SelectLabel  = "Delete";
            if (App.ShowDialog(dlg))
            {
                if (App.MessageUser(
                        String.Format("Are you sure you want to delete project '{0}'", dlg.SelectedProjectName),
                        "Confirm Delete",
                        System.Windows.MessageBoxImage.Warning,
                        new string[] { "Yes", "No" }) == "Yes")
                {
                    if (App.Instance.SalesForceApp.CurrentProject != null &&
                        App.Instance.SalesForceApp.CurrentProject.ProjectName == dlg.SelectedProjectName)
                    {
                        App.Instance.SalesForceApp.CloseProject();
                    }

                    Project.DeleteProject(dlg.SelectedProjectName);
                }
            }
        }
Пример #3
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);
                    }
                }
            }
        }