示例#1
0
        public SourceCompareSelect()
        {
            InitializeComponent();

            if (Editor.LastEditing != null)
            {
                RemoteSource src = Editor.LastEditing.Tag as RemoteSource;

                if (src != null)
                {
                    switch (src.GetFS())
                    {
                    case FileSystem.QSYS:
                        newSourceBox.SetSource(src.GetLibrary(), src.GetObject(), src.GetName());
                        oldSourceBox.SetSource("", src.GetObject(), src.GetName());
                        break;

                    case FileSystem.IFS:
                        newSourceBox.SetSource(src.GetRemoteFile());
                        newSourceBox.SetTab(src.GetFS());
                        break;
                    }
                }
            }
        }
示例#2
0
        public static void OpenSource(RemoteSource Source)
        {
            SourceEditor sourcePanel;
            string       resultFile = "";
            string       text       = Source.GetName() + (Source.GetExtension() != "" ? '.' + Source.GetExtension().ToLower() : "");

            Editor.TheEditor.SetStatus("Fetching file " + text + "...");

            new Thread((ThreadStart) delegate
            {
                switch (Source.GetFS())
                {
                case FileSystem.QSYS:
                    resultFile = IBMiUtils.DownloadSourceMember(Source.GetLibrary(), Source.GetObject(), Source.GetName(), Source.GetExtension());
                    break;

                case FileSystem.IFS:
                    resultFile = IBMiUtils.DownloadFile(Source.GetRemoteFile());
                    break;
                }

                if (resultFile != "")
                {
                    TheEditor.SetStatus("Opening file " + text + "...");

                    Source._Local = resultFile;
                    Source.Lock();

                    sourcePanel = new SourceEditor(Source.GetLocalFile(), GetBoundLangType(Source.GetExtension()), Source.GetRecordLength(), !Source.IsEditable());

                    sourcePanel.Tag  = Source;
                    sourcePanel.Text = text;

                    switch (Source.GetFS())
                    {
                    case FileSystem.QSYS:
                        sourcePanel.ToolTipText = Source.GetLibrary() + "/" + Source.GetObject() + ":" + Source.GetName() + "." + Source.GetExtension().ToLower();
                        break;

                    case FileSystem.IFS:
                        sourcePanel.ToolTipText = Source.GetRemoteFile();
                        break;
                    }

                    TheEditor.Invoke((MethodInvoker) delegate
                    {
                        TheEditor.AddTool(sourcePanel, DockState.Document, false);
                    });
                }
                else
                {
                    switch (Source.GetFS())
                    {
                    case FileSystem.QSYS:
                        MessageBox.Show("Unable to download member " + Source.GetLibrary() + "/" + Source.GetObject() + "." + Source.GetName() + ". Please check it exists and that you have access to the remote system.");
                        break;
                    }
                }
            }).Start();
        }
示例#3
0
        public SaveAs(RemoteSource MemberInfo = null)
        {
            InitializeComponent();

            if (MemberInfo != null)
            {
                switch (MemberInfo.GetFS())
                {
                case FileSystem.IFS:
                    sourceSelectBox.SetSource(MemberInfo.GetRemoteFile());
                    sourceSelectBox.SetSource("", "", MemberInfo.GetName());
                    break;

                case FileSystem.QSYS:
                    sourceSelectBox.SetSource("", MemberInfo.GetObject(), MemberInfo.GetName());
                    break;
                }
            }
        }
示例#4
0
        public void AddSourceEditor(RemoteSource SourceInfo, Language Language = Language.None)
        {
            string pageName = "";

            switch (SourceInfo.GetFS())
            {
            case FileSystem.QSYS:
                pageName = SourceInfo.GetLibrary() + "/" + SourceInfo.GetObject() + "(" + SourceInfo.GetName() + ")";
                break;

            case FileSystem.IFS:
                pageName = SourceInfo.GetName() + "." + SourceInfo.GetExtension();
                break;
            }

            OpenTab currentTab = EditorContains(pageName);

            if (File.Exists(SourceInfo.GetLocalFile()))
            {
                //Close tab if it already exists.
                if (currentTab != null)
                {
                    switch (currentTab.getSide())
                    {
                    case OpenTab.TAB_SIDE.Left:
                        editortabsleft.TabPages.RemoveAt(currentTab.getIndex());
                        break;

                    case OpenTab.TAB_SIDE.Right:
                        editortabsright.TabPages.RemoveAt(currentTab.getIndex());
                        break;
                    }
                }

                TabPage tabPage = new TabPage(pageName);
                tabPage.ImageIndex  = 0;
                tabPage.ToolTipText = pageName;
                SourceEditor srcEdit = new SourceEditor(SourceInfo.GetLocalFile(), Language, SourceInfo.GetRecordLength());
                srcEdit.SetReadOnly(!SourceInfo.IsEditable());
                srcEdit.BringToFront();
                srcEdit.Dock = DockStyle.Fill;
                srcEdit.Tag  = SourceInfo;

                tabPage.Tag = SourceInfo;
                tabPage.Controls.Add(srcEdit);
                editortabsleft.TabPages.Add(tabPage);

                SwitchToTab(OpenTab.TAB_SIDE.Left, editortabsleft.TabPages.Count - 1);
            }
            else
            {
                MessageBox.Show("There was an error opening the local member. '" + SourceInfo.GetLocalFile() + "' does not exist");
            }
        }
示例#5
0
 private void cLFormattingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (LastEditing != null)
     {
         RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
         Language     Language   = GetBoundLangType(SourceInfo.GetExtension());
         if (Language == Language.CL)
         {
             SetStatus("Formatting CL in " + SourceInfo.GetName());
             LastEditing.DoAction(EditorAction.Format_CL);
         }
     }
 }
示例#6
0
 private void rPGConversionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (LastEditing != null)
     {
         RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag;
         Language     Language   = GetBoundLangType(SourceInfo.GetExtension());
         if (Language == Language.RPG)
         {
             SetStatus("Converting RPG in " + SourceInfo.GetName());
             LastEditing.DoAction(EditorAction.Convert_Selected_RPG);
         }
     }
 }
示例#7
0
        private void compareMembersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string lib = "", spf = "", mbr = "";

            if (this.LastEditing.Tag != null)
            {
                RemoteSource MemberInfo = (RemoteSource)this.LastEditing.Tag;
                lib = MemberInfo.GetLibrary();
                spf = MemberInfo.GetObject();
                mbr = MemberInfo.GetName();
            }
            new MemberCompareSelect(lib, spf, mbr).ShowDialog();
        }
示例#8
0
        public static void OpenExistingSource(RemoteSource Source)
        {
            string text = Path.GetFileName(Source.GetName() + "." + Source.GetExtension().ToLower());

            if (File.Exists(Source.GetLocalFile()))
            {
                SourceEditor sourcePanel = new SourceEditor(Source.GetLocalFile(), GetBoundLangType(Source.GetExtension()), Source.GetRecordLength(), !Source.IsEditable());

                sourcePanel.Tag  = Source;
                sourcePanel.Text = text;

                Source.Lock();
                TheEditor.AddTool(sourcePanel, DockState.Document);
            }
            else
            {
                MessageBox.Show("There was an error opening the local file. '" + Source.GetLocalFile() + "' does not exist");
            }
        }
示例#9
0
        public MemberCompareDisplay(RemoteSource MemberA, RemoteSource MemberB)
        {
            InitializeComponent();

            this.Text = MemberA.GetLibrary() + "/" + MemberA.GetObject() + "." + MemberA.GetName() + " -> " + MemberB.GetLibrary() + "/" + MemberB.GetObject() + "." + MemberB.GetName();

            var    dmp   = new diff_match_patch();
            var    res   = dmp.diff_main(File.ReadAllText(MemberA.GetLocalFile()), File.ReadAllText(MemberB.GetLocalFile()), false);
            string html  = dmp.diff_prettyHtml(res);
            string style = @"<head>
    <meta charset=" + '"' + "utf-8" + '"' + @" />
      <style>
          body {
                font-family: " + '"' + "Lucida Console" + '"' + @", Monaco, monospace
            }
    </style>
</head> ";

            webBrowser1.DocumentText = style + html;
        }
示例#10
0
        public void Save()
        {
            RemoteSource SourceInfo   = (RemoteSource)this.Tag;
            bool         UploadResult = true;

            if (SourceInfo != null)
            {
                if (SourceInfo.IsEditable())
                {
                    if (!SourceInfo._IsBeingSaved)
                    {
                        SourceInfo._IsBeingSaved = true;

                        Editor.TheEditor.SetStatus("Saving " + SourceInfo.GetName() + "..");
                        Thread gothread = new Thread((ThreadStart) delegate
                        {
                            MemberCache.EditsAdd(SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                            this.Invoke((MethodInvoker) delegate
                            {
                                File.WriteAllText(SourceInfo.GetLocalFile(), this.GetText(), textEditor.Encoding);
                            });

                            switch (SourceInfo.GetFS())
                            {
                            case FileSystem.QSYS:
                                UploadResult = IBMiUtils.UploadMember(SourceInfo.GetLocalFile(), SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                                break;

                            case FileSystem.IFS:
                                UploadResult = IBMiUtils.UploadFile(SourceInfo.GetLocalFile(), SourceInfo.GetRemoteFile());
                                break;
                            }
                            if (UploadResult == false)
                            {
                            }
                            else
                            {
                                this.Invoke((MethodInvoker) delegate
                                {
                                    if (GetParent().Text.EndsWith("*"))
                                    {
                                        GetParent().Text = GetParent().Text.Substring(0, GetParent().Text.Length - 1);
                                    }
                                });
                            }

                            this.Invoke((MethodInvoker) delegate
                            {
                                Editor.TheEditor.SetStatus(SourceInfo.GetName() + " " + (UploadResult ? "" : "not ") + "saved.");
                            });

                            SourceInfo._IsBeingSaved = false;
                        });

                        gothread.Start();
                    }
                }
                else
                {
                    MessageBox.Show("This file is readonly.");
                }
            }
            else
            {
                File.WriteAllText(this.LocalPath, this.GetText(), textEditor.Encoding);
                if (GetParent().Text.EndsWith("*"))
                {
                    GetParent().Text = GetParent().Text.Substring(0, GetParent().Text.Length - 1);
                }
                Editor.TheEditor.SetStatus("File saved locally.");
            }
        }
示例#11
0
        private void Save()
        {
            RemoteSource SourceInfo   = (RemoteSource)this.Tag;
            bool         UploadResult = true;

            if (SourceInfo != null)
            {
                if (SourceInfo.IsEditable())
                {
                    if (!CurrentSaving)
                    {
                        CurrentSaving = true;

                        Editor.TheEditor.SetStatus("Saving " + SourceInfo.GetName() + "..");
                        Thread gothread = new Thread((ThreadStart) delegate
                        {
                            MemberCache.EditsAdd(SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                            this.Invoke((MethodInvoker) delegate
                            {
                                File.WriteAllText(SourceInfo.GetLocalFile(), this.GetText(), textEditor.Encoding);
                            });

                            switch (SourceInfo.GetFS())
                            {
                            case FileSystem.QSYS:
                                UploadResult = IBMiUtils.UploadMember(SourceInfo.GetLocalFile(), SourceInfo.GetLibrary(), SourceInfo.GetObject(), SourceInfo.GetName());
                                break;

                            case FileSystem.IFS:
                                UploadResult = IBMiUtils.UploadFile(SourceInfo.GetLocalFile(), SourceInfo.GetRemoteFile());
                                break;
                            }
                            if (UploadResult == false)
                            {
                            }
                            else
                            {
                                this.Invoke((MethodInvoker) delegate
                                {
                                    if (this.Text.EndsWith("*"))
                                    {
                                        this.Text = this.Text.Substring(0, this.Text.Length - 1);
                                    }
                                });
                                DoAction(EditorAction.ParseCode);
                                DoAction(EditorAction.OutlineUpdate);
                            }

                            this.Invoke((MethodInvoker) delegate
                            {
                                Editor.TheEditor.SetStatus(SourceInfo.GetName() + " " + (UploadResult ? "" : "not ") + "saved.");
                            });

                            CurrentSaving = false;
                        });

                        gothread.Start();
                    }
                    else
                    {
                        Editor.TheEditor.SetStatus("Please wait until previous save has finished.");
                    }
                }
                else
                {
                    MessageBox.Show("This file is readonly.");
                }
            }
            else
            {
                File.WriteAllText(this.LocalPath, this.GetText(), textEditor.Encoding);
                if (this.Text.EndsWith("*"))
                {
                    this.Text = this.Text.Substring(0, this.Text.Length - 1);
                }
                Editor.TheEditor.SetStatus("File saved locally.");
            }
        }
示例#12
0
        private void SaveAs()
        {
            if (!this.Text.EndsWith("*"))
            {
                if (!CurrentSaving)
                {
                    RemoteSource MemberInfo = this.Tag as RemoteSource;
                    if (MemberInfo != null)
                    {
                        SaveAs SaveAsWindow = new SaveAs(MemberInfo);
                        SaveAsWindow.ShowDialog();
                        if (SaveAsWindow.Success)
                        {
                            Thread gothread = null;
                            CurrentSaving = true;
                            Editor.TheEditor.SetStatus("Saving " + MemberInfo.GetName() + "..");
                            switch (SaveAsWindow.SourceInfo().GetFS())
                            {
                            case FileSystem.QSYS:
                                gothread = new Thread((ThreadStart) delegate
                                {
                                    bool UploadResult = IBMiUtils.UploadMember(MemberInfo.GetLocalFile(), SaveAsWindow.SourceInfo().GetLibrary(), SaveAsWindow.SourceInfo().GetSPF(), SaveAsWindow.SourceInfo().GetMember());
                                    if (UploadResult == false)
                                    {
                                        MessageBox.Show("Failed to upload to " + MemberInfo.GetName() + ".");
                                    }

                                    this.Invoke((MethodInvoker) delegate
                                    {
                                        Editor.TheEditor.SetStatus(MemberInfo.GetName() + " " + (UploadResult ? "" : "not ") + "saved.");
                                    });

                                    CurrentSaving = false;
                                });
                                break;

                            case FileSystem.IFS:
                                gothread = new Thread((ThreadStart) delegate
                                {
                                    bool UploadResult = IBMiUtils.UploadFile(MemberInfo.GetLocalFile(), SaveAsWindow.SourceInfo().GetIFSPath());
                                    if (UploadResult == false)
                                    {
                                        MessageBox.Show("Failed to upload to " + MemberInfo.GetName() + "." + MemberInfo.GetExtension() + ".");
                                    }

                                    this.Invoke((MethodInvoker) delegate
                                    {
                                        Editor.TheEditor.SetStatus(MemberInfo.GetName() + "." + MemberInfo.GetExtension() + " " + (UploadResult ? "" : "not ") + "saved.");
                                    });

                                    CurrentSaving = false;
                                });
                                break;
                            }

                            if (gothread != null)
                            {
                                gothread.Start();
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("You must save the source before you can Save-As.");
                }
            }
        }
示例#13
0
        public static void OpenSource(RemoteSource source)
        {
            string resultFile = "";
            Thread gothread   = new Thread((ThreadStart) delegate {
                switch (source.GetFS())
                {
                case FileSystem.QSYS:
                    resultFile = IBMiUtils.DownloadMember(source.GetLibrary(), source.GetObject(), source.GetName(), source.GetExtension());
                    break;

                case FileSystem.IFS:
                    resultFile = IBMiUtils.DownloadFile(source.GetRemoteFile());
                    break;
                }

                if (resultFile != "")
                {
                    source._Local = resultFile;
                    //LOCK HERE
                    source.Lock();
                    TheEditor.Invoke((MethodInvoker) delegate
                    {
                        TheEditor.AddSourceEditor(source, GetBoundLangType(source.GetExtension()));
                    });
                }
                else
                {
                    switch (source.GetFS())
                    {
                    case FileSystem.QSYS:
                        MessageBox.Show("Unable to download member " + source.GetLibrary() + "/" + source.GetObject() + "." + source.GetName() + ". Please check it exists and that you have access to the remote system.");
                        break;
                    }
                }
            });

            gothread.Start();
        }