Skip to content

Commit

Permalink
Merge pull request #1439 from HicServices/open-sql-file
Browse files Browse the repository at this point in the history
Add open button to ConsoleGuiSqlEditor
  • Loading branch information
jas88 authored Sep 29, 2022
2 parents 423ac94 + 1d9ff0d commit 4934c58
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added command line switch `--skip-patching` to prevent running patches and launch the application as normal (can help debugging patch issues) [#1392](https://github.com/HicServices/RDMP/issues/1392)

- Added 'open file' to Console SQL Editor for easier running of .sql files [#1438](https://github.com/HicServices/RDMP/issues/1438)

## [8.0.0] - 2022-09-27

Expand Down
31 changes: 30 additions & 1 deletion Tools/rdmp/CommandLine/Gui/ConsoleGuiSqlEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,17 @@ public ConsoleGuiSqlEditor(IBasicActivateItems activator,IViewSQLAndResultsColle
btnSave.Clicked += ()=>Save();
Add(btnSave);

var btnOpen = new Button("Open")
{
X = Pos.Right(btnSave) + 1,
};

btnOpen.Clicked += OpenFile;

Add(btnOpen);

var btnClose = new Button("Clos_e"){
X= Pos.Right(btnSave)+1,
X= Pos.Right(btnOpen) +1,
};


Expand All @@ -153,6 +162,26 @@ public ConsoleGuiSqlEditor(IBasicActivateItems activator,IViewSQLAndResultsColle
textView.Autocomplete.MaxWidth = 40;
}

private void OpenFile()
{
try
{
using var open = new OpenDialog("Open Sql File", "Open");
Application.Run(open, ConsoleMainWindow.ExceptionPopup);

var file = open.FilePath.ToString();
if (!open.Canceled && File.Exists(file))
{
var sql = File.ReadAllText(file);
textView.Text = sql;
}
}
catch (Exception ex)
{
ConsoleMainWindow.ExceptionPopup(ex);
}
}

private void TableView_CellActivated(TableView.CellActivatedEventArgs obj)
{
var val = obj.Table.Rows[obj.Row][obj.Col];
Expand Down

0 comments on commit 4934c58

Please sign in to comment.