Skip to content

Commit 019328f

Browse files
author
Vitaliy
authored
Merge pull request #456 from magento/epic-entity-manager
Initial implementation of entity manager (MVP)
2 parents c0bdfe4 + e4b19ea commit 019328f

File tree

9 files changed

+1717
-8
lines changed

9 files changed

+1717
-8
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
<!-- Module file generators -->
6060
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
61+
<action id="MagentoCreateEntity" class="com.magento.idea.magento2plugin.actions.generation.NewEntityAction" />
6162
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
6263
<action id="MagentoCreateAController" class="com.magento.idea.magento2plugin.actions.generation.NewControllerAction" />
6364
<action id="MagentoCreateACronjob" class="com.magento.idea.magento2plugin.actions.generation.NewCronjobAction" />
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation;
7+
8+
import com.intellij.ide.IdeView;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.CommonDataKeys;
12+
import com.intellij.openapi.actionSystem.DataContext;
13+
import com.intellij.openapi.actionSystem.LangDataKeys;
14+
import com.intellij.openapi.project.Project;
15+
import com.intellij.psi.PsiDirectory;
16+
import com.magento.idea.magento2plugin.MagentoIcons;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewEntityDialog;
18+
19+
public class NewEntityAction extends AnAction {
20+
public static final String ACTION_NAME = "Magento 2 Entity";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Entity";
22+
23+
/**
24+
* Constructor.
25+
*/
26+
public NewEntityAction() {
27+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
28+
}
29+
30+
@Override
31+
public void actionPerformed(final AnActionEvent event) {
32+
final DataContext dataContext = event.getDataContext();
33+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
34+
35+
if (view == null) {
36+
return;
37+
}
38+
39+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
40+
if (project == null) {
41+
return;
42+
}
43+
44+
final PsiDirectory directory = view.getOrChooseDirectory();
45+
if (directory == null) {
46+
return;
47+
}
48+
49+
NewEntityDialog.open(project, directory);
50+
}
51+
52+
@Override
53+
public boolean isDumbAware() {
54+
return false;
55+
}
56+
}

src/com/magento/idea/magento2plugin/actions/generation/data/DbSchemaXmlData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void setColumns(final List<Map<String, String>> columns) {
8787
* @return Map
8888
*/
8989
public Map<String, String> getTableAttributesMap() {
90-
final Map<String, String> tableAttributesData = new LinkedHashMap<>();
90+
final Map<String, String> tableAttributesData = new LinkedHashMap<>();//NOPMD
9191
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_NAME, getTableName());
9292
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_RESOURCE, getTableResource());
9393
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_ENGINE, getTableEngine());

src/com/magento/idea/magento2plugin/actions/generation/data/util/DbSchemaXmlSourceDataUtil.java

Whitespace-only changes.

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
2828
import com.magento.idea.magento2plugin.magento.files.DataModel;
2929
import com.magento.idea.magento2plugin.magento.files.DataModelInterface;
30+
import com.magento.idea.magento2plugin.magento.packages.PropertiesTypes;
3031
import com.magento.idea.magento2plugin.ui.table.ComboBoxEditor;
3132
import com.magento.idea.magento2plugin.ui.table.DeleteRowButton;
3233
import com.magento.idea.magento2plugin.ui.table.TableButton;
@@ -70,8 +71,6 @@ public class NewDataModelDialog extends AbstractDialog {
7071
private static final String PROPERTY_ACTION = "Action";
7172
private static final String PROPERTY_DELETE = "Delete";
7273

73-
private static final String[] PROPERTY_TYPES = {"int", "float", "string", "bool"};
74-
7574
private JPanel contentPanel;
7675
private JButton buttonOK;
7776
private JButton buttonCancel;
@@ -304,9 +303,10 @@ private void initPropertiesTable() {
304303

305304
addProperty.addActionListener(e -> {
306305
propertiesTable.addRow(new Object[]{
307-
"",
308-
PROPERTY_TYPES[0],
309-
PROPERTY_DELETE
306+
"",
307+
PropertiesTypes.valueOf(PropertiesTypes.INT.toString())
308+
.getPropertyType(),
309+
PROPERTY_DELETE
310310
});
311311
});
312312

@@ -315,8 +315,8 @@ private void initPropertiesTable() {
315315

316316
private void initPropertyTypeColumn() {
317317
final TableColumn formElementTypeColumn = propertyTable.getColumn(PROPERTY_TYPE);
318-
formElementTypeColumn.setCellEditor(new ComboBoxEditor(PROPERTY_TYPES));
319-
formElementTypeColumn.setCellRenderer(new ComboBoxTableRenderer<>(PROPERTY_TYPES));
318+
formElementTypeColumn.setCellEditor(new ComboBoxEditor(PropertiesTypes.getPropertyTypes()));
319+
formElementTypeColumn.setCellRenderer(new ComboBoxTableRenderer<>(PropertiesTypes.getPropertyTypes()));
320320
}
321321

322322
private DefaultTableModel getPropertiesTable() {

0 commit comments

Comments
 (0)