Add Show-MappingTab function to manage tab selection and improve error handling

This commit is contained in:
Torsten Brendgen
2026-06-29 17:19:30 +02:00
parent bbe83e55ad
commit 2cf6d47ccd

View File

@@ -1047,6 +1047,29 @@ function Set-MigrationUiBusy {
}
}
function Show-MappingTab {
if ($null -eq $script:MainTabControl -or $null -eq $script:tabMapping) {
return
}
if ($script:MainTabControl -isnot [System.Windows.Forms.TabControl] -or $script:tabMapping -isnot [System.Windows.Forms.TabPage]) {
return
}
if ($null -ne $script:MainForm -and $script:MainForm.IsDisposed) {
return
}
try {
if ($script:MainTabControl.TabPages.Contains($script:tabMapping)) {
$script:MainTabControl.SelectTab($script:tabMapping)
}
}
catch {
Write-UILog -Message ("Konnte Mapping-Tab nicht aktivieren: {0}" -f $_.Exception.Message) -Level "WARN"
}
}
function Reset-MigrationStreamPositions {
$script:MigrationStreamPositions = @{
Output = [long]0
@@ -2400,7 +2423,7 @@ function Invoke-ExportFromGui {
Load-MappingTableFromPath -Path $mappingPath
Apply-ColumnDefaultsIfAvailable
Save-MappingTableToPath -Path $mappingPath
$script:MainTabControl.SelectedTab = $script:tabMapping
Show-MappingTab
}
}.GetNewClosure()
@@ -2798,7 +2821,7 @@ $btnLoadMapping.Add_Click({
if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
Load-MappingTableFromPath -Path $dialog.GetPath()
$script:MainTabControl.SelectedTab = $script:tabMapping
Show-MappingTab
}
}
catch {
@@ -2923,3 +2946,4 @@ if ($NoGui.IsPresent) {
$formBuilder.Show()