public static void OpenExistingSource(RemoteSource Source) { string text = Source.GetName() + (Source.GetExtension() != "" ? '.' + 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; sourcePanel.ToolTipText = Source.GetLocalFile(); Source.Lock(); TheEditor.AddTool(sourcePanel, DockState.Document); } else { MessageBox.Show("There was an error opening the local file. '" + Source.GetLocalFile() + "' does not exist"); } }
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"); } }
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); } } }
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); } } }
public static void OpenSource(RemoteSource Source) { SourceEditor sourcePanel; string resultFile = ""; string text = ""; text = Path.GetFileName(Source.GetName() + "." + Source.GetExtension().ToLower()); Editor.TheEditor.SetStatus("Fetching file " + text + "..."); 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 != "") { Editor.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; Editor.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(); }
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(); }
private void compileToolStripMenuItem_DropDownOpening(object sender, EventArgs e) { compileOptionsToolStripMenuItem.DropDownItems.Clear(); List <ToolStripMenuItem> Compiles = new List <ToolStripMenuItem>(); if (LastEditing != null) { RemoteSource SourceInfo = (RemoteSource)LastEditing.Tag; string[] Items = IBMi.CurrentSystem.GetValue("TYPE_" + SourceInfo.GetExtension()).Split('|'); foreach (string Item in Items) { if (Item.Trim() == "") { continue; } Compiles.Add(new ToolStripMenuItem(Item, null, compileAnyHandle)); } } compileToolStripMenuItem1.Enabled = (Compiles.Count > 0); compileOptionsToolStripMenuItem.Enabled = (Compiles.Count > 0); compileOptionsToolStripMenuItem.DropDownItems.AddRange(Compiles.ToArray()); }
private void compileRightclick_Opening(object sender, CancelEventArgs e) { compileOtherToolStripMenuItem.DropDownItems.Clear(); List <ToolStripMenuItem> Compiles = new List <ToolStripMenuItem>(); if (currentRightClick != null) { RemoteSource MemberInfo = currentRightClick; string[] Items = IBMi.CurrentSystem.GetValue("TYPE_" + MemberInfo.GetExtension()).Split('|'); foreach (string Item in Items) { if (Item.Trim() == "") { continue; } Compiles.Add(new ToolStripMenuItem(Item, null, compileAnyHandle)); } } compileToolStripMenuItem.Enabled = (Compiles.Count > 0); compileOtherToolStripMenuItem.Enabled = (Compiles.Count > 0); compileOtherToolStripMenuItem.DropDownItems.AddRange(Compiles.ToArray()); }
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."); } } }