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 ;
40
45
public class CreateAnObserverDialog extends AbstractDialog {
41
46
@ NotNull
42
47
private final Project project ;
43
- @ NotNull
44
- private final CreateAnObserverDialogValidator validator ;
45
48
private final String targetEvent ;
46
49
private JPanel contentPane ;
47
50
private JButton buttonOK ;
48
51
private JButton buttonCancel ;
49
- private JTextField observerClassName ;
50
- private JTextField observerDirectory ;
51
- private FilteredComboBox observerModule ;
52
52
private JComboBox observerArea ;
53
- private JTextField observerName ;
54
53
private JLabel observerClassNameLabel ;
55
54
private JLabel observerDirectoryName ;
56
55
private JLabel selectObserverModule ;
57
56
private JLabel observerAreaLabel ;
58
57
private JLabel observerNameLabel ;
58
+ private static final String OBSERVER_MODULE = "target module" ;
59
+ private static final String OBSERVER_CLASS = "class name" ;
60
+ private static final String OBSERVER_DIRECTORY = "directory" ;
61
+ private static final String OBSERVER_NAME = "name" ;
62
+
63
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
64
+ message = {NotEmptyRule .MESSAGE , OBSERVER_MODULE })
65
+ private FilteredComboBox observerModule ;
66
+
67
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
68
+ message = {NotEmptyRule .MESSAGE , OBSERVER_CLASS })
69
+ @ FieldValidation (rule = RuleRegistry .PHP_CLASS ,
70
+ message = {PhpClassRule .MESSAGE , OBSERVER_CLASS })
71
+ private JTextField observerClassName ;
72
+
73
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
74
+ message = {NotEmptyRule .MESSAGE , OBSERVER_DIRECTORY })
75
+ @ FieldValidation (rule = RuleRegistry .DIRECTORY ,
76
+ message = {DirectoryRule .MESSAGE , OBSERVER_DIRECTORY })
77
+ private JTextField observerDirectory ;
78
+
79
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
80
+ message = {NotEmptyRule .MESSAGE , OBSERVER_NAME })
81
+ @ FieldValidation (rule = RuleRegistry .ALPHANUMERIC_WITH_UNDERSCORE ,
82
+ message = {AlphanumericWithUnderscoreRule .MESSAGE , OBSERVER_NAME })
83
+ private JTextField observerName ;
59
84
60
85
/**
61
86
* Constructor.
@@ -68,7 +93,6 @@ public CreateAnObserverDialog(@NotNull final Project project, final String targe
68
93
69
94
this .project = project ;
70
95
this .targetEvent = targetEvent ;
71
- this .validator = CreateAnObserverDialogValidator .getInstance (this );
72
96
73
97
setContentPane (contentPane );
74
98
setModal (true );
@@ -119,7 +143,7 @@ private void fillTargetAreaOptions() {
119
143
* Perform code generation using input data.
120
144
*/
121
145
private void onOK () {
122
- if (!validator . validate ( project )) {
146
+ if (!validateFormFields ( )) {
123
147
return ;
124
148
}
125
149
new ObserverClassGenerator (new ObserverFileData (
0 commit comments