Common/DocumentResultList: Rework layout with DockManager

This commit is contained in:
Jonathan Jenne
2022-03-14 16:33:15 +01:00
parent 262ed2143f
commit 538790aa42
16 changed files with 1797 additions and 519 deletions

View File

@@ -10,7 +10,6 @@ Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.BandedGrid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraPrinting
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.EDMI.API
@@ -56,12 +55,14 @@ Public Class frmDocumentResultList
Private ReadOnly Helpers As DocumentResultList.Helpers
Private ReadOnly Params As DocumentResultList.Params
Private ReadOnly LayoutManager As DocumentResultList.Layout
Private WithEvents Watcher As DocumentResultList.Watcher
Private ControlManager As AttributeControls
Private Documentloader As DocumentResultList.Loader
' Runtime variables
Private Property _ResultLists As List(Of DocumentResultList.DocumentResult)
Private Property ResultLists As List(Of DocumentResultList.DocumentResult)
Private _IsLoading As Boolean = True
Private _ActiveGrid As GridControl = Nothing
@@ -100,16 +101,17 @@ Public Class frmDocumentResultList
Logger = pLogConfig.GetLogger()
ErrorHandler = New BaseErrorHandler(pLogConfig, Me)
Environment = pEnvironment
Params = pParams
ResultLists = pParams.Results
Config = New ConfigManager(Of DocumentResultList.Config)(pLogConfig, oConfigPath, oConfigPath)
Helpers = New DocumentResultList.Helpers(pLogConfig)
Filesystem = New Modules.Filesystem.File(pLogConfig)
GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3})
FileEx = New Modules.Windows.File(pLogConfig)
Watcher = New DocumentResultList.Watcher(pLogConfig)
Environment = pEnvironment
Params = pParams
_ResultLists = pParams.Results
LayoutManager = New DocumentResultList.Layout(pLogConfig, Config)
_Language = Utils.NotNull(Me.Environment.User.Language, State.UserState.LANG_EN_US)
End Sub
@@ -158,6 +160,17 @@ Public Class frmDocumentResultList
SplitContainerControl2.SplitterPosition = Config.Config.SplitContainer2Distance
SwitchDetailContainerHorizontal.Checked = Config.Config.SplitContainer2Horizontal
' Hide options relating to a filepath for zooflow
If OperationMode = OperationMode.ZooFlow Then
RibbonPageGroupFilesystem.Visible = False
Else
RibbonPageGroupFilesystem.Visible = False
End If
If OperationMode = OperationMode.NoAppServer Then
DockPanelMetadata.Visibility = Docking.DockVisibility.Hidden
End If
If OperationMode <> OperationMode.NoAppServer Then
' Location and size will be managed by the ZooFlow Search Window
If Utils.IsVisibleOnAnyScreen(Config.Config.WindowLocation) Then
@@ -184,6 +197,8 @@ Public Class frmDocumentResultList
UpdateTotalResults()
UpdateGridData()
LayoutManager.DockManager_RestoreLayout(DockManager1)
Catch ex As Exception
ErrorHandler.ShowErrorMessage(ex, "Error while loading results", "Form Load")
@@ -195,7 +210,8 @@ Public Class frmDocumentResultList
Private Sub frmDocumentResultList_Closing(sender As Object, e As CancelEventArgs) Handles Me.FormClosing
Try
GridViewSave_Layout(_ActiveGrid.MainView)
LayoutManager.GridView_SaveLayout(_ActiveGrid.MainView)
LayoutManager.DockManager_SaveLayout(DockManager1)
Config.Config.WindowLocation = Location
Config.Config.WindowSize = Size
@@ -207,11 +223,10 @@ Public Class frmDocumentResultList
End Try
End Sub
Private Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
Private Async Sub GridView_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs)
Helpers.SetRowHandle(e)
Try
Reset_Errors()
Cursor = Cursors.WaitCursor
If e.FocusedRowHandle >= 0 Then
@@ -226,7 +241,7 @@ Public Class frmDocumentResultList
' Check DocumentInfo
If IsNothing(oDocumentInfo) Then
Show_Warning("File could not be loaded!")
ErrorHandler.ShowErrorMessage("File could not be loaded!")
Exit Sub
End If
@@ -248,16 +263,19 @@ Public Class frmDocumentResultList
RibbonPageGroupFilesystem.Visible = True
End If
' Hide options relating to a filepath for zooflow
If OperationMode = OperationMode.ZooFlow Then
RibbonPageGroupFilesystem.Visible = False
Else
RibbonPageGroupFilesystem.Visible = False
If OperationMode = OperationMode.ZooFlow Or OperationMode = OperationMode.WithAppServer Then
Dim oEntityId = 1
Dim oAttributes = Await ControlManager.GetAttributesForBusinessEntity(oEntityId)
If oAttributes.Count = 0 Then
MsgBox($"Es konnten keine Attribute für das Objekt '{oObjectId}' geladen werden!", MsgBoxStyle.Critical, Text)
End If
Await ControlManager.LoadControlsForAttributes(oObjectId, oAttributes, RootMetadata)
End If
End If
Catch ex As Exception
Logger.Error(ex)
Show_CriticalError(ex)
ErrorHandler.ShowErrorMessage(ex, "GridView_FocusedRowChanged")
Finally
Cursor = Cursors.Default
End Try
@@ -303,8 +321,7 @@ Public Class frmDocumentResultList
End If
Catch ex As Exception
Logger.Error(ex)
Show_CriticalError(ex)
ErrorHandler.ShowErrorMessage(ex, "Watcher_FileChanged")
Finally
' Signal to the watcher that the file is no longer in use
@@ -376,8 +393,7 @@ Public Class frmDocumentResultList
Dim oPort As Integer = oSplit.Item(1)
_IDBClient = New Client(LogConfig, oAddress, oPort)
' TODO: INitialize databasewithfallback
'_Database
ControlManager = New AttributeControls(LogConfig, Environment, _IDBClient)
If Not _IDBClient.Connect() Then
Logger.Warn("Client could not connect to Service at [{0}]", Environment.Service.Address)
@@ -398,7 +414,7 @@ Public Class frmDocumentResultList
_IsLoading = True
Try
' Save the new results
_ResultLists = pResults
ResultLists = pResults
' Remove the current document from
Documentloader.ClearCache()
@@ -450,31 +466,31 @@ Public Class frmDocumentResultList
Private Sub UpdateGridData()
' Load Grids
For oIndex = 0 To _ResultLists.Count - 1
For oIndex = 0 To ResultLists.Count - 1
Select Case oIndex
Case 0
Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(0)
Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(0)
LoadGridData(GridView1, oResult)
CreateDocumentGrid(GridView1, oResult)
RestoreLayout(GridView1)
UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count)
LayoutManager.GridView_RestoreLayout(GridView1)
UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count)
Case 1
Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(1)
Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(1)
LoadGridData(GridView2, oResult)
CreateDocumentGrid(GridView2, oResult)
RestoreLayout(GridView2)
UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count)
LayoutManager.GridView_RestoreLayout(GridView2)
UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count)
Case 2
Dim oResult As DocumentResultList.DocumentResult = _ResultLists.Item(2)
Dim oResult As DocumentResultList.DocumentResult = ResultLists.Item(2)
LoadGridData(GridView3, oResult)
CreateDocumentGrid(GridView3, oResult)
RestoreLayout(GridView3)
UpdateGridHeader(_ResultLists, oIndex, oResult.Datatable.Rows.Count)
LayoutManager.GridView_RestoreLayout(GridView3)
UpdateGridHeader(ResultLists, oIndex, oResult.Datatable.Rows.Count)
Case Else
MessageBox.Show(Constants.MESSAGE_TOO_MANY_SEARCHES, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
@@ -483,7 +499,7 @@ Public Class frmDocumentResultList
Next
' Hide Grids depending on Result count
Select Case _ResultLists.Count
Select Case ResultLists.Count
Case 0
SplitContainerControl1.SetPanelCollapsed(True)
@@ -515,7 +531,7 @@ Public Class frmDocumentResultList
Private Sub UpdateTotalResults()
Dim oTotalResults = 0
For Each oList In _ResultLists
For Each oList In ResultLists
oTotalResults += oList.Datatable.Rows.Count
Next
@@ -702,17 +718,17 @@ Public Class frmDocumentResultList
Private Sub GridView1_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView1.ColumnFilterChanged
Dim oRowCount = sender.RowCount
UpdateGridHeader(_ResultLists, 0, oRowCount)
UpdateGridHeader(ResultLists, 0, oRowCount)
End Sub
Private Sub GridView2_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView2.ColumnFilterChanged
Dim oRowCount = sender.RowCount
UpdateGridHeader(_ResultLists, 1, oRowCount)
UpdateGridHeader(ResultLists, 1, oRowCount)
End Sub
Private Sub GridView3_ColumnFilterChanged(sender As GridView, e As EventArgs) Handles GridView3.ColumnFilterChanged
Dim oRowCount = sender.RowCount
UpdateGridHeader(_ResultLists, 2, oRowCount)
UpdateGridHeader(ResultLists, 2, oRowCount)
End Sub
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonBack.ItemClick
@@ -726,30 +742,10 @@ Public Class frmDocumentResultList
End If
End Sub
Public Sub Show_CriticalError(Message As String)
labelCriticalError.Visibility = BarItemVisibility.Always
labelCriticalError.Caption = Message
End Sub
Public Sub Show_CriticalError(pException As Exception)
labelCriticalError.Visibility = BarItemVisibility.Always
labelCriticalError.Caption = pException.Message
End Sub
Public Sub Show_Warning(Message As String)
labelWarning.Visibility = BarItemVisibility.Always
labelWarning.Caption = Message
End Sub
Public Sub Reset_Errors()
labelCriticalError.Visibility = BarItemVisibility.Never
labelWarning.Visibility = BarItemVisibility.Never
End Sub
Private Sub BarButtonResetLayout_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonResetLayout.ItemClick
If Not IsNothing(_ActiveGrid) Then
Try
Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView)
Dim oFile = LayoutManager.GetGrid_LayoutName(_ActiveGrid.MainView)
If IO.File.Exists(oFile) Then
IO.File.Delete(oFile)
End If
@@ -798,45 +794,12 @@ Public Class frmDocumentResultList
#Region "Context Menu"
'Private Sub GridView_PopupMenuShowing(sender As Object, e As PopupMenuShowingEventArgs) Handles GridView2.PopupMenuShowing, GridView3.PopupMenuShowing, GridView1.PopupMenuShowing
' Try
' Dim oView As GridView = sender
' If e.MenuType = GridMenuType.Row Then
' Dim oRowHandle = e.HitInfo.RowHandle
' Dim oRow As DataRow = oView.GetDataRow(oRowHandle)
' Dim oObjectId As Long = oRow.Item(COLUMN_DOCID)
' Dim oPoint As Point = oView.GridControl.PointToScreen(e.HitInfo.HitPoint)
' Dim oRight As Rights.AccessRight = _CurrentDocument.AccessRight
' '_CurrentDocumentId = oObjectId
' _CurrentDocument.Id = oObjectId
' If OperationMode = OperationMode.WithAppServer Then
' If oRight = Rights.AccessRight.FULL Or oRight = Rights.AccessRight.VIEW_EXPORT Then
' MenuFullAccess_IDB.ShowPopup(oPoint)
' Else
' MenuViewAccess_IDB.ShowPopup(oPoint)
' End If
' ElseIf OperationMode = OperationMode.ZooFlow Then
' MenuFullAccess_ZOOFLOW.ShowPopup(oPoint)
' Else
' MenuFullAccess_EDM.ShowPopup(oPoint)
' End If
' Else
' '_CurrentDocumentId = Nothing
' _CurrentDocument.Id = Nothing
' End If
' Catch ex As Exception
' Logger.Error(ex)
' MsgBox("Unexpected Error while preparing context menu", MsgBoxStyle.Critical, Text)
' End Try
'End Sub
#Region "File Actions"
Private Sub MenuItem_OpenProperties_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesECM.ItemClick
If _CurrentDocument Is Nothing Then
Exit Sub
End If
Select Case OperationMode
Case OperationMode.NoAppServer
FileEx.OpenFileProperties(_CurrentDocument.FullPath)
@@ -947,38 +910,19 @@ Public Class frmDocumentResultList
Config.Config.SplitContainer2Horizontal = SwitchDetailContainerHorizontal.Checked
End If
End Sub
Private Function GetDevexpressGrid_LayoutName(pGridView As GridView)
Dim Filename As String = $"DevExpressGridViewDocResult_{pGridView.Name}UserLayout.xml"
Return Path.Combine(Config.UserConfigPath.Replace("UserConfig.xml", ""), Filename)
End Function
Private Sub GridViewSave_Layout(pGridView As GridView)
Try
Dim oXml As String = GetDevexpressGrid_LayoutName(pGridView)
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
Catch ex As Exception
Logger.Error(ex)
Logger.Info("Error while saving GridLayout: " & ex.Message)
End Try
End Sub
Private Sub RestoreLayout(pGridView As GridView)
Try
Dim oLayoutFile As String = GetDevexpressGrid_LayoutName(pGridView)
If IO.File.Exists(oLayoutFile) Then
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
End If
Catch ex As Exception
Logger.Error(ex)
Logger.Info("Error while restoring layout: " & ex.Message)
End Try
End Sub
#End Region
Private Sub ButtonRefresh_ItemClick(sender As Object, e As ItemClickEventArgs) Handles ButtonRefresh.ItemClick
RaiseEvent NeedsRefresh(Me, Params.ProfileGuid)
End Sub
#End Region
Private Sub BarButtonItem6_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem6.ItemClick
Try
Dim oFile = LayoutManager.GetDockmanager_LayoutName()
If File.Exists(oFile) Then
File.Delete(oFile)
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
End Class