37
37
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentGridToolbarData ;
38
38
import com .magento .idea .magento2plugin .actions .generation .data .code .ClassPropertyData ;
39
39
import com .magento .idea .magento2plugin .actions .generation .data .ui .ComboBoxItemData ;
40
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .FieldValidation ;
41
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .RuleRegistry ;
42
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .AclResourceIdRule ;
43
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .IdentifierRule ;
44
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .MenuIdentifierRule ;
45
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .NotEmptyRule ;
46
+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .NumericRule ;
40
47
import com .magento .idea .magento2plugin .actions .generation .generator .AclXmlGenerator ;
41
48
import com .magento .idea .magento2plugin .actions .generation .generator .DataModelGenerator ;
42
49
import com .magento .idea .magento2plugin .actions .generation .generator .DataModelInterfaceGenerator ;
103
110
import javax .swing .JTabbedPane ;
104
111
import javax .swing .JTable ;
105
112
import javax .swing .JTextField ;
113
+ import javax .swing .JTextPane ;
106
114
import javax .swing .KeyStroke ;
107
115
import javax .swing .table .DefaultTableModel ;
108
116
import org .apache .commons .lang .StringUtils ;
@@ -140,25 +148,18 @@ public class NewEntityDialog extends AbstractDialog {
140
148
private JLabel entityIdColumnNameLabel ;
141
149
private JTextField route ;
142
150
private JLabel routeLabel ;
143
- private JTextField acl ;
144
151
private JLabel aclLabel ;
145
152
private JTextField aclTitle ;
146
153
private FilteredComboBox parentAcl ;
147
- private JLabel formNameLabel ;
148
- private JTextField formName ;
149
154
private JTextField formLabel ;
150
155
private JLabel formLabelLabel ;
151
- private JTextField gridName ;
152
156
private JLabel gridNameLabel ;
153
157
private JLabel parentMenuItemLabel ;
154
158
private JLabel sortOrderLabel ;
155
159
private JLabel menuIdentifierLabel ;
156
- private JTextField sortOrder ;
157
- private JTextField menuIdentifier ;
158
160
private JLabel menuTitleLabel ;
159
161
private JTextField menuTitle ;
160
162
private FilteredComboBox parentMenu ;
161
- private JLabel formMenuLabel ;
162
163
private JCheckBox addToolBar ;
163
164
private JCheckBox addBookmarksCheckBox ;
164
165
private JCheckBox addColumnsControlCheckBox ;
@@ -176,7 +177,36 @@ public class NewEntityDialog extends AbstractDialog {
176
177
private static final String ACTION_NAME = "Create Entity" ;
177
178
private static final String PROPERTY_NAME = "Name" ;
178
179
private static final String PROPERTY_TYPE = "Type" ;
180
+ private static final String ACL_ID = "ACL ID" ;
181
+ private static final String FORM_NAME = "Form Name" ;
182
+ private static final String GRID_NAME = "Grit Name" ;
183
+ private static final String IDENTIFIER = "Identifier" ;
184
+ private static final String SORT_ORDER = "Sort Order" ;
185
+
186
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY , message = {NotEmptyRule .MESSAGE , FORM_NAME })
187
+ @ FieldValidation (rule = RuleRegistry .IDENTIFIER , message = {IdentifierRule .MESSAGE })
188
+ private JTextField formName ;
189
+
190
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY , message = {NotEmptyRule .MESSAGE , GRID_NAME })
191
+ @ FieldValidation (rule = RuleRegistry .IDENTIFIER , message = {IdentifierRule .MESSAGE })
192
+ private JTextField gridName ;
179
193
194
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY , message = {NotEmptyRule .MESSAGE , ACL_ID })
195
+ @ FieldValidation (rule = RuleRegistry .ACL_RESOURCE_ID , message = {AclResourceIdRule .MESSAGE })
196
+ private JTextField acl ;
197
+
198
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY , message = {NotEmptyRule .MESSAGE , SORT_ORDER })
199
+ @ FieldValidation (rule = RuleRegistry .NUMERIC , message = {NumericRule .MESSAGE })
200
+ private JTextField sortOrder ;
201
+
202
+ @ FieldValidation (rule = RuleRegistry .NOT_EMPTY , message = {NotEmptyRule .MESSAGE , IDENTIFIER })
203
+ @ FieldValidation (rule = RuleRegistry .MENU_IDENTIFIER , message = {MenuIdentifierRule .MESSAGE })
204
+ private JTextField menuIdentifier ;
205
+ private JLabel formNameLabel ;
206
+ private JTextPane exampleIdentifier ;
207
+ private JTextPane exampleAclId ;
208
+ private JTextPane exampleFormName ;
209
+ private JTextPane exampleGridName ;
180
210
private JTextField observerName ;
181
211
182
212
/**
@@ -276,6 +306,10 @@ private DefaultTableModel getPropertiesTable() {
276
306
* Perform code generation using input data.
277
307
*/
278
308
private void onOK () {
309
+ if (!validateFormFields ()) {
310
+ return ;
311
+ }
312
+
279
313
generateModelFile ();
280
314
generateResourceModelFile ();
281
315
generateCollectionFile ();
0 commit comments