Common/SQLEditor: add configurable title for auto/manual palceholders

This commit is contained in:
Jonathan Jenne
2022-05-12 11:04:21 +02:00
parent 7b41acf1d7
commit 7c3c2ce9ed
2 changed files with 35 additions and 20 deletions

View File

@@ -23,10 +23,11 @@ Public Class frmSQLEditor
Public Property PlaceholdersManual As Dictionary(Of String, String)
Public Property PlaceholdersManualPrefix As String
Public Property PlaceholdersManualTitle As String = "Manuelles Attribut"
Public Property PlaceholdersAutomatic As Dictionary(Of String, String)
Public Property PlaceholdersAutomaticPrefix As String
Public Property PlaceholdersAutomaticTitle As String = "Automatisches Attribut"
Public Property PlaceholdersWindream As List(Of String)
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
@@ -72,7 +73,10 @@ Public Class frmSQLEditor
End If
GalleryConnection.Gallery.Groups.Add(oConnectionGroup)
GalleryConnection.Gallery.SetItemCheck(oSelectedItem, True)
If oSelectedItem IsNot Nothing Then
GalleryConnection.Gallery.SetItemCheck(oSelectedItem, True)
End If
Dim oPlaceholderGroups = LoadPlaceholders()
GalleryPlaceholders.Gallery.Groups.AddRange(oPlaceholderGroups.ToArray)
@@ -104,12 +108,12 @@ Public Class frmSQLEditor
Placeholders.GetUserPlaceholders()
}
Dim oAutomaticAttributes = Placeholders.GetAutomaticPlaceholders(PlaceholdersAutomatic, PlaceholdersAutomaticPrefix)
Dim oAutomaticAttributes = Placeholders.GetAutomaticPlaceholders(PlaceholdersAutomatic, PlaceholdersAutomaticPrefix, PlaceholdersAutomaticTitle)
If oAutomaticAttributes IsNot Nothing Then
oPlaceholders.Add(oAutomaticAttributes)
End If
Dim oManualPlaceholders = Placeholders.GetManualPlaceholders(PlaceholdersManual, PlaceholdersManualPrefix)
Dim oManualPlaceholders = Placeholders.GetManualPlaceholders(PlaceholdersManual, PlaceholdersManualPrefix, PlaceholdersManualTitle)
If oManualPlaceholders IsNot Nothing Then
oPlaceholders.Add(oManualPlaceholders)
End If
@@ -163,7 +167,11 @@ Public Class frmSQLEditor
Private Sub ClearPlaceholders()
GridPlaceholders.DataSource = New List(Of SQLEditor.Placeholder)
Dim oPlaceholders As List(Of SQLEditor.Placeholder) = GridPlaceholders.DataSource
oPlaceholders.ForEach(Sub(placeholder) placeholder.Value = "")
GridPlaceholders.DataSource = oPlaceholders
End Sub
Private Function GetGalleryItem(pConnection As Connection) As GalleryItem
@@ -179,6 +187,19 @@ Public Class frmSQLEditor
Private Property LastPatterns As New List(Of Pattern)
Private Sub RichEditControl1_ContentChanged(sender As Object, e As EventArgs) Handles txtSQLCommand.ContentChanged
UpdatePlaceholders()
End Sub
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExecuteSQL.ItemClick
ExecuteSQL()
End Sub
Private Class Connection
Public Property Id As Integer
Public Property Name As String
End Class
Private Sub UpdatePlaceholders()
Dim oSqlText = txtSQLCommand.Document.Text
Dim oPatterns = Patterns.GetAllPatterns(oSqlText)
@@ -196,15 +217,6 @@ Public Class frmSQLEditor
LastPatterns = oPatterns
End Sub
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnExecuteSQL.ItemClick
ExecuteSQL()
End Sub
Private Class Connection
Public Property Id As Integer
Public Property Name As String
End Class
Private Sub ExecuteSQL()
Try
ViewPlaceholders.FocusInvalidRow()
@@ -234,6 +246,9 @@ Public Class frmSQLEditor
oDatatable = Database.GetDatatable(oSql)
End If
If ClearPlaceholdersAfterSuccessfulExecute Then
ClearPlaceholders()
End If
Dim oForm As New frmSQLResult(oDatatable)
oForm.Show()