10
10
import com .magento .idea .magento2plugin .actions .generation .CreateAnObserverAction ;
11
11
import com .magento .idea .magento2plugin .actions .generation .data .ObserverEventsXmlData ;
12
12
import com .magento .idea .magento2plugin .actions .generation .data .ObserverFileData ;
13
- import com .magento .idea .magento2plugin .actions .generation .dialog .validator .CreateAnObserverDialogValidator ;
13
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .FieldValidation ;
14
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .RuleRegistry ;
15
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .AlphanumericWithUnderscoreRule ;
16
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .DirectoryRule ;
17
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .NotEmptyRule ;
18
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .PhpClassRule ;
14
19
import com .magento .idea .magento2plugin .actions .generation .generator .ObserverClassGenerator ;
15
20
import com .magento .idea .magento2plugin .actions .generation .generator .ObserverEventsXmlGenerator ;
16
21
import com .magento .idea .magento2plugin .indexes .ModuleIndex ;
36
41
"PMD.MissingSerialVersionUID" ,
37
42
"PMD.DataClass" ,
38
43
"PMD.UnusedPrivateField" ,
44
+ "PMD.ExcessiveImports" ,
39
45
})
40
46
public class CreateAnObserverDialog extends AbstractDialog {
41
47
@ NotNull
42
48
private final Project project ;
43
- @ NotNull
44
- private final CreateAnObserverDialogValidator validator ;
45
49
private final String targetEvent ;
46
50
private JPanel contentPane ;
47
51
private JButton buttonOK ;
48
52
private JButton buttonCancel ;
49
- private JTextField observerClassName ;
50
- private JTextField observerDirectory ;
51
- private FilteredComboBox observerModule ;
52
53
private JComboBox observerArea ;
53
- private JTextField observerName ;
54
54
private JLabel observerClassNameLabel ;
55
55
private JLabel observerDirectoryName ;
56
56
private JLabel selectObserverModule ;
57
57
private JLabel observerAreaLabel ;
58
58
private JLabel observerNameLabel ;
59
+ private static final String OBSERVER_MODULE = "target module" ;
60
+ private static final String OBSERVER_CLASS = "class name" ;
61
+ private static final String OBSERVER_DIRECTORY = "directory" ;
62
+ private static final String OBSERVER_NAME = "name" ;
63
+
64
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
65
+ message = {NotEmptyRule .MESSAGE , OBSERVER_MODULE })
66
+ private FilteredComboBox observerModule ;
67
+
68
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
69
+ message = {NotEmptyRule .MESSAGE , OBSERVER_CLASS })
70
+ @ FieldValidation (rule = RuleRegistry .PHP_CLASS ,
71
+ message = {PhpClassRule .MESSAGE , OBSERVER_CLASS })
72
+ private JTextField observerClassName ;
73
+
74
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
75
+ message = {NotEmptyRule .MESSAGE , OBSERVER_DIRECTORY })
76
+ @ FieldValidation (rule = RuleRegistry .DIRECTORY ,
77
+ message = {DirectoryRule .MESSAGE , OBSERVER_DIRECTORY })
78
+ private JTextField observerDirectory ;
79
+
80
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
81
+ message = {NotEmptyRule .MESSAGE , OBSERVER_NAME })
82
+ @ FieldValidation (rule = RuleRegistry .ALPHANUMERIC_WITH_UNDERSCORE ,
83
+ message = {AlphanumericWithUnderscoreRule .MESSAGE , OBSERVER_NAME })
84
+ private JTextField observerName ;
59
85
60
86
/**
61
87
* Constructor.
@@ -68,7 +94,6 @@ public CreateAnObserverDialog(@NotNull final Project project, final String targe
68
94
69
95
this .project = project ;
70
96
this .targetEvent = targetEvent ;
71
- this .validator = CreateAnObserverDialogValidator .getInstance (this );
72
97
73
98
setContentPane (contentPane );
74
99
setModal (true );
@@ -119,7 +144,7 @@ private void fillTargetAreaOptions() {
119
144
* Perform code generation using input data.
120
145
*/
121
146
private void onOK () {
122
- if (!validator . validate ( project )) {
147
+ if (!validateFormFields ( )) {
123
148
return ;
124
149
}
125
150
new ObserverClassGenerator (new ObserverFileData (
0 commit comments