Exemple #1
0
        internal static void DisplayEdit()
        {
            DialogResult buttonPress = (IBMi.GetConfig("dspfNotice") == "yes" ? DialogResult.Yes : DialogResult.No);

            if (buttonPress == DialogResult.No)
            {
                buttonPress = MessageBox.Show("Do you understand that you use the Display File Editor at your own risk? Currently, the Display File Editor is not ready for production use and therefore holds no responsibility of changes made to source when saving.", "Notice!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (buttonPress == DialogResult.Yes)
                {
                    IBMi.SetConfig("dspfNotice", "yes");
                }
            }

            if (buttonPress == DialogResult.Yes)
            {
                dspfEdit Editor = new dspfEdit();
                string   path   = NppFunctions.GetCurrentFileName();
                if (path.Trim() != "")
                {
                    DisplayParse parser = new LanguageTools.DisplayParse();
                    parser.ParseFile(path);
                    Editor = new dspfEdit(parser.GetRecordFormats(), path);
                    NppFunctions.RefreshWindow(path);
                }

                Editor.ShowDialog();
            }
        }
Exemple #2
0
        /// <summary>
        /// TODO: ?
        /// </summary>
        internal static void RebuildRelic()
        {
            Thread gothread = new Thread((ThreadStart) delegate {
                IBMiUtilities.DebugLog("RebuildRelic!");
                string tmpFile = Path.GetTempFileName();
                IBMi.AddOutput("Starting build of '" + IBMi.GetConfig("relicdir") + "' into " + IBMi.GetConfig("reliclib"));
                if (Main.CommandWindow != null)
                {
                    Main.CommandWindow.loadNewCommands();
                }
                IBMi.RunCommands(IBMiCommandRender.RenderRelicRebuildScript(tmpFile));
                IBMi.AddOutput("");
                foreach (string line in File.ReadAllLines(tmpFile))
                {
                    IBMi.AddOutput($"> { line }");
                }
                IBMi.AddOutput("");
                IBMi.AddOutput("End of build.");
                File.Delete(tmpFile);
                if (Main.CommandWindow != null)
                {
                    Main.CommandWindow.loadNewCommands();
                }
                IBMiUtilities.DebugLog("RebuildRelic - DONE!");
            });

            gothread.Start();
        }
Exemple #3
0
        internal static void LaunchRBLD()
        {
            DialogResult outp = MessageBox.Show("Confirm build of '" + IBMi.GetConfig("relicdir") + "' into " + IBMi.GetConfig("reliclib") + "?", "Relic Build", MessageBoxButtons.YesNo);

            if (outp == DialogResult.Yes)
            {
                IBMiNPPInstaller.RebuildRelic();
            }
        }
        internal static string[] RenderRelicRebuildScript(string tmp)
        {
            string buildDir = IBMi.GetConfig("relicdir");

            if (!buildDir.EndsWith("/"))
            {
                buildDir += '/';
            }

            return(new string[] {
                $"QUOTE RCMD CD '{ buildDir }'",
                $"QUOTE RCMD RBLD { IBMi.GetConfig("reliclib") }",
                "ASCII",
                $"RECV { buildDir }RELICBLD.log \"{ tmp }\""
            });
        }
        internal static string[] RenderFFDCollectionScript(List <SourceLine> src, string[] tmp)
        {
            IBMiUtilities.DebugLog("RenderFFDCollectionScript");
            string[] cmd = new string[(src.Count * 3) + 2];
            int      i = 0, t = 0;

            // Run commands on remote
            cmd[i++] = "ASCII";
            cmd[i++] = $"QUOTE RCMD CHGLIBL LIBL({ IBMi.GetConfig("datalibl").Replace(',', ' ')})  CURLIB({ IBMi.GetConfig("curlib") })";
            foreach (SourceLine sl in src)
            {
                cmd[i++] = $"QUOTE RCMD {IBMi.GetConfig("installlib")}/NPPDSPFFD {sl.searchResult}";
                cmd[i++] = $"RECV /home/{ IBMi.GetConfig("username") }/{ sl.searchResult }.tmp \"{ tmp[t++] }\"";
                cmd[i++] = $"QUOTE RCMD RMVLNK OBJLNK('/home/{ IBMi.GetConfig("username") }/{ sl.searchResult }.tmp')";
            }

            IBMiUtilities.DebugLog("RenderFFDCollectionScript - DONE!");
            return(cmd);
        }
        internal static string[] RenderRemoteInstallScript(List <string> sourceFiles, string library)
        {
            // Make room for <upload, copy, delete, compile> for each file
            string[] cmd = new string[sourceFiles.Count * 4 + 3];
            int      i   = 0;

            cmd[i++] = "ASCII";
            cmd[i++] = "QUOTE RCMD CRTPF FILE(QTEMP/NPPCLSRC)  RCDLEN(112) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy NPP plugin commands')";
            cmd[i++] = "QUOTE RCMD CRTPF FILE(QTEMP/NPPCMDSRC) RCDLEN(112) FILETYPE(*SRC) MAXMBRS(*NOMAX) TEXT('Deploy NPP plugin commands')";
            foreach (string file in sourceFiles)
            {
                string fileName = file.Substring(file.LastIndexOf("\\") + 1);
                string member = fileName.Substring(fileName.LastIndexOf("-") + 1, fileName.LastIndexOf(".") - (fileName.LastIndexOf("-") + 1));
                string sourceFile = null, crtCmd = null;

                switch (fileName.Substring(fileName.Length - 4))
                {
                case ".clp":
                    sourceFile = "NPPCLSRC";
                    crtCmd     = $"CRTCLPGM PGM({library}/{member}) SRCFILE(QTEMP/NPPCLSRC) SRCMBR({member}) REPLACE(*YES) TEXT('{Main.PluginDescription}')";
                    break;

                case ".cmd":
                    sourceFile = "NPPCMDSRC";
                    crtCmd     = $"CRTCMD CMD({library}/{member}) PGM({library}/{member}) SRCFILE(QTEMP/NPPCMDSRC) SRCMBR({member}) REPLACE(*YES) TEXT('{Main.PluginDescription}')";
                    break;

                default:
                    continue;
                }

                cmd[i++] = $"SEND { file } /home/{ IBMi.GetConfig("username") }/{ fileName }";
                cmd[i++] = $"QUOTE RCMD CPYFRMSTMF FROMSTMF('/home/{ IBMi.GetConfig("username") }/{ fileName }') TOMBR('/QSYS.LIB/QTEMP.LIB/{ sourceFile }.FILE/{ member }.MBR')";
                cmd[i++] = $"QUOTE RCMD RMVLNK OBJLNK('/home/{ IBMi.GetConfig("username") }/{ fileName }')";
                cmd[i++] = $"QUOTE RCMD { crtCmd }";
            }
            return(cmd);
        }
Exemple #7
0
        internal static void CommandMenuInit()
        {
            StringBuilder pluginsConfigDir = new StringBuilder(Win32.MAX_PATH);

            Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETPLUGINSCONFIGDIR, Win32.MAX_PATH, pluginsConfigDir);
            ConfigDirectory    = $"{ pluginsConfigDir.ToString() }\\{ PluginName }\\";
            SystemsDirectory   = $"{ConfigDirectory}systems\\";
            FileCacheDirectory = $"{ConfigDirectory}cache\\";

            if (!Directory.Exists(ConfigDirectory))
            {
                Directory.CreateDirectory(ConfigDirectory);
            }
            if (!Directory.Exists(SystemsDirectory))
            {
                Directory.CreateDirectory(SystemsDirectory);
            }
            if (!Directory.Exists(FileCacheDirectory))
            {
                Directory.CreateDirectory(FileCacheDirectory);
            }

            IBMiUtilities.CreateLog(ConfigDirectory + PluginName);
            RPGParser.LoadFileCache();
            CLParser.LoadFileCache();

            if (File.Exists(ConfigDirectory + "dftcfg"))
            {
                Config.SwitchToConfig(File.ReadAllText(ConfigDirectory + "dftcfg"));
            }
            else
            {
                LoadConfigSelect();
                if (Config.GetConfigs().Length == 0)
                {
                    return;
                }
                if (IBMi._ConfigFile == "" || IBMi._ConfigFile == null)
                {
                    string UseConfig = Config.GetConfigs()[0];
                    MessageBox.Show("No config selected. Defaulted to " + UseConfig + ".");
                    Config.SwitchToConfig(UseConfig);
                }
            }
            //if (IBMi.GetConfig("localDefintionsInstalled") == "false")
            //{
            //    IBMiNPPInstaller.InstallLocalDefinitions();
            //}

            bool ExperimentalFeatures = (IBMi.GetConfig("experimental") == "true");
            int  ItemOrder            = 0;

            PluginBase.SetCommand(ItemOrder++, "About IBMiCmd", About, new ShortcutKey(false, false, false, Keys.None));
            PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null);
            PluginBase.SetCommand(ItemOrder++, "Select Remote System", LoadConfigSelect);
            PluginBase.SetCommand(ItemOrder++, "Remote System Setup", RemoteSetup);
            PluginBase.SetCommand(ItemOrder++, "Library List", LiblDialog, new ShortcutKey(true, false, false, Keys.F7));
            if (ExperimentalFeatures)
            {
                PluginBase.SetCommand(ItemOrder++, "Remote Install Plugin Server", RemoteInstall);
            }
            PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null);
            PluginBase.SetCommand(ItemOrder++, "Command Entry", CommandDialog);
            PluginBase.SetCommand(ItemOrder++, "Error Listing", ErrorDialog);
            PluginBase.SetCommand(ItemOrder++, "Command Bindings", BindsDialog);
            PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null);
            PluginBase.SetCommand(ItemOrder++, "Member Listing", MemberListing);
            PluginBase.SetCommand(ItemOrder++, "Open Source Member", OpenMember, new ShortcutKey(true, false, true, Keys.A));
            //PluginBase.SetCommand(ItemOrder++, "Upload Source Member", UploadMember, new ShortcutKey(true, false, true, Keys.X));
            PluginBase.SetCommand(ItemOrder++, "Open Include/Copy", OpenInclude, new ShortcutKey(true, false, false, Keys.F12));
            PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null);
            PluginBase.SetCommand(ItemOrder++, "Format CL file", ManageCL, new ShortcutKey(true, false, false, Keys.F4));
            PluginBase.SetCommand(ItemOrder++, "RPG Line Conversion", LaunchConversion, new ShortcutKey(true, false, false, Keys.F5));
            PluginBase.SetCommand(ItemOrder++, "RPG File Conversion", LaunchFileConversion, new ShortcutKey(true, false, false, Keys.F6));
            PluginBase.SetCommand(ItemOrder++, "-SEPARATOR-", null);
            PluginBase.SetCommand(ItemOrder++, "Display File Editor", DisplayEdit);
            if (ExperimentalFeatures)
            {
                PluginBase.SetCommand(ItemOrder++, "Refresh Extname Definitions", BuildSourceContext);
            }
            if (ExperimentalFeatures)
            {
                PluginBase.SetCommand(ItemOrder++, "Extname Content Assist", AutoComplete, new ShortcutKey(false, true, false, Keys.Space));
            }
            if (ExperimentalFeatures)
            {
                PluginBase.SetCommand(ItemOrder++, "Prompt CL Command", PromptCommand, new ShortcutKey(true, false, false, Keys.F4));
            }
        }
Exemple #8
0
 internal static void ManageCL()
 {
     CLFile.CorrectLines(NppFunctions.GetCurrentFileName(), Convert.ToInt32(IBMi.GetConfig("clrcdlen")));
     NppFunctions.RefreshWindow(NppFunctions.GetCurrentFileName());
 }