8
8
import com .magento .idea .magento2plugin .actions .generation .dialog .CreateAPluginDialog ;
9
9
import com .magento .idea .magento2plugin .indexes .ModuleIndex ;
10
10
import com .magento .idea .magento2plugin .util .Regex ;
11
- import com .magento .idea .magento2plugin .validators .ValidatorBundle ;
11
+ import com .magento .idea .magento2plugin .bundles .ValidatorBundle ;
12
12
import javax .swing .*;
13
13
import java .util .List ;
14
14
15
15
public class CreateAPluginDialogValidator {
16
16
private static CreateAPluginDialogValidator INSTANCE = null ;
17
+ private ValidatorBundle validatorBundle ;
17
18
private CreateAPluginDialog dialog ;
18
19
19
20
public static CreateAPluginDialogValidator getInstance (CreateAPluginDialog dialog ) {
@@ -25,88 +26,92 @@ public static CreateAPluginDialogValidator getInstance(CreateAPluginDialog dialo
25
26
return INSTANCE ;
26
27
}
27
28
29
+ public CreateAPluginDialogValidator () {
30
+ this .validatorBundle = new ValidatorBundle ();
31
+ }
32
+
28
33
public boolean validate (Project project )
29
34
{
30
35
String errorTitle = "Error" ;
31
36
String pluginClassName = dialog .getPluginClassName ();
32
37
33
38
if (pluginClassName .length () == 0 ) {
34
- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Class Name" );
39
+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Class Name" );
35
40
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
36
41
37
42
return false ;
38
43
}
39
44
40
45
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" );
42
47
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
43
48
44
49
return false ;
45
50
}
46
51
47
52
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" );
49
54
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
50
55
51
56
return false ;
52
57
}
53
58
54
59
String pluginDirectory = dialog .getPluginDirectory ();
55
60
if (pluginDirectory .length () == 0 ) {
56
- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Directory" );
61
+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Directory" );
57
62
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
58
63
59
64
return false ;
60
65
}
61
66
62
67
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" );
64
69
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
65
70
66
71
return false ;
67
72
}
68
73
69
74
String pluginName = dialog .getPluginName ();
70
75
if (pluginName .length () == 0 ) {
71
- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Name" );
76
+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Name" );
72
77
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
73
78
74
79
return false ;
75
80
}
76
81
77
82
if (!pluginName .matches (Regex .IDENTIFIER )) {
78
- String errorMessage = ValidatorBundle .message ("validator.identifier" , "Plugin Name" );
83
+ String errorMessage = validatorBundle .message ("validator.identifier" , "Plugin Name" );
79
84
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
80
85
81
86
return false ;
82
87
}
83
88
84
89
String sortOrder = dialog .getPluginSortOrder ();
85
90
if (sortOrder .length () == 0 ) {
86
- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Sort Order" );
91
+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Sort Order" );
87
92
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
88
93
89
94
return false ;
90
95
}
91
96
92
97
if (!sortOrder .matches (Regex .NUMERIC )) {
93
- String errorMessage = ValidatorBundle .message ("validator.onlyNumbers" , "Sort Order" );
98
+ String errorMessage = validatorBundle .message ("validator.onlyNumbers" , "Sort Order" );
94
99
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
95
100
96
101
return false ;
97
102
}
98
103
99
104
String pluginModule = dialog .getPluginModule ();
100
105
if (pluginModule .length () == 0 ) {
101
- String errorMessage = ValidatorBundle .message ("validator.notEmpty" , "Plugin Module" );
106
+ String errorMessage = validatorBundle .message ("validator.notEmpty" , "Plugin Module" );
102
107
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
103
108
104
109
return false ;
105
110
}
106
111
107
112
List <String > allModulesList = ModuleIndex .getInstance (project ).getEditableModuleNames ();
108
113
if (!allModulesList .contains (pluginModule )) {
109
- String errorMessage = ValidatorBundle .message ("validator.module.noSuchModule" , pluginModule );
114
+ String errorMessage = validatorBundle .message ("validator.module.noSuchModule" , pluginModule );
110
115
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
111
116
112
117
return false ;
0 commit comments