11
11
import com .intellij .psi .PsiFile ;
12
12
import com .intellij .util .indexing .FileBasedIndex ;
13
13
import com .magento .idea .magento2plugin .actions .generation .NewViewModelAction ;
14
+ import com .magento .idea .magento2plugin .actions .generation .OverrideClassByAPreferenceAction ;
14
15
import com .magento .idea .magento2plugin .actions .generation .data .AclXmlData ;
15
16
import com .magento .idea .magento2plugin .actions .generation .data .CollectionData ;
16
17
import com .magento .idea .magento2plugin .actions .generation .data .ControllerFileData ;
20
21
import com .magento .idea .magento2plugin .actions .generation .data .LayoutXmlData ;
21
22
import com .magento .idea .magento2plugin .actions .generation .data .MenuXmlData ;
22
23
import com .magento .idea .magento2plugin .actions .generation .data .ModelData ;
24
+ import com .magento .idea .magento2plugin .actions .generation .data .PreferenceDiXmFileData ;
23
25
import com .magento .idea .magento2plugin .actions .generation .data .ResourceModelData ;
24
26
import com .magento .idea .magento2plugin .actions .generation .data .RoutesXmlData ;
25
27
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentDataProviderData ;
42
44
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleControllerClassGenerator ;
43
45
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleModelGenerator ;
44
46
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleResourceModelGenerator ;
47
+ import com .magento .idea .magento2plugin .actions .generation .generator .PreferenceDiXmlGenerator ;
45
48
import com .magento .idea .magento2plugin .actions .generation .generator .RoutesXmlGenerator ;
46
49
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentDataProviderGenerator ;
47
50
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentFormGenerator ;
64
67
import com .magento .idea .magento2plugin .ui .FilteredComboBox ;
65
68
import com .magento .idea .magento2plugin .ui .table .TableGroupWrapper ;
66
69
import com .magento .idea .magento2plugin .util .FirstLetterToLowercaseUtil ;
70
+ import com .magento .idea .magento2plugin .util .GetPhpClassByFQN ;
67
71
import com .magento .idea .magento2plugin .util .magento .GetAclResourcesListUtil ;
68
72
import com .magento .idea .magento2plugin .util .magento .GetModuleNameByDirectoryUtil ;
69
73
import java .awt .event .ActionEvent ;
@@ -153,6 +157,7 @@ public class NewEntityDialog extends AbstractDialog {
153
157
private JLabel tableEngineLabel ;
154
158
private JComboBox tableResource ;
155
159
private JLabel tableResourceLabel ;
160
+ private JCheckBox createInterface ;
156
161
private final List <String > properties ;
157
162
private TableGroupWrapper entityPropertiesTableGroupWrapper ;
158
163
@@ -262,10 +267,13 @@ private void onOK() {
262
267
generateModelFile ();
263
268
generateResourceModelFile ();
264
269
generateCollectionFile ();
265
-
266
270
formatProperties ();
267
271
generateDataModelFile ();
268
- generateDataModelInterfaceFile ();
272
+
273
+ if (createInterface .isSelected ()) {
274
+ generateDataModelInterfaceFile ();
275
+ generateDataModelPreference ();
276
+ }
269
277
270
278
generateRoutesXmlFile ();
271
279
generateViewControllerFile ();
@@ -274,7 +282,6 @@ private void onOK() {
274
282
generateLayoutFile ();
275
283
generateFormFile ();
276
284
generateAclXmlFile ();
277
-
278
285
generateGridViewControllerFile ();
279
286
generateGridLayoutFile ();
280
287
generateMenuFile ();
@@ -290,6 +297,7 @@ private void onOK() {
290
297
291
298
generateDbSchemaXmlFile (dbSchemaXmlData );
292
299
generateWhitelistJsonFile (dbSchemaXmlData );
300
+ this .setVisible (false );
293
301
}
294
302
295
303
private PsiFile generateModelFile () {
@@ -333,6 +341,23 @@ private NamespaceBuilder getResourceModelNamespace() {
333
341
);
334
342
}
335
343
344
+ /**
345
+ * Generate preference for data model.
346
+ */
347
+ private void generateDataModelPreference () {
348
+ final NamespaceBuilder modelNamespace = getModelNamespace ();
349
+ final NamespaceBuilder modelInterfaceNamespace = getDataModelInterfaceNamespace ();
350
+ new PreferenceDiXmlGenerator (new PreferenceDiXmFileData (
351
+ getModuleName (),
352
+ GetPhpClassByFQN .getInstance (project ).execute (
353
+ modelInterfaceNamespace .getClassFqn ()
354
+ ),
355
+ modelNamespace .getClassFqn (),
356
+ getModelName (),
357
+ Areas .base .toString ()
358
+ ), project ).generate (OverrideClassByAPreferenceAction .ACTION_NAME );
359
+ }
360
+
336
361
private String getModuleName () {
337
362
return moduleName ;
338
363
}
@@ -410,6 +435,9 @@ private PsiFile generateCollectionFile() {
410
435
), project ).generate (ACTION_NAME , true );
411
436
}
412
437
438
+ /**
439
+ * Generate Data Model File.
440
+ */
413
441
private void generateDataModelFile () {
414
442
final NamespaceBuilder nameSpaceBuilder = getDataModelNamespace ();
415
443
new DataModelGenerator (project , new DataModelData (
@@ -418,7 +446,8 @@ private void generateDataModelFile() {
418
446
getModuleName (),
419
447
nameSpaceBuilder .getClassFqn (),
420
448
getDataModelInterfaceNamespace ().getClassFqn (),
421
- getProperties ()
449
+ getProperties (),
450
+ createInterface .isSelected ()
422
451
)).generate (ACTION_NAME , true );
423
452
}
424
453
0 commit comments