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(); }
public static void OpenLocalSource(string FilePath, Language Language, string Title = null, bool ReadOnly = false) { string text = Path.GetFileName(FilePath); if (File.Exists(FilePath)) { SourceEditor sourcePanel = new SourceEditor(FilePath, Language, 0, ReadOnly); if (Title != null) { sourcePanel.Text = Title; } else { sourcePanel.Text = text; } sourcePanel.ToolTipText = FilePath; TheEditor.AddTool(sourcePanel, DockState.Document); } else { MessageBox.Show("There was an error opening the local file. '" + text + "' does not exist"); } }
: super("Semantic Highlight") { this.editor = editor; this.text = text; this.compilationUnit = compilationUnit; this.typeSystem = typeSystem; this.annotatedTypeSystem = annotatedTypeSystem; }
public void ChangeSelection(SelectionPosition position) { SourceEditor.Select( position == SelectionPosition.BodyStart ? 0 : position == SelectionPosition.BodyEnd ? SourceEditor.TextLength : 0, 0); }
private void DockingPanel_ActiveContentChanged(object sender, EventArgs e) { SourceEditor PreviousEditor = GetTabEditor(dockingPanel.ActiveContent as DockContent); if (PreviousEditor != null) { LastEditing = PreviousEditor; LastEditing.DoAction(EditorAction.TasksUpdate); } }
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 EditSource(object sender) { if (SelectedSource != null) { SourceEditor se = new SourceEditor(SelectedSource); se.ShowDialog(); SourcesView.Refresh(); } }
/// <summary> /// If the specified markers exist in the editor text, /// delete the first instance of each and position the /// selection at the markers. /// </summary> public bool SelectAndDelete(string startMarker, string endMarker) { string html = SourceEditor.Text; int startIndex, startLen; FindMarker(html, startMarker, out startIndex, out startLen); int endIndex, endLen; FindMarker(html, endMarker, out endIndex, out endLen); if (startIndex > endIndex) { Trace.Fail("Selection startIndex is before endIndex--this should never happen"); int temp = startIndex; startIndex = endIndex; endIndex = temp; temp = startLen; startLen = endLen; endLen = temp; } if (endIndex >= 0) { html = html.Substring(0, endIndex) + html.Substring(endIndex + endLen); } if (startIndex >= 0) { html = html.Substring(0, startIndex) + html.Substring(startIndex + startLen); if (endIndex >= 0) { endIndex -= startLen; } } SourceEditor.Text = html; if (startIndex >= 0) { SourceEditor.Select(startIndex, endIndex - startIndex); SourceEditor.ScrollToCaret(); return(true); } return(false); }
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"); } }
private void btnLoad_Click(object sender, EventArgs e) { try { openFileSource.Filter = "Basic Files (*.bas)|*.bas|Class Files (*.cls)|*.cls|Form Files (*.frm)|*.frm|All files (*.*)|*.*"; DialogResult result = openFileSource.ShowDialog(); if (result == DialogResult.OK) { string source = File.ReadAllText(openFileSource.FileName, Encoding.Default); SourceEditor.Text = ConverterEngine.FilterSource(source); } SourceEditor.Focus(); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); MessageBox.Show("It's not possible to open the dialog. \n\nDetails: " + ex.Message, "VB Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddMemberEditor(Member MemberInfo, ILELanguage Language = ILELanguage.None) { string pageName = MemberInfo.GetLibrary() + "/" + MemberInfo.GetObject() + "(" + MemberInfo.GetMember() + ")"; OpenTab currentTab = EditorContains(pageName); if (File.Exists(MemberInfo.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 = MemberInfo.GetLibrary() + "/" + MemberInfo.GetObject() + "(" + MemberInfo.GetMember() + ")"; SourceEditor srcEdit = new SourceEditor(MemberInfo.GetLocalFile(), Language, MemberInfo.GetRecordLength()); srcEdit.SetReadOnly(!MemberInfo.IsEditable()); srcEdit.BringToFront(); srcEdit.Dock = DockStyle.Fill; srcEdit.Tag = MemberInfo; tabPage.Tag = MemberInfo; 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. '" + MemberInfo.GetLocalFile() + "' does not exist"); } }
public void AddSource(object sender) { SourceEditor se = new SourceEditor(); try { se.ShowDialog(); var svm = se.GetSourceViewModel(); if (svm != null) { Sources.Add(svm); SVMLookup.Add(svm.Data, svm); } } catch (Exception ex) { MessageBoxFactory.ShowError(ex); } }
private void btnConvert_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(SourceEditor.Text)) { MessageBox.Show("There's no source code to convert !", "VB Converter", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); SourceEditor.Focus(); } else { this.Cursor = Cursors.WaitCursor; string source = SourceEditor.Text; ConverterEngine engine = new ConverterEngine(LanguageVersion.VB6, source); if (cboLanguage.Text == "VB .NET") { engine.ResultType = DestinationLanguage.VisualBasic; } bool success = engine.Convert(); string result = success ? engine.Result : engine.GetErrors(); DestinationEditor.Text = result; DestinationEditor.Focus(); if (engine.Errors.Count > 0) { MessageBox.Show("It's not possible to convert the the source code due to compile errors!\n\nCheck the sintax.", "VB Converter", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); MessageBox.Show("It's not possible to convert the source code. \n\nDetails: " + ex.Message, "VB Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void AddFileEditor(string FilePath, Language Language) { string pageName = Path.GetFileName(FilePath); OpenTab currentTab = EditorContains(pageName); if (File.Exists(FilePath)) { 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(FilePath, Language); srcEdit.BringToFront(); srcEdit.Dock = DockStyle.Fill; srcEdit.Tag = null; tabPage.Tag = null; tabPage.Controls.Add(srcEdit); editortabsleft.TabPages.Add(tabPage); SwitchToTab(OpenTab.TAB_SIDE.Left, editortabsleft.TabPages.Count - 1); } }
private async void InitializeAsync() { // Make sure everything is set up before doing anything with the browser await this.Browser.EnsureCoreWebView2Async(null); await this.TextBrowser.EnsureCoreWebView2Async(null); this.CypherEditor.SyntaxHighlighting = SourceEditor.LoadHighlightDefinition("SocratexGraphExplorer.Resources.Cypher-mode.xshd"); // Set up a function to call when the user clicks on something in the graph browser. Browser.WebMessageReceived += async(object sender, CoreWebView2WebMessageReceivedEventArgs args) => { string message = args.WebMessageAsJson; // The payload will be empty if the user clicked in the empty space // it will be {edge: id} if an edge is selected // it will be {node: id) if a node is selected //var item = System.Text.Json.JsonSerializer.Deserialize<ClickedItem>(message); var e = Newtonsoft.Json.Linq.JObject.Parse(message); if (e.ContainsKey("nodeId")) { var id = e["nodeId"].ToObject <long>(); var cypher = "MATCH (c) where id(c) = {id} return c limit 1"; this.ViewModel.SelectedNode = id; var nodeResult = await this.model.ExecuteCypherAsync(cypher, new Dictionary <string, object>() { { "id", id } }); this.ViewModel.UpdatePropertyListView(nodeResult); } else if (e.ContainsKey("edgeId")) { var id = e["edgeId"].ToObject <long>(); var cypher = "MATCH (c) -[r]- (d) where id(r) = {id} return r limit 1"; this.ViewModel.SelectedEdge = id; var edgeResult = await this.model.ExecuteCypherAsync(cypher, new Dictionary <string, object>() { { "id", id } }); this.ViewModel.UpdatePropertyListView(edgeResult); } else { // blank space selected } }; this.Browser.SizeChanged += async(object sender, SizeChangedEventArgs e) => { var browser = sender as WebView2; //await browser.EnsureCoreWebView2Async(); await this.ViewModel.SetGraphSizeAsync(browser); }; this.Browser.NavigationCompleted += Browser_NavigationCompleted; // The debugger does not work in Edge if the source does not come from a file. // Load the script into a temporary file, and use that file in the URI that // the debugger loads. this.Browser.Source = this.model.ScriptUri; this.TextBrowser.NavigateToString(@"<html> <head> <style> html, body, .container { height: 100%; } .container { font-size: 24; color: lightgray; display: flex; align-items: center; justify-content: center; } </style> </head> <body class='container'> No information </body> </html>"); this.ViewModel.GraphModeSelected = true; }
PartListener(SourceEditor editor) { this.editor = editor; }
TextInputListener(SourceEditor editor) { this.editor = editor; var sourceViewer = editor.getSourceViewer(); sourceViewer.addTextInputListener(this); var documentProvider = editor.getDocumentProvider(); if (documentProvider != null) { var document = documentProvider.getDocument(editor.getEditorInput()); if (document != null) { editor.Highlighter = new Highlighter(sourceViewer, document, editor.getFile(), editor.getSharedColors()); } } }
AnnotationHover(SourceEditor editor) { this.editor = editor; }
ReconcilingStrategy(SourceEditor editor) { this.editor = editor; }
HighlightJob(SourceEditor editor, char[] text, CompilationUnitNode compilationUnit, Library typeSystem, Library annotatedTypeSystem) : super("Semantic Highlight") {
void dispose() { if (editor.Highlighter != null) { editor.Highlighter.dispose(); editor.Highlighter = null; } if (editor != null) { editor.getSourceViewer().removeTextInputListener(this); editor = null; } }
SourceViewerConfiguration(SourceEditor editor) { this.editor = editor; }
HighlightJob(SourceEditor editor, char[] text, CompilationUnitNode compilationUnit, Library typeSystem, Library annotatedTypeSystem) : super("Semantic Highlight")