77import com .intellij .openapi .project .Project ;
88import com .magento .idea .magento2plugin .actions .generation .dialog .NewCLICommandDialog ;
99import com .magento .idea .magento2plugin .bundles .ValidatorBundle ;
10- import com .magento .idea .magento2plugin .util . GetPhpClassByFQN ;
10+ import com .magento .idea .magento2plugin .bundles . CommonBundle ;
1111import com .magento .idea .magento2plugin .util .RegExUtil ;
1212
1313import javax .swing .*;
1414
1515public class NewCLICommandValidator {
1616 private static NewCLICommandValidator INSTANCE = null ;
17- private ValidatorBundle validatorBundle ;
17+ private final ValidatorBundle validatorBundle ;
18+ private final CommonBundle commonBundle ;
1819
1920 public static NewCLICommandValidator getInstance () {
2021 if (null == INSTANCE ) {
@@ -26,6 +27,7 @@ public static NewCLICommandValidator getInstance() {
2627
2728 public NewCLICommandValidator () {
2829 this .validatorBundle = new ValidatorBundle ();
30+ this .commonBundle = new CommonBundle ();
2931 }
3032
3133 public boolean validate (Project project , NewCLICommandDialog dialog ) {
@@ -36,61 +38,76 @@ public boolean validate(Project project, NewCLICommandDialog dialog) {
3638 String cliCommandDescription = dialog .getCLICommandDescription ();
3739
3840 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+ );
4045 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
4146
4247 return false ;
4348 }
4449 if (!cliCommandClassName .matches (RegExUtil .ALPHANUMERIC )) {
4550 String errorMessage = validatorBundle .message (
46- "validator.alphaNumericCharacters" ,
47- "CLI Command Class Name"
51+ "validator.alphaNumericCharacters" ,
52+ this . commonBundle . message ( "common.cli.class.name" )
4853 );
4954 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
5055
5156 return false ;
5257 }
5358 if (!Character .isUpperCase (cliCommandClassName .charAt (0 )) && !Character .isDigit (cliCommandClassName .charAt (0 ))) {
5459 String errorMessage = validatorBundle .message (
55- "validator.startWithNumberOrCapitalLetter" ,
56- "CLI Command Class Name"
60+ "validator.startWithNumberOrCapitalLetter" ,
61+ this . commonBundle . message ( "common.cli.class.name" )
5762 );
5863 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
5964
6065 return false ;
6166 }
6267
6368 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+ );
6573 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
6674
6775 return false ;
6876 }
6977 if (!cliCommandParentDirectory .matches (RegExUtil .DIRECTORY )) {
7078 String errorMessage = validatorBundle .message (
7179 "validator.directory.isNotValid" ,
72- "CLI Command Parent Directory"
80+ this . commonBundle . message ( "common.cli.parent.directory" )
7381 );
7482 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
7583
7684 return false ;
7785 }
7886
7987 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+ );
8192 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
8293
8394 return false ;
8495 }
8596 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+ );
87101 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
88102
89103 return false ;
90104 }
91105
92106 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+ );
94111 JOptionPane .showMessageDialog (null , errorMessage , errorTitle , JOptionPane .ERROR_MESSAGE );
95112
96113 return false ;
0 commit comments