77using System . Diagnostics ;
88using System . IO ;
99using System . Linq ;
10+ using System . Text ;
1011using System . Windows . Forms ;
1112using System . Xml . Linq ;
1213using System . Xml . XPath ;
@@ -113,17 +114,8 @@ internal void DoImport()
113114
114115 ImportCustomFields ( _importLiftLocation ) ;
115116
116- // REVIEW (Hasso) 2026.01: should this be calculated closer to where it is used?
117- // If the configuration to import has the same label as an existing configuration in the project folder
118- // then overwrite the existing configuration.
119- var existingConfigurationInTheWay = _configurations . FirstOrDefault ( config => config . Label == NewConfigToImport . Label &&
120- Path . GetDirectoryName ( config . FilePath ) == _projectConfigDir ) ;
117+ NewConfigToImport . Publications . ForEach ( publication => AddPublicationTypeIfNotPresent ( publication , _cache ) ) ;
121118
122- NewConfigToImport . Publications . ForEach (
123- publication =>
124- {
125- AddPublicationTypeIfNotPresent ( publication , _cache ) ;
126- } ) ;
127119 try
128120 {
129121 ImportStyles ( _importStylesLocation ) ;
@@ -147,6 +139,10 @@ internal void DoImport()
147139 _view . importButton . Enabled = false ;
148140 }
149141
142+ // If the configuration to import has the same label as an existing configuration in the project folder
143+ // then overwrite the existing configuration.
144+ var existingConfigurationInTheWay = _configurations . FirstOrDefault ( config => config . Label == NewConfigToImport . Label &&
145+ Path . GetDirectoryName ( config . FilePath ) == _projectConfigDir ) ;
150146 // We have re-loaded the model from disk to preserve custom field state so the Label must be set here
151147 NewConfigToImport . FilePath = _temporaryImportConfigLocation ;
152148 NewConfigToImport . Load ( _cache ) ;
@@ -163,7 +159,8 @@ internal void DoImport()
163159 NewConfigToImport . Label = _proposedNewConfigLabel ;
164160 }
165161
166- // Set a filename for the new configuration. Use a unique filename that isn't either registered with another configuration, or existing on disk. Note that in this way, we ignore what the original filename was of the configuration file in the .zip file.
162+ // Set a filename for the new configuration. Use a unique filename that isn't either registered with another configuration, or existing on disk.
163+ // Note that in this way, we ignore what the original filename was of the configuration file in the .zip file.
167164 DictionaryConfigurationManagerController . GenerateFilePath ( _projectConfigDir , _configurations , NewConfigToImport ) ;
168165
169166 var outputConfigPath = existingConfigurationInTheWay != null ? existingConfigurationInTheWay . FilePath : NewConfigToImport . FilePath ;
@@ -356,7 +353,6 @@ private IEnumerable<string> CustomFieldsInLiftFile(string liftFilePath)
356353 /// <summary>
357354 /// Connect to and show a view for the user to perform an import.
358355 /// </summary>
359- /// <param name="dialog"></param>
360356 public void DisplayView ( DictionaryConfigurationImportDlg dialog )
361357 {
362358 _view = dialog ;
@@ -397,50 +393,46 @@ public void OnBrowse()
397393
398394 public void RefreshStatusDisplay ( )
399395 {
400- string mainStatus ;
401- var publicationStatus = string . Empty ;
402- var customFieldStatus = string . Empty ;
396+ var statusBldr = new StringBuilder ( ) ;
403397 _view . explanationLabel . Text = "" ;
404398
405399 if ( NewConfigToImport == null )
406400 {
407- string invalidConfigFileMsg = string . Empty ;
408401 if ( _isInvalidConfigFile )
409402 {
410403 var configType = Path . GetFileName ( _projectConfigDir ) == DictionaryConfigurationListener . DictConfigDirName
411- ? xWorksStrings . ReversalIndex : xWorksStrings . Dictionary ;
412- invalidConfigFileMsg = string . Format ( xWorksStrings . DictionaryConfigurationMismatch , configType )
413- + Environment . NewLine ;
404+ ? xWorksStrings . ReversalIndex : xWorksStrings . Dictionary ;
405+ statusBldr . AppendFormat ( xWorksStrings . DictionaryConfigurationMismatch , configType ) . AppendLine ( ) ;
414406 }
415- _view . explanationLabel . Text = invalidConfigFileMsg + xWorksStrings . kstidCannotImport ;
407+ _view . explanationLabel . Text = statusBldr . Append ( xWorksStrings . kstidCannotImport ) . ToString ( ) ;
416408 return ;
417409 }
418410
419411 if ( _originalConfigLabel == _proposedNewConfigLabel )
420412 {
421- mainStatus = string . Format ( xWorksStrings . kstidImportingConfig , NewConfigToImport . Label ) ;
413+ statusBldr . AppendFormat ( xWorksStrings . kstidImportingConfig , NewConfigToImport . Label ) . AppendLine ( ) ;
422414 }
423415 else
424416 {
425- mainStatus = string . Format ( NewConfigToImport . Label == _proposedNewConfigLabel
417+ statusBldr . AppendFormat ( NewConfigToImport . Label == _proposedNewConfigLabel
426418 ? xWorksStrings . kstidImportingConfigNewName
427419 : xWorksStrings . kstidImportingAndOverwritingConfiguration ,
428- NewConfigToImport . Label ) ;
420+ NewConfigToImport . Label ) . AppendLine ( ) ;
429421 }
430422
431423 if ( _newPublications != null && _newPublications . Any ( ) )
432424 {
433- publicationStatus = xWorksStrings . kstidPublicationsWillBeAdded + Environment . NewLine + string . Join ( ", " , _newPublications ) ;
425+ statusBldr . AppendLine ( ) . AppendLine ( xWorksStrings . kstidPublicationsWillBeAdded ) . AppendLine ( string . Join ( ", " , _newPublications ) ) ;
434426 }
435427
436428 if ( _customFieldsToImport != null && _customFieldsToImport . Any ( ) )
437429 {
438- customFieldStatus = xWorksStrings . kstidCustomFieldsWillBeAdded + Environment . NewLine + string . Join ( ", " , _customFieldsToImport ) ;
430+ statusBldr . AppendLine ( ) . AppendLine ( xWorksStrings . kstidCustomFieldsWillBeAdded ) . AppendLine ( string . Join ( ", " , _customFieldsToImport ) ) ;
439431 }
440- // TODO (Hasso) 2026-01: WSs
441- _view . explanationLabel . Text = string . Format ( "{0}{1}{2}{1}{3}{1}{4}" ,
442- mainStatus , Environment . NewLine + Environment . NewLine , publicationStatus , customFieldStatus ,
443- xWorksStrings . DictionaryConfigurationDictionaryConfigurationUser_StyleOverwriteWarning ) ;
432+
433+ statusBldr . AppendLine ( ) . Append ( xWorksStrings . DictionaryConfigurationDictionaryConfigurationUser_StyleOverwriteWarning ) ;
434+
435+ _view . explanationLabel . Text = statusBldr . ToString ( ) ;
444436 _view . Refresh ( ) ;
445437 }
446438
0 commit comments