|
10 | 10 | import com.intellij.openapi.ui.ComboBoxTableRenderer; |
11 | 11 | import com.intellij.psi.PsiDirectory; |
12 | 12 | import com.intellij.psi.PsiFile; |
| 13 | +import com.magento.idea.magento2plugin.actions.generation.NewDbSchemaAction; |
13 | 14 | import com.magento.idea.magento2plugin.actions.generation.NewUiComponentGridAction; |
14 | 15 | import com.magento.idea.magento2plugin.actions.generation.NewViewModelAction; |
15 | 16 | import java.awt.event.ActionEvent; |
|
18 | 19 | import java.awt.event.WindowEvent; |
19 | 20 | import java.util.ArrayList; |
20 | 21 | import java.util.List; |
| 22 | +import java.util.Map; |
21 | 23 | import javax.swing.*; |
22 | 24 | import javax.swing.table.DefaultTableModel; |
23 | 25 | import javax.swing.table.TableColumn; |
|
27 | 29 | import com.magento.idea.magento2plugin.actions.generation.data.ControllerFileData; |
28 | 30 | import com.magento.idea.magento2plugin.actions.generation.data.DataModelData; |
29 | 31 | import com.magento.idea.magento2plugin.actions.generation.data.DataModelInterfaceData; |
| 32 | +import com.magento.idea.magento2plugin.actions.generation.data.DbSchemaXmlData; |
30 | 33 | import com.magento.idea.magento2plugin.actions.generation.data.LayoutXmlData; |
31 | 34 | import com.magento.idea.magento2plugin.actions.generation.data.MenuXmlData; |
32 | 35 | import com.magento.idea.magento2plugin.actions.generation.data.ModelData; |
|
43 | 46 | import com.magento.idea.magento2plugin.actions.generation.generator.AclXmlGenerator; |
44 | 47 | import com.magento.idea.magento2plugin.actions.generation.generator.DataModelGenerator; |
45 | 48 | import com.magento.idea.magento2plugin.actions.generation.generator.DataModelInterfaceGenerator; |
| 49 | +import com.magento.idea.magento2plugin.actions.generation.generator.DbSchemaXmlGenerator; |
46 | 50 | import com.magento.idea.magento2plugin.actions.generation.generator.LayoutXmlGenerator; |
47 | 51 | import com.magento.idea.magento2plugin.actions.generation.generator.MenuXmlGenerator; |
48 | 52 | import com.magento.idea.magento2plugin.actions.generation.generator.ModuleCollectionGenerator; |
|
68 | 72 | import com.magento.idea.magento2plugin.ui.table.ComboBoxEditor; |
69 | 73 | import com.magento.idea.magento2plugin.ui.table.DeleteRowButton; |
70 | 74 | import com.magento.idea.magento2plugin.ui.table.TableButton; |
| 75 | +import com.magento.idea.magento2plugin.ui.table.TableGroupWrapper; |
71 | 76 | import com.magento.idea.magento2plugin.util.FirstLetterToLowercaseUtil; |
72 | 77 | import com.magento.idea.magento2plugin.util.magento.GetAclResourcesListUtil; |
73 | 78 | import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil; |
@@ -128,7 +133,13 @@ public class NewEntityDialog extends AbstractDialog { |
128 | 133 | private JCheckBox addFullTextSearchCheckBox; |
129 | 134 | private JCheckBox addListingFiltersCheckBox; |
130 | 135 | private JCheckBox addListingPagingCheckBox; |
| 136 | + private JComboBox tableEngine; |
| 137 | + private JLabel tableEngineLabel; |
| 138 | + private JComboBox tableResource; |
| 139 | + private JLabel tableResourceLabel; |
131 | 140 | private final List<String> properties; |
| 141 | + // Table Columns UI components group |
| 142 | + private TableGroupWrapper columnsTableGroupWrapper; |
132 | 143 |
|
133 | 144 | private static final String ACTION_NAME = "Create Entity"; |
134 | 145 | private static final String PROPERTY_NAME = "Name"; |
@@ -252,6 +263,8 @@ private void onOK() { |
252 | 263 | generateGridLayoutFile(); |
253 | 264 | generateMenuFile(); |
254 | 265 | generateUiComponentGridFile(); |
| 266 | + |
| 267 | + generateDbSchemaXmlFile(); |
255 | 268 | } |
256 | 269 |
|
257 | 270 | private PsiFile generateModelFile() { |
@@ -811,7 +824,7 @@ private void generateUiComponentGridFile() { |
811 | 824 | getUiComponentGridData(), |
812 | 825 | project |
813 | 826 | ); |
814 | | - gridXmlGenerator.generate(NewUiComponentGridAction.ACTION_NAME, true); |
| 827 | + gridXmlGenerator.generate(ACTION_NAME, true); |
815 | 828 | } |
816 | 829 |
|
817 | 830 | /** |
@@ -870,4 +883,48 @@ private Boolean getAddListingPagingCheckBox() { |
870 | 883 | private Boolean getAddBookmarksCheckBox() { |
871 | 884 | return addBookmarksCheckBox.isSelected(); |
872 | 885 | } |
| 886 | + |
| 887 | + /** |
| 888 | + * Run db_schema.xml file generator. |
| 889 | + */ |
| 890 | + private void generateDbSchemaXmlFile() { |
| 891 | + new DbSchemaXmlGenerator( |
| 892 | + new DbSchemaXmlData( |
| 893 | + getDbTableName(), |
| 894 | + getTableResource(), |
| 895 | + getTableEngine(), |
| 896 | + getEntityName(), |
| 897 | + getColumns() |
| 898 | + ), |
| 899 | + project, |
| 900 | + moduleName |
| 901 | + ).generate(ACTION_NAME, false); |
| 902 | + } |
| 903 | + |
| 904 | + /** |
| 905 | + * Get tableResource field value. |
| 906 | + * |
| 907 | + * @return String |
| 908 | + */ |
| 909 | + private String getTableResource() { |
| 910 | + return tableResource.getSelectedItem().toString().trim(); |
| 911 | + } |
| 912 | + |
| 913 | + /** |
| 914 | + * Get tableEngine field value. |
| 915 | + * |
| 916 | + * @return String |
| 917 | + */ |
| 918 | + private String getTableEngine() { |
| 919 | + return tableEngine.getSelectedItem().toString().trim(); |
| 920 | + } |
| 921 | + |
| 922 | + /** |
| 923 | + * Get columnsTable values. |
| 924 | + * |
| 925 | + * @return List |
| 926 | + */ |
| 927 | + private List<Map<String, String>> getColumns() { |
| 928 | + return columnsTableGroupWrapper.getColumnsData(); |
| 929 | + } |
873 | 930 | } |
0 commit comments