Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add open button to ConsoleGuiSqlEditor #1439

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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