Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

<!-- Module file generators -->
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
<action id="MagentoCreateEntity" class="com.magento.idea.magento2plugin.actions.generation.NewEntityAction" />
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
<action id="MagentoCreateAController" class="com.magento.idea.magento2plugin.actions.generation.NewControllerAction" />
<action id="MagentoCreateACronjob" class="com.magento.idea.magento2plugin.actions.generation.NewCronjobAction" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

package com.magento.idea.magento2plugin.actions.generation;

import com.intellij.ide.IdeView;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.generation.dialog.NewEntityDialog;

public class NewEntityAction extends AnAction {
public static final String ACTION_NAME = "Magento 2 Entity";
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Entity";

/**
* Constructor.
*/
public NewEntityAction() {
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
}

@Override
public void actionPerformed(final AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);

if (view == null) {
return;
}

final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}

final PsiDirectory directory = view.getOrChooseDirectory();
if (directory == null) {
return;
}

NewEntityDialog.open(project, directory);
}

@Override
public boolean isDumbAware() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void setColumns(final List<Map<String, String>> columns) {
* @return Map
*/
public Map<String, String> getTableAttributesMap() {
final Map<String, String> tableAttributesData = new LinkedHashMap<>();
final Map<String, String> tableAttributesData = new LinkedHashMap<>();//NOPMD
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_NAME, getTableName());
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_RESOURCE, getTableResource());
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_ENGINE, getTableEngine());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
import com.magento.idea.magento2plugin.magento.files.DataModel;
import com.magento.idea.magento2plugin.magento.files.DataModelInterface;
import com.magento.idea.magento2plugin.magento.packages.PropertiesTypes;
import com.magento.idea.magento2plugin.ui.table.ComboBoxEditor;
import com.magento.idea.magento2plugin.ui.table.DeleteRowButton;
import com.magento.idea.magento2plugin.ui.table.TableButton;
Expand Down Expand Up @@ -70,8 +71,6 @@ public class NewDataModelDialog extends AbstractDialog {
private static final String PROPERTY_ACTION = "Action";
private static final String PROPERTY_DELETE = "Delete";

private static final String[] PROPERTY_TYPES = {"int", "float", "string", "bool"};

private JPanel contentPanel;
private JButton buttonOK;
private JButton buttonCancel;
Expand Down Expand Up @@ -304,9 +303,10 @@ private void initPropertiesTable() {

addProperty.addActionListener(e -> {
propertiesTable.addRow(new Object[]{
"",
PROPERTY_TYPES[0],
PROPERTY_DELETE
"",
PropertiesTypes.valueOf(PropertiesTypes.INT.toString())
.getPropertyType(),
PROPERTY_DELETE
});
});

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

private void initPropertyTypeColumn() {
final TableColumn formElementTypeColumn = propertyTable.getColumn(PROPERTY_TYPE);
formElementTypeColumn.setCellEditor(new ComboBoxEditor(PROPERTY_TYPES));
formElementTypeColumn.setCellRenderer(new ComboBoxTableRenderer<>(PROPERTY_TYPES));
formElementTypeColumn.setCellEditor(new ComboBoxEditor(PropertiesTypes.getPropertyTypes()));
formElementTypeColumn.setCellRenderer(new ComboBoxTableRenderer<>(PropertiesTypes.getPropertyTypes()));
}

private DefaultTableModel getPropertiesTable() {
Expand Down
Loading