Skip to content

Commit ef47c50

Browse files
committed
Use common bundle for the NewCLICommandValidator
1 parent 6a1ab92 commit ef47c50

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

resources/magento2/common.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ common.classInheritance=Inherit Class
2828
common.license.proprietary=Proprietary
2929
common.description=Description
3030
common.cli.class.name=Class Name
31-
common.cli.cli.description=CLI Description
32-
common.cli.cli.name=CLI Name
3331
common.cli.parent.directory=Parent Directory
32+
common.cli.cli.description=CLI Command Description
33+
common.cli.cli.name=CLI Command Name
3434
common.cli.create.new.cli.command.title=Create a new Magento 2 CLI Command
3535
common.cli.generate.error=New CLI Command Generation Error
3636
common.cli.class.title=CLI Command Class

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewCLICommandDialog.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.magento.idea.magento2plugin.actions.generation.generator.util.NamespaceBuilder;
1414
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
1515

16-
1716
import javax.swing.*;
1817
import java.awt.event.*;
1918

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewCLICommandValidator.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import com.intellij.openapi.project.Project;
88
import com.magento.idea.magento2plugin.actions.generation.dialog.NewCLICommandDialog;
99
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
10-
import com.magento.idea.magento2plugin.util.GetPhpClassByFQN;
10+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
1111
import com.magento.idea.magento2plugin.util.RegExUtil;
1212

1313
import javax.swing.*;
1414

1515
public 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

Comments
 (0)