7
7
import com .intellij .openapi .project .Project ;
8
8
import com .magento .idea .magento2plugin .actions .generation .dialog .NewCLICommandDialog ;
9
9
import com .magento .idea .magento2plugin .bundles .ValidatorBundle ;
10
- import com .magento .idea .magento2plugin .util . GetPhpClassByFQN ;
10
+ import com .magento .idea .magento2plugin .bundles . CommonBundle ;
11
11
import com .magento .idea .magento2plugin .util .RegExUtil ;
12
12
13
13
import javax .swing .*;
14
14
15
15
public class NewCLICommandValidator {
16
16
private static NewCLICommandValidator INSTANCE = null ;
17
- private ValidatorBundle validatorBundle ;
17
+ private final ValidatorBundle validatorBundle ;
18
+ private final CommonBundle commonBundle ;
18
19
19
20
public static NewCLICommandValidator getInstance () {
20
21
if (null == INSTANCE ) {
@@ -26,6 +27,7 @@ public static NewCLICommandValidator getInstance() {
26
27
27
28
public NewCLICommandValidator () {
28
29
this .validatorBundle = new ValidatorBundle ();
30
+ this .commonBundle = new CommonBundle ();
29
31
}
30
32
31
33
public boolean validate (Project project , NewCLICommandDialog dialog ) {
@@ -36,61 +38,76 @@ public boolean validate(Project project, NewCLICommandDialog dialog) {
36
38
String cliCommandDescription = dialog .getCLICommandDescription ();
37
39
38
40
if (cliCommandClassName .length () == 0 ) {
39
- String errorMessage = validatorBundle .message ("validator.notEmpty" , "CLI Command Class Name" );
41
+ String errorMessage = validatorBundle .message (
42
+ "validator.notEmpty" ,
43
+ this .commonBundle .message ("common.cli.class.name" )
44
+ );
40
45
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
41
46
42
47
return false ;
43
48
}
44
49
if (!cliCommandClassName .matches (RegExUtil .ALPHANUMERIC )) {
45
50
String errorMessage = validatorBundle .message (
46
- "validator.alphaNumericCharacters" ,
47
- "CLI Command Class Name"
51
+ "validator.alphaNumericCharacters" ,
52
+ this . commonBundle . message ( "common.cli.class.name" )
48
53
);
49
54
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
50
55
51
56
return false ;
52
57
}
53
58
if (!Character .isUpperCase (cliCommandClassName .charAt (0 )) && !Character .isDigit (cliCommandClassName .charAt (0 ))) {
54
59
String errorMessage = validatorBundle .message (
55
- "validator.startWithNumberOrCapitalLetter" ,
56
- "CLI Command Class Name"
60
+ "validator.startWithNumberOrCapitalLetter" ,
61
+ this . commonBundle . message ( "common.cli.class.name" )
57
62
);
58
63
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
59
64
60
65
return false ;
61
66
}
62
67
63
68
if (cliCommandParentDirectory .length () == 0 ) {
64
- String errorMessage = validatorBundle .message ("validator.notEmpty" , "CLI Command Parent Directory" );
69
+ String errorMessage = validatorBundle .message (
70
+ "validator.notEmpty" ,
71
+ this .commonBundle .message ("common.cli.parent.directory" )
72
+ );
65
73
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
66
74
67
75
return false ;
68
76
}
69
77
if (!cliCommandParentDirectory .matches (RegExUtil .DIRECTORY )) {
70
78
String errorMessage = validatorBundle .message (
71
79
"validator.directory.isNotValid" ,
72
- "CLI Command Parent Directory"
80
+ this . commonBundle . message ( "common.cli.parent.directory" )
73
81
);
74
82
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
75
83
76
84
return false ;
77
85
}
78
86
79
87
if (cliCommandName .length () == 0 ) {
80
- String errorMessage = validatorBundle .message ("validator.notEmpty" , "CLI Command Name" );
88
+ String errorMessage = validatorBundle .message (
89
+ "validator.notEmpty" ,
90
+ this .commonBundle .message ("common.cli.cli.name" )
91
+ );
81
92
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
82
93
83
94
return false ;
84
95
}
85
96
if (!cliCommandName .matches (RegExUtil .CLI_COMMAND_NAME )) {
86
- String errorMessage = validatorBundle .message ("validator.identifier" , "CLI Command Name" );
97
+ String errorMessage = validatorBundle .message (
98
+ "validator.identifier" ,
99
+ this .commonBundle .message ("common.cli.cli.name" )
100
+ );
87
101
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
88
102
89
103
return false ;
90
104
}
91
105
92
106
if (cliCommandDescription .length () == 0 ) {
93
- String errorMessage = validatorBundle .message ("validator.notEmpty" , "CLI Command Description" );
107
+ String errorMessage = validatorBundle .message (
108
+ "validator.notEmpty" ,
109
+ this .commonBundle .message ("common.cli.cli.description" )
110
+ );
94
111
JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
95
112
96
113
return false ;
0 commit comments