Ejemplo n.º 1
0
        public void TestPst()
        {
            var dlg = new PromptForm();
            dlg.Prompt = "Table name:";
            if (dlg.ShowDialog(NppWindow) == DialogResult.OK)
            {
                MenuCommand(NppSharp.MenuCommand.FileNew);

                var parser = new PstParser();
                parser.Process(dlg.Value);

                foreach (var table in parser.Tables)
                {
                    Insert("Table: " + table.Name + "\r\n");
                    foreach (var field in table.Fields) Insert("  - " + field.Name + "\r\n");
                }

                if (parser.RelInds.Any())
                {
                    Insert("RelInds:\r\n");
                    foreach (var relind in parser.RelInds) Insert("  - " + relind.Name + "\r\n");
                }

                Insert("\r\n\r\n");
                Insert(parser.Source);
            }
        }
Ejemplo n.º 2
0
        public void PstTable()
        {
            try
            {
                using (PromptForm dlg = new PromptForm())
                {
                    string selected = SelectedText;
                    if (!string.IsNullOrEmpty(selected) && ProbeEnvironment.IsProbeTable(selected))
                    {
                        dlg.Value = selected;
                    }

                    dlg.Text = "PST Table";
                    dlg.Prompt = "Enter the name of the table to PST:";
                    if (dlg.ShowDialog(_nppWindow) == DialogResult.OK)
                    {
                        string tableName = dlg.Value;

                        ProcessRunner pr = new ProcessRunner();
                        StringOutput output = new StringOutput();
                        int exitCode = pr.CaptureProcess("pst.exe", tableName, ProbeEnvironment.TempDir, output);

                        if (exitCode != 0)
                        {
                            Errors.ShowExtended(_nppWindow, string.Format("PST returned exit code {0}.", exitCode), output.Text);
                        }
                        else
                        {
                            string tempFileName = TempManager.GetNewTempFileName(tableName, ".pst");
                            File.WriteAllText(tempFileName, output.Text);
                            OpenFile(tempFileName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Errors.Show(_nppWindow, ex);
            }
        }
Ejemplo n.º 3
0
 private void OnCreateNewFile(string dir, TreeNode parentNode)
 {
     using (var form = new PromptForm())
     {
         form.AllowEmpty = false;
         if (form.ShowDialog() == DialogResult.OK)
         {
             var fileName = form.Value;
             if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
             {
                 Errors.Show(this, "This file name contains invalid characters.");
             }
             else
             {
                 var pathName = Path.Combine(dir, fileName);
                 if (File.Exists(pathName))
                 {
                     Errors.Show(this, "This file already exists.");
                 }
                 else
                 {
                     using (var stream = File.Create(pathName))
                     {
                     }
                     PopulateFileTree_AddFile(parentNode, pathName);
                     AddProbeFile(pathName);
                 }
                 _plugin.OpenFile(pathName);
                 _plugin.CreateFileHeaderText(pathName);
             }
         }
     }
 }