@@ -98,33 +98,8 @@ enum GeneratePartitionValidationError
9898 SIZE_ERROR , ENCRYPTION_PATH_ERROR ;
9999 }
100100
101- private enum ErrorListenerMap
102- {
103- INSTANCE ;
104-
105- private EnumMap <GeneratePartitionValidationError , String > validationErrors = new EnumMap <>(
106- GeneratePartitionValidationError .class );
107- private NvsCsvEditorPage page ;
108-
109- void setPage (NvsCsvEditorPage page )
110- {
111- this .page = page ;
112- }
113-
114- public void put (GeneratePartitionValidationError key , String errMsg )
115- {
116- validationErrors .put (key , errMsg );
117- page .setGenerationButtonStatus ();
118- page .updateErrorMessage ();
119- }
120-
121- public void remove (GeneratePartitionValidationError key )
122- {
123- validationErrors .remove (key );
124- page .setGenerationButtonStatus ();
125- page .updateErrorMessage ();
126- }
127- }
101+ private final EnumMap <GeneratePartitionValidationError , String > validationErrors = new EnumMap <>(
102+ GeneratePartitionValidationError .class );
128103
129104 public NvsCsvEditorPage (Composite parent , IFile csvFile , Consumer <Boolean > dirtyStateListener )
130105 {
@@ -133,8 +108,6 @@ public NvsCsvEditorPage(Composite parent, IFile csvFile, Consumer<Boolean> dirty
133108
134109 mainControl = new Composite (parent , SWT .NONE );
135110 mainControl .setLayout (new GridLayout (1 , false ));
136-
137- ErrorListenerMap .INSTANCE .setPage (this );
138111 }
139112
140113 /**
@@ -270,7 +243,6 @@ public void markDirty()
270243 public void updateErrorMessage ()
271244 {
272245 String newErrorMessage = StringUtil .EMPTY ;
273- EnumMap <GeneratePartitionValidationError , String > validationErrors = ErrorListenerMap .INSTANCE .validationErrors ;
274246
275247 if (saveErrorMsg == null )
276248 {
@@ -325,7 +297,7 @@ public void widgetSelected(SelectionEvent e)
325297 }
326298 else
327299 {
328- ErrorListenerMap . INSTANCE .remove (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR );
300+ validationErrors .remove (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR );
329301 }
330302 markDirty ();
331303 }
@@ -442,7 +414,7 @@ public void widgetSelected(SelectionEvent e)
442414 if (generateEncryptionKeyCheckBox .getSelection ())
443415 {
444416 canBeDisposedList .forEach (t -> t .setEnabled (false ));
445- ErrorListenerMap . INSTANCE .remove (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR );
417+ validationErrors .remove (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR );
446418 errorIconLabel .setImage (null ); // Hide error when disabled
447419 errorIconLabel .setToolTipText (null );
448420 }
@@ -739,7 +711,7 @@ private void getGeneratePartitionAction()
739711 public void setGenerationButtonStatus ()
740712 {
741713 if (generateButton != null )
742- generateButton .setEnabled (ErrorListenerMap . INSTANCE . validationErrors .isEmpty ());
714+ generateButton .setEnabled (validationErrors .isEmpty ());
743715 }
744716
745717 private String validateEncKeyPath ()
@@ -749,11 +721,11 @@ private String validateEncKeyPath()
749721 if (encryptAction .getSelection () && !generateEncryptionKeyCheckBox .getSelection ()
750722 && !new File (encKeyPath ).canRead ())
751723 {
752- ErrorListenerMap . INSTANCE .put (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR ,
724+ validationErrors .put (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR ,
753725 Messages .NvsEditorDialog_EncKeyCantBeReadErrMsg );
754726 return Messages .NvsEditorDialog_EncKeyCantBeReadErrMsg ;
755727 }
756- ErrorListenerMap . INSTANCE .remove (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR );
728+ validationErrors .remove (GeneratePartitionValidationError .ENCRYPTION_PATH_ERROR );
757729
758730 return StringUtil .EMPTY ;
759731 }
@@ -767,17 +739,17 @@ private String validateSize()
767739 }
768740 catch (NumberFormatException e )
769741 {
770- ErrorListenerMap . INSTANCE .put (GeneratePartitionValidationError .SIZE_ERROR ,
742+ validationErrors .put (GeneratePartitionValidationError .SIZE_ERROR ,
771743 Messages .NvsEditorDialog_SizeValidationDecodedErr + e .getMessage ());
772744 return Messages .NvsEditorDialog_SizeValidationDecodedErr + e .getMessage ();
773745 }
774746 if (decodedSize < 4096 || decodedSize % 4096 != 0 )
775747 {
776- ErrorListenerMap . INSTANCE .put (GeneratePartitionValidationError .SIZE_ERROR ,
748+ validationErrors .put (GeneratePartitionValidationError .SIZE_ERROR ,
777749 Messages .NvsEditorDialog_WrongSizeFormatErrMsg );
778750 return Messages .NvsEditorDialog_WrongSizeFormatErrMsg ;
779751 }
780- ErrorListenerMap . INSTANCE .remove (GeneratePartitionValidationError .SIZE_ERROR );
752+ validationErrors .remove (GeneratePartitionValidationError .SIZE_ERROR );
781753 return StringUtil .EMPTY ;
782754 }
783755
0 commit comments