88import com .magento .idea .magento2plugin .actions .generation .dialog .CreateAPluginDialog ;
99import com .magento .idea .magento2plugin .indexes .ModuleIndex ;
1010import com .magento .idea .magento2plugin .util .Regex ;
11- import com .magento .idea .magento2plugin .validators .ValidatorBundle ;
11+ import com .magento .idea .magento2plugin .bundles .ValidatorBundle ;
1212import javax .swing .*;
1313import java .util .List ;
1414
1515public class CreateAPluginDialogValidator {
1616 private static CreateAPluginDialogValidator INSTANCE = null ;
17+ private ValidatorBundle validatorBundle ;
1718 private CreateAPluginDialog dialog ;
1819
1920 public static CreateAPluginDialogValidator getInstance (CreateAPluginDialog dialog ) {
@@ -25,88 +26,92 @@ public static CreateAPluginDialogValidator getInstance(CreateAPluginDialog dialo
2526 return INSTANCE ;
2627 }
2728
29+ public CreateAPluginDialogValidator () {
30+ this .validatorBundle = new ValidatorBundle ();
31+ }
32+
2833 public boolean validate (Project project )
2934 {
3035 String errorTitle = "Error" ;
3136 String pluginClassName = dialog .getPluginClassName ();
3237
3338 if (pluginClassName .length () == 0 ) {
34- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Class Name" );
39+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Class Name" );
3540 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
3641
3742 return false ;
3843 }
3944
4045 if (!pluginClassName .matches (Regex .ALPHANUMERIC )) {
41- String errorMessage = ValidatorBundle .message ("validator.alphaNumericCharacters" , "Plugin Class Name" );
46+ String errorMessage = validatorBundle .message ("validator.alphaNumericCharacters" , "Plugin Class Name" );
4247 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
4348
4449 return false ;
4550 }
4651
4752 if (!Character .isUpperCase (pluginClassName .charAt (0 )) && !Character .isDigit (pluginClassName .charAt (0 ))) {
48- String errorMessage = ValidatorBundle .message ("validator.startWithNumberOrCapitalLetter" , "Plugin Class Name" );
53+ String errorMessage = validatorBundle .message ("validator.startWithNumberOrCapitalLetter" , "Plugin Class Name" );
4954 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
5055
5156 return false ;
5257 }
5358
5459 String pluginDirectory = dialog .getPluginDirectory ();
5560 if (pluginDirectory .length () == 0 ) {
56- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Directory" );
61+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Directory" );
5762 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
5863
5964 return false ;
6065 }
6166
6267 if (!pluginDirectory .matches (Regex .DIRECTORY )) {
63- String errorMessage = ValidatorBundle .message ("validator.directory.isNotValid" , "Plugin Directory" );
68+ String errorMessage = validatorBundle .message ("validator.directory.isNotValid" , "Plugin Directory" );
6469 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
6570
6671 return false ;
6772 }
6873
6974 String pluginName = dialog .getPluginName ();
7075 if (pluginName .length () == 0 ) {
71- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Name" );
76+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Name" );
7277 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
7378
7479 return false ;
7580 }
7681
7782 if (!pluginName .matches (Regex .IDENTIFIER )) {
78- String errorMessage = ValidatorBundle .message ("validator.identifier" , "Plugin Name" );
83+ String errorMessage = validatorBundle .message ("validator.identifier" , "Plugin Name" );
7984 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
8085
8186 return false ;
8287 }
8388
8489 String sortOrder = dialog .getPluginSortOrder ();
8590 if (sortOrder .length () == 0 ) {
86- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Sort Order" );
91+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Sort Order" );
8792 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
8893
8994 return false ;
9095 }
9196
9297 if (!sortOrder .matches (Regex .NUMERIC )) {
93- String errorMessage = ValidatorBundle .message ("validator.onlyNumbers" , "Sort Order" );
98+ String errorMessage = validatorBundle .message ("validator.onlyNumbers" , "Sort Order" );
9499 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
95100
96101 return false ;
97102 }
98103
99104 String pluginModule = dialog .getPluginModule ();
100105 if (pluginModule .length () == 0 ) {
101- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Module" );
106+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Module" );
102107 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
103108
104109 return false ;
105110 }
106111
107112 List <String > allModulesList = ModuleIndex .getInstance (project ).getEditableModuleNames ();
108113 if (!allModulesList .contains (pluginModule )) {
109- String errorMessage = ValidatorBundle .message ("validator.module.noSuchModule" , pluginModule );
114+ String errorMessage = validatorBundle .message ("validator.module.noSuchModule" , pluginModule );
110115 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
111116
112117 return false ;
0 commit comments