|
12 | 12 | import com.magento.idea.magento2plugin.actions.generation.data.ModuleComposerJsonData; |
13 | 13 | import com.magento.idea.magento2plugin.actions.generation.data.ModuleRegistrationPhpData; |
14 | 14 | import com.magento.idea.magento2plugin.actions.generation.data.ModuleXmlData; |
| 15 | +import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation; |
| 16 | +import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry; |
| 17 | +import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.AlphanumericRule; |
| 18 | +import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule; |
| 19 | +import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.StartWithNumberOrCapitalLetterRule; |
15 | 20 | import com.magento.idea.magento2plugin.actions.generation.generator.ModuleComposerJsonGenerator; |
16 | 21 | import com.magento.idea.magento2plugin.actions.generation.generator.ModuleRegistrationPhpGenerator; |
17 | 22 | import com.magento.idea.magento2plugin.actions.generation.generator.ModuleXmlGenerator; |
|
44 | 49 |
|
45 | 50 | @SuppressWarnings({"PMD.TooManyFields", "PMD.DataClass", "PMD.UnusedPrivateMethod"}) |
46 | 51 | public class NewModuleDialog extends AbstractDialog implements ListSelectionListener { //NOPMD |
47 | | - @NotNull |
48 | | - private final Project project; |
49 | | - @NotNull |
50 | | - private final PsiDirectory initialBaseDir; |
51 | | - private final CamelCaseToHyphen camelCaseToHyphen; |
52 | | - private JPanel contentPane; |
53 | | - private JButton buttonOK; |
54 | | - private JButton buttonCancel; |
| 52 | + private static final String MODULE_DESCRIPTION = "module description"; |
| 53 | + private static final String MODULE_VERSION = "module version"; |
| 54 | + private static final String MODULE_NAME = "module name"; |
| 55 | + private static final String PACKAGE_NAME = "package name"; |
| 56 | + |
| 57 | + @FieldValidation(rule = RuleRegistry.ALPHANUMERIC, |
| 58 | + message = {AlphanumericRule.MESSAGE, MODULE_NAME}) |
| 59 | + @FieldValidation(rule = RuleRegistry.START_WITH_NUMBER_OR_CAPITAL_LETTER, |
| 60 | + message = {StartWithNumberOrCapitalLetterRule.MESSAGE, PACKAGE_NAME}) |
| 61 | + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, |
| 62 | + message = {NotEmptyRule.MESSAGE, PACKAGE_NAME}) |
55 | 63 | private JTextField packageName; |
56 | | - private JLabel packageNameLabel; |
| 64 | + |
| 65 | + |
| 66 | + /* TODO: module name !== package name */ |
| 67 | + @FieldValidation(rule = RuleRegistry.ALPHANUMERIC, |
| 68 | + message = {AlphanumericRule.MESSAGE, MODULE_NAME}) |
| 69 | + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, |
| 70 | + message = {NotEmptyRule.MESSAGE, MODULE_NAME}) |
| 71 | + @FieldValidation(rule = RuleRegistry.START_WITH_NUMBER_OR_CAPITAL_LETTER, |
| 72 | + message = {StartWithNumberOrCapitalLetterRule.MESSAGE, MODULE_NAME}) |
57 | 73 | private JTextField moduleName; |
| 74 | + |
| 75 | + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, |
| 76 | + message = {NotEmptyRule.MESSAGE, MODULE_DESCRIPTION}) |
58 | 77 | private JTextArea moduleDescription; |
59 | | - private final ModuleIndex moduleIndex; |
| 78 | + |
| 79 | + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, |
| 80 | + message = {NotEmptyRule.MESSAGE, MODULE_VERSION}) |
60 | 81 | private JTextField moduleVersion; |
61 | | - private String detectedPackageName; |
| 82 | + |
| 83 | + private JTextField moduleLicenseCustom; |
| 84 | + |
62 | 85 | private JList moduleDependencies; |
63 | 86 | private JList moduleLicense; |
64 | | - private JTextField moduleLicenseCustom; |
65 | | - private JLabel moduleLicenseLabel;//NOPMD |
| 87 | + |
66 | 88 | private JScrollPane moduleLicenseScrollPanel;//NOPMD |
| 89 | + private JScrollPane moduleDependenciesScrollPanel;//NOPMD |
| 90 | + |
| 91 | + private JLabel moduleLicenseLabel;//NOPMD |
67 | 92 | private JLabel moduleVersionLabel;//NOPMD |
68 | 93 | private JLabel moduleDependenciesLabel;//NOPMD |
69 | | - private JScrollPane moduleDependenciesScrollPanel;//NOPMD |
70 | 94 | private JLabel moduleDescriptionLabel;//NOPMD |
71 | 95 | private JLabel moduleNameLabel;//NOPMD |
| 96 | + private JLabel packageNameLabel; |
72 | 97 |
|
| 98 | + private JPanel contentPane; |
| 99 | + |
| 100 | + private JButton buttonOK; |
| 101 | + private JButton buttonCancel; |
| 102 | + |
| 103 | + @NotNull |
| 104 | + private final Project project; |
| 105 | + @NotNull |
| 106 | + private final PsiDirectory initialBaseDir; |
| 107 | + private String detectedPackageName; |
| 108 | + private final ModuleIndex moduleIndex; |
| 109 | + private final CamelCaseToHyphen camelCaseToHyphen; |
73 | 110 | private static final String MAGENTO_BEFORE_DECLARATIVE_SCHEMA_VERSION = "2.2.11"; |
74 | 111 |
|
75 | 112 | /** |
|
0 commit comments