Common/DocumentResultList: Move Context menu into ribbon

This commit is contained in:
Jonathan Jenne
2022-03-14 13:17:39 +01:00
parent 7f9fd6ee58
commit 007ddeede0
15 changed files with 621 additions and 2360 deletions

View File

@@ -21,9 +21,10 @@ Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.ZooFlow.Constants
Imports DigitalData.Modules.Base.IDB.FileStore
Imports DigitalData.Controls.MessageBoxEx
Imports DigitalData.GUIs.Common.Base
Public Class frmDocumentResultList
Implements IResultForm
Implements IResultForm, IBaseForm
' These are NOT constants, only defaults
' Can be changed when calling frmDocumentResultList
@@ -41,10 +42,12 @@ Public Class frmDocumentResultList
Private Const FILE_OPEN_TIMER_INTERVAL As Integer = 500
Private ReadOnly Property LogConfig As LogConfig Implements IBaseForm.LogConfig
Private ReadOnly Property Logger As Logger Implements IBaseForm.Logger
Public ReadOnly Property ErrorHandler As BaseErrorHandler Implements IBaseForm.ErrorHandler
' Helper Classes
Private _IDBClient As Client
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly Config As ConfigManager(Of DocumentResultList.Config)
Private ReadOnly Environment As Environment
Private ReadOnly Filesystem As Modules.Filesystem.File
@@ -73,6 +76,8 @@ Public Class frmDocumentResultList
Public Property ShouldReturnToPreviousForm As Boolean = False Implements IResultForm.ShouldReturnToPreviousForm
Public Event NeedsRefresh As EventHandler(Of Integer) Implements IResultForm.NeedsRefresh
Public Event ResultsRefreshed As EventHandler(Of List(Of DocumentResultList.DocumentResult))
@@ -93,6 +98,7 @@ Public Class frmDocumentResultList
LogConfig = pLogConfig
Logger = pLogConfig.GetLogger()
ErrorHandler = New BaseErrorHandler(pLogConfig, Me)
Config = New ConfigManager(Of DocumentResultList.Config)(pLogConfig, oConfigPath, oConfigPath)
Helpers = New DocumentResultList.Helpers(pLogConfig)
@@ -134,8 +140,6 @@ Public Class frmDocumentResultList
End If
Documentloader = New DocumentResultList.Loader(LogConfig, OperationMode, _IDBClient, Environment.User)
If Params.WindowTitle <> "" Then
@@ -179,11 +183,13 @@ Public Class frmDocumentResultList
UpdateTotalResults()
UpdateGridData()
Catch ex As Exception
Logger.Error(ex)
MessageBox.Show("Error while loading results:" & vbNewLine & vbNewLine & ex.Message, Text)
ErrorHandler.ShowErrorMessage(ex, "Error while loading results", "Form Load")
Finally
_IsLoading = False
End Try
End Sub
@@ -231,12 +237,22 @@ Public Class frmDocumentResultList
' Save reference to current
_CurrentDocument = oDocumentInfo
' Hide Export and filesystem options for view only right
If oDocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then
DocumentViewer1.SetViewOnly(True)
RibbonPageGroup_Export.Visible = False
RibbonPageExport.Visible = False
RibbonPageGroupFilesystem.Visible = False
Else
DocumentViewer1.SetViewOnly(False)
RibbonPageGroup_Export.Visible = True
RibbonPageExport.Visible = True
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
End If
End If
Catch ex As Exception
@@ -706,9 +722,6 @@ Public Class frmDocumentResultList
Private Async Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick
If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then
'Process.Start(New ProcessStartInfo With {
' .FileName = _CurrentDocument.FullPath
'})
Await Watcher.OpenDocument(_CurrentDocument)
End If
End Sub
@@ -747,8 +760,12 @@ Public Class frmDocumentResultList
End If
End Sub
Private Function TestPathExists(pTitle As String) As Boolean
If IO.File.Exists(_CurrentDocument.FullPath) = False Then
Private Function TestFileExists(pTitle As String) As Boolean
If _CurrentDocument Is Nothing Then
Return False
End If
If File.Exists(_CurrentDocument.FullPath) = False Then
MessageBox.Show($"Datei {_CurrentDocument.FullPath} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return False
Else
@@ -756,6 +773,19 @@ Public Class frmDocumentResultList
End If
End Function
Private Function TestDirectoryExists(pDirectory As String, pTitle As String) As Boolean
If _CurrentDocument Is Nothing Then
Return False
End If
If Directory.Exists(pDirectory) = False Then
MessageBox.Show($"Ordner {pDirectory} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return False
Else
Return True
End If
End Function
Private Function TestObjectIdExists(pObjectId As Long, pTitle As String) As Boolean
If pObjectId = 0 Then
MessageBox.Show($"Objekt {pObjectId} existiert nicht oder wurde verschoben!", pTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
@@ -770,65 +800,78 @@ 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
'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
' 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
' '_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)
' 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
' 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
Private Sub MenuItem_OpenProperties_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesECM.ItemClick
Select Case OperationMode
Case OperationMode.NoAppServer
FileEx.OpenFileProperties(_CurrentDocument.FullPath)
Case Else
Dim oPropertyDialog As New frmObjectPropertyDialog(LogConfig, Environment, _IDBClient, _CurrentDocument.Id)
oPropertyDialog.Show()
End Select
End Sub
Private Sub MenuItemFolderpathCopyECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderpathCopy.ItemClick
Dim oFolderPath = IO.Path.GetDirectoryName(_CurrentDocument.FullPath)
Private Sub MenuItem_CopyFolderpath_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderpathCopy.ItemClick
Dim oFolderPath = Path.GetDirectoryName(_CurrentDocument.FullPath)
Clipboard.SetText(oFolderPath)
End Sub
Private Sub MenuItemPropertiesECM_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesECM.ItemClick
If TestPathExists(OPEN_PROPERTIES) = False Then
Exit Sub
End If
FileEx.OpenFileProperties(_CurrentDocument.FullPath)
End Sub
Private Sub MenuItemFilepathCopyIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFilepathCopy.ItemClick
Private Sub MenuItem_CopyFilepath_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFilepathCopy.ItemClick
Clipboard.SetText(_CurrentDocument.FullPath)
End Sub
Private Sub MenuItemFolderOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderOpen.ItemClick
If TestPathExists(OPEN_DIRECTORY) = False Then
Private Async Sub MenuItem_OpenFile_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
Try
Await Watcher.OpenDocument(_CurrentDocument)
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub MenuItem_FolderOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFolderOpen.ItemClick
Dim oFolderPath = Path.GetDirectoryName(_CurrentDocument.FullPath)
If TestDirectoryExists(oFolderPath, OPEN_DIRECTORY) = False Then
Exit Sub
End If
Dim oArgs As String = $"/e, /select, ""{_CurrentDocument.FullPath}"""
Dim oArgs As String = $"/e, /select, ""{oFolderPath}"""
Dim oInfo As New ProcessStartInfo() With {
.Arguments = oArgs,
.FileName = "explorer"
@@ -837,44 +880,6 @@ Public Class frmDocumentResultList
Process.Start(oInfo)
End Sub
Private Sub MenuItemPropertiesIDB_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesIDB.ItemClick
If TestObjectIdExists(_CurrentDocument.Id, OPEN_PROPERTIES) = False Then
Exit Sub
End If
Dim oPropertyDialog As New frmObjectPropertyDialog(LogConfig, Environment, _IDBClient, _CurrentDocument.Id)
oPropertyDialog.Show()
End Sub
Private Async Sub MenuItemFileOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
If TestPathExists(OPEN_FILE) = False Then
Exit Sub
End If
Try
Await Watcher.OpenDocument(_CurrentDocument)
'Process.Start(New ProcessStartInfo With {
' .FileName = _CurrentDocument.FullPath
'})
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub MenuItemPropertiesZooFlow_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemPropertiesZooFlow.ItemClick
If TestObjectIdExists(_CurrentDocument.Id, OPEN_PROPERTIES) = False Then
Exit Sub
End If
Dim oPropertyDialog As New frmObjectPropertyDialog(LogConfig, Environment, _IDBClient, _CurrentDocument.Id)
oPropertyDialog.Show()
End Sub
Private Async Sub MenuItemsOpenFileZooFlow_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemsOpenFileZooFlow.ItemClick
Await Watcher.OpenDocument(_CurrentDocument)
End Sub
#End Region
#Region "Drag to Export"