diff --git a/GUIs.Common/frmSQLEditor.Designer.vb b/GUIs.Common/frmSQLEditor.Designer.vb index 3fe98747..504bee8a 100644 --- a/GUIs.Common/frmSQLEditor.Designer.vb +++ b/GUIs.Common/frmSQLEditor.Designer.vb @@ -23,7 +23,6 @@ Partial Class frmSQLEditor Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() - Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmSQLEditor)) Me.RibbonControl1 = New DevExpress.XtraBars.Ribbon.RibbonControl() Me.GalleryPlaceholders = New DevExpress.XtraBars.RibbonGalleryBarItem() Me.SvgImageCollection1 = New DevExpress.Utils.SvgImageCollection(Me.components) @@ -39,7 +38,6 @@ Partial Class frmSQLEditor Me.BarButtonItem3 = New DevExpress.XtraBars.BarButtonItem() Me.BarButtonItem4 = New DevExpress.XtraBars.BarButtonItem() Me.BarButtonItem5 = New DevExpress.XtraBars.BarButtonItem() - Me.BarButtonItem6 = New DevExpress.XtraBars.BarButtonItem() Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage() Me.RibbonPageGroup3 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() @@ -67,14 +65,15 @@ Partial Class frmSQLEditor ' Me.RibbonControl1.ColorScheme = DevExpress.XtraBars.Ribbon.RibbonControlColorScheme.Green Me.RibbonControl1.ExpandCollapseItem.Id = 0 - Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.GalleryPlaceholders, Me.btnEditConnections, Me.btnSave, Me.btnExecuteSQL, Me.GalleryConnection, Me.chkClearPlaceholders, Me.btnClearPlaceholders, Me.chkShowPlaceholders, Me.BarButtonItem1, Me.BarButtonItem2, Me.BarButtonItem3, Me.BarButtonItem4, Me.BarButtonItem5, Me.BarButtonItem6}) + Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.GalleryPlaceholders, Me.btnEditConnections, Me.btnSave, Me.btnExecuteSQL, Me.GalleryConnection, Me.chkClearPlaceholders, Me.btnClearPlaceholders, Me.chkShowPlaceholders, Me.BarButtonItem1, Me.BarButtonItem2, Me.BarButtonItem3, Me.BarButtonItem4, Me.BarButtonItem5}) Me.RibbonControl1.Location = New System.Drawing.Point(0, 0) Me.RibbonControl1.MaxItemId = 20 Me.RibbonControl1.Name = "RibbonControl1" Me.RibbonControl1.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1}) Me.RibbonControl1.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.[False] + Me.RibbonControl1.ShowPageHeadersMode = DevExpress.XtraBars.Ribbon.ShowPageHeadersMode.Hide Me.RibbonControl1.ShowToolbarCustomizeItem = False - Me.RibbonControl1.Size = New System.Drawing.Size(1056, 158) + Me.RibbonControl1.Size = New System.Drawing.Size(1056, 132) Me.RibbonControl1.StatusBar = Me.RibbonStatusBar1 Me.RibbonControl1.Toolbar.ShowCustomizeItem = False ' @@ -106,6 +105,7 @@ Partial Class frmSQLEditor Me.btnSave.Id = 3 Me.btnSave.ImageOptions.SvgImage = Global.DigitalData.GUIs.Common.My.Resources.Resources.save2 Me.btnSave.Name = "btnSave" + Me.btnSave.RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.Large ' 'btnExecuteSQL ' @@ -113,6 +113,7 @@ Partial Class frmSQLEditor Me.btnExecuteSQL.Id = 4 Me.btnExecuteSQL.ImageOptions.SvgImage = Global.DigitalData.GUIs.Common.My.Resources.Resources.updatedataextract Me.btnExecuteSQL.Name = "btnExecuteSQL" + Me.btnExecuteSQL.RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.Large ' 'GalleryConnection ' @@ -183,13 +184,6 @@ Partial Class frmSQLEditor Me.BarButtonItem5.ImageOptions.SvgImage = Global.DigitalData.GUIs.Common.My.Resources.Resources.actions_database Me.BarButtonItem5.Name = "BarButtonItem5" ' - 'BarButtonItem6 - ' - Me.BarButtonItem6.Caption = "Abbrechen" - Me.BarButtonItem6.Id = 19 - Me.BarButtonItem6.ImageOptions.SvgImage = CType(resources.GetObject("BarButtonItem6.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage) - Me.BarButtonItem6.Name = "BarButtonItem6" - ' 'RibbonPage1 ' Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup3, Me.RibbonPageGroup1}) @@ -198,11 +192,11 @@ Partial Class frmSQLEditor ' 'RibbonPageGroup3 ' - Me.RibbonPageGroup3.ItemLinks.Add(Me.BarButtonItem6) Me.RibbonPageGroup3.ItemLinks.Add(Me.btnSave) Me.RibbonPageGroup3.ItemLinks.Add(Me.btnExecuteSQL) Me.RibbonPageGroup3.ItemLinks.Add(Me.GalleryConnection) Me.RibbonPageGroup3.Name = "RibbonPageGroup3" + Me.RibbonPageGroup3.State = DevExpress.XtraBars.Ribbon.RibbonPageGroupState.Expanded Me.RibbonPageGroup3.Text = "Start" ' 'RibbonPageGroup1 @@ -233,14 +227,14 @@ Partial Class frmSQLEditor Me.txtSQLCommand.MenuManager = Me.RibbonControl1 Me.txtSQLCommand.Name = "txtSQLCommand" Me.txtSQLCommand.Options.CopyPaste.InsertOptions = DevExpress.XtraRichEdit.API.Native.InsertOptions.KeepTextOnly - Me.txtSQLCommand.Size = New System.Drawing.Size(802, 508) + Me.txtSQLCommand.Size = New System.Drawing.Size(802, 534) Me.txtSQLCommand.TabIndex = 2 ' 'SplitContainerControl1 ' Me.SplitContainerControl1.CollapsePanel = DevExpress.XtraEditors.SplitCollapsePanel.Panel2 Me.SplitContainerControl1.Dock = System.Windows.Forms.DockStyle.Fill - Me.SplitContainerControl1.Location = New System.Drawing.Point(0, 158) + Me.SplitContainerControl1.Location = New System.Drawing.Point(0, 132) Me.SplitContainerControl1.Name = "SplitContainerControl1" ' 'SplitContainerControl1.Panel1 @@ -252,7 +246,7 @@ Partial Class frmSQLEditor ' Me.SplitContainerControl1.Panel2.Controls.Add(Me.GridPlaceholders) Me.SplitContainerControl1.Panel2.Text = "Panel2" - Me.SplitContainerControl1.Size = New System.Drawing.Size(1056, 508) + Me.SplitContainerControl1.Size = New System.Drawing.Size(1056, 534) Me.SplitContainerControl1.SplitterPosition = 802 Me.SplitContainerControl1.TabIndex = 4 ' @@ -263,7 +257,7 @@ Partial Class frmSQLEditor Me.GridPlaceholders.MainView = Me.ViewPlaceholders Me.GridPlaceholders.MenuManager = Me.RibbonControl1 Me.GridPlaceholders.Name = "GridPlaceholders" - Me.GridPlaceholders.Size = New System.Drawing.Size(244, 508) + Me.GridPlaceholders.Size = New System.Drawing.Size(244, 534) Me.GridPlaceholders.TabIndex = 0 Me.GridPlaceholders.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.ViewPlaceholders}) ' @@ -272,6 +266,8 @@ Partial Class frmSQLEditor Me.ViewPlaceholders.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.colPattern, Me.colValue}) Me.ViewPlaceholders.GridControl = Me.GridPlaceholders Me.ViewPlaceholders.Name = "ViewPlaceholders" + Me.ViewPlaceholders.OptionsView.ShowGroupPanel = False + Me.ViewPlaceholders.OptionsView.ShowIndicator = False ' 'colPattern ' @@ -346,5 +342,4 @@ Partial Class frmSQLEditor Friend WithEvents BarButtonItem3 As DevExpress.XtraBars.BarButtonItem Friend WithEvents BarButtonItem4 As DevExpress.XtraBars.BarButtonItem Friend WithEvents BarButtonItem5 As DevExpress.XtraBars.BarButtonItem - Friend WithEvents BarButtonItem6 As DevExpress.XtraBars.BarButtonItem End Class diff --git a/GUIs.Common/frmSQLEditor.resx b/GUIs.Common/frmSQLEditor.resx index 49b40652..1a6c0395 100644 --- a/GUIs.Common/frmSQLEditor.resx +++ b/GUIs.Common/frmSQLEditor.resx @@ -120,20 +120,7 @@ 17, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIxLjIsIFZlcnNpb249MjEuMi40 - LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl - dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAANcBAAAC77u/ - PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi - IHZpZXdCb3g9IjAgMCAzMiAzMiIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv - MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3Bh - Y2U9InByZXNlcnZlIiBpZD0iTGF5ZXJfMSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAg - MzIgMzIiPg0KICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLlJlZHtmaWxsOiNEMTFDMUM7fQo8L3N0 - eWxlPg0KICA8cGF0aCBkPSJNMTYsMkM4LjMsMiwyLDguMywyLDE2czYuMywxNCwxNCwxNHMxNC02LjMs - MTQtMTRTMjMuNywyLDE2LDJ6IE0yMywyMGwtMywzbC00LTRsLTQsNGwtMy0zbDQtNGwtNC00bDMtM2w0 - LDQgIGw0LTRsMywzbC00LDRMMjMsMjB6IiBjbGFzcz0iUmVkIiAvPg0KPC9zdmc+Cw== - - + + 17, 17 + \ No newline at end of file diff --git a/GUIs.Common/frmSQLEditor.vb b/GUIs.Common/frmSQLEditor.vb index 88ba5929..918d5cd5 100644 --- a/GUIs.Common/frmSQLEditor.vb +++ b/GUIs.Common/frmSQLEditor.vb @@ -12,6 +12,8 @@ Public Class frmSQLEditor Private ReadOnly LogConfig As LogConfig Private ReadOnly Database As MSSQLServer Private ReadOnly Placeholders As SQLEditor.Placeholders + Private ReadOnly FormHelper As FormHelper + Private ReadOnly GridHelper As GridBuilder Private ClearPlaceholdersAfterSuccessfulExecute As Boolean = False Private FormLoading As Boolean = False @@ -19,6 +21,8 @@ Public Class frmSQLEditor Public Property SQLCommand As String = "" Public Property SQLConnection As Integer = 0 + Public Property AllowSQLConnectionSelection As Boolean = True + Public Property LoadClipboardPlaceholders As Boolean = False Public Property PlaceholdersManual As Dictionary(Of String, String) @@ -31,6 +35,10 @@ Public Class frmSQLEditor Public Property PlaceholdersWindream As List(Of String) Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer) + MyClass.New(pLogConfig, pDatabase, True) + End Sub + + Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pAllowConnectionIdSelection As Boolean) ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() @@ -39,13 +47,21 @@ Public Class frmSQLEditor Database = pDatabase Patterns = New ClassPatterns(LogConfig) Placeholders = New SQLEditor.Placeholders() + FormHelper = New FormHelper(pLogConfig, Me) + GridHelper = New GridBuilder() + AllowSQLConnectionSelection = pAllowConnectionIdSelection End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load FormLoading = True + txtSQLCommand.BeginUpdate() Try + If AllowSQLConnectionSelection = False Then + GalleryConnection.Visibility = DevExpress.XtraBars.BarItemVisibility.Never + End If + If PlaceholdersAutomatic Is Nothing Then PlaceholdersAutomatic = New Dictionary(Of String, String) End If @@ -65,15 +81,19 @@ Public Class frmSQLEditor Dim oConnectionGroup = LoadConnections() Dim oSelectedItem = Nothing - If SQLConnection > 0 Then - For Each oItem As GalleryItem In oConnectionGroup.Items - Dim oConnection = oItem.Tag - If SQLConnection = oConnection.id Then - oSelectedItem = oItem - End If - Next + ' Missing/Negative connection will always result in default (DD_ECM) connection + If SQLConnection <= 0 Then + SQLConnection = 1 End If + ' Select the supplied connection in the ribbon gallery + For Each oItem As GalleryItem In oConnectionGroup.Items + Dim oConnection = oItem.Tag + If SQLConnection = oConnection.id Then + oSelectedItem = oItem + End If + Next + GalleryConnection.Gallery.Groups.Add(oConnectionGroup) If oSelectedItem IsNot Nothing Then @@ -85,7 +105,12 @@ Public Class frmSQLEditor ConfigureRichEditControl() + GridHelper.SetDefaults(ViewPlaceholders) + ViewPlaceholders.OptionsView.ShowAutoFilterRow = False + chkClearPlaceholders.Checked = ClearPlaceholdersAfterSuccessfulExecute + + ResizePlaceholderPanel() Catch ex As Exception Finally txtSQLCommand.EndUpdate() @@ -147,9 +172,19 @@ Public Class frmSQLEditor Dim oConnectionGroup = New GalleryItemGroup() With {.Caption = "Verbindungen"} Dim oItems As New List(Of GalleryItem) + For Each oConnection In oConnections - oItems.Add(GetGalleryItem(oConnection)) + + 'Preselect the first connection if no selection was made + Dim oChecked = False + If SQLConnection = 0 AndAlso oConnection.Id = oConnections.First.Id Then + oChecked = True + Else : oChecked = False + End If + + oItems.Add(GetConnectionGalleryItem(oConnection, oChecked)) Next + oConnectionGroup.Items.AddRange(oItems.ToArray) Return oConnectionGroup @@ -177,9 +212,10 @@ Public Class frmSQLEditor GridPlaceholders.DataSource = oPlaceholders End Sub - Private Function GetGalleryItem(pConnection As Connection) As GalleryItem + Private Function GetConnectionGalleryItem(pConnection As Connection, Optional pChecked As Boolean = False) As GalleryItem Dim oItem = New GalleryItem(Nothing, pConnection.Name, Nothing) With { - .Tag = pConnection + .Tag = pConnection, + .Checked = pChecked } oItem.ImageOptions.SvgImage = My.Resources.actions_database @@ -298,8 +334,31 @@ Public Class frmSQLEditor End Sub - Private Sub BarButtonItem6_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem6.ItemClick - FormResult = DialogResult.Cancel - Me.Close() + Private Sub frmSQLEditor_ResizeEnd(sender As Object, e As EventArgs) Handles MyBase.ResizeEnd + ResizePlaceholderPanel() + End Sub + + Private LastWindowState As FormWindowState = FormWindowState.Normal + Private Sub frmSQLEditor_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize + If LastWindowState <> WindowState Then + LastWindowState = WindowState + ResizePlaceholderPanel() + End If + End Sub + + Private Sub ResizePlaceholderPanel() + Dim oSplitterPosition As Integer = SplitContainerControl1.SplitterPosition + Dim oWindowWidth As Integer = Width + Dim oPlaceholdersExpanded As Boolean = Not SplitContainerControl1.Collapsed + + If oSplitterPosition > oWindowWidth Then + oSplitterPosition = oWindowWidth * 0.7 + ElseIf oSplitterPosition < (oWindowWidth * 0.5) Then + oSplitterPosition = oWindowWidth * 0.7 + ElseIf oSplitterPosition > (oWindowWidth * 0.9) Then + oSplitterPosition = oWindowWidth * 0.7 + End If + + SplitContainerControl1.SplitterPosition = oSplitterPosition End Sub End Class diff --git a/GUIs.Test.TestGUI/frmStart.vb b/GUIs.Test.TestGUI/frmStart.vb index 78ca09a3..ea323cc3 100644 --- a/GUIs.Test.TestGUI/frmStart.vb +++ b/GUIs.Test.TestGUI/frmStart.vb @@ -48,7 +48,7 @@ Public Class frmStart Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click Dim oForm As New frmSQLEditor(LogConfig, Database) With { .SQLCommand = "SELECT * FROM TBDD_USER WHERE EMAIL = '{#USER#EMAIL}'", - .SQLConnection = 1, + .SQLConnection = 0, .PlaceholdersAutomatic = New Dictionary(Of String, String) From {{"Testindex 1", "test 1"}, {"Testindex 2", "test 2"}}, .PlaceholdersAutomaticPrefix = "MAN", .PlaceholdersWindream = New List(Of String) From {"String Index 1", "String Index 2"}