diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewEmailTemplateAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewEmailTemplateAction.java
index 78a99904b..ca7007625 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/NewEmailTemplateAction.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/NewEmailTemplateAction.java
@@ -16,8 +16,8 @@
import com.magento.idea.magento2plugin.MagentoIcons;
import com.magento.idea.magento2plugin.actions.generation.dialog.NewEmailTemplateDialog;
-@SuppressWarnings({"PMD.OnlyOneReturn", "PMD.FieldNamingConventions"})
public class NewEmailTemplateAction extends AnAction {
+
public static final String ACTION_NAME = "Magento 2 Email Template";
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 email template";
@@ -36,17 +36,16 @@ public void actionPerformed(final AnActionEvent event) {
if (view == null) {
return;
}
-
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
+
if (project == null) {
return;
}
-
final PsiDirectory directory = view.getOrChooseDirectory();
+
if (directory == null) {
return;
}
-
NewEmailTemplateDialog.open(project, directory);
}
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewModelsAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewModelsAction.java
index e9034f882..1567d41eb 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/NewModelsAction.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/NewModelsAction.java
@@ -17,6 +17,7 @@
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModelsDialog;
public class NewModelsAction extends AnAction {
+
public static final String ACTION_NAME = "Magento 2 Models";
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 models";
@@ -35,17 +36,16 @@ public void actionPerformed(final AnActionEvent event) {
if (view == null) {
return;
}
-
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
+
if (project == null) {
return;
}
-
final PsiDirectory directory = view.getOrChooseDirectory();
+
if (directory == null) {
return;
}
-
NewModelsDialog.open(project, directory);
}
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.form
index 1c074587b..411ec0e9d 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.form
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.form
@@ -3,9 +3,11 @@
-
+
-
+
+
+
@@ -49,7 +51,7 @@
-
+
@@ -75,7 +77,7 @@
-
+
@@ -83,7 +85,7 @@
-
+
@@ -91,7 +93,7 @@
-
+
@@ -99,7 +101,7 @@
-
+
@@ -107,7 +109,7 @@
-
+
@@ -115,7 +117,7 @@
-
+
@@ -123,7 +125,7 @@
-
+
@@ -134,7 +136,7 @@
-
+
@@ -145,7 +147,7 @@
-
+
@@ -153,12 +155,36 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java
index 2ee468ebf..461f3588f 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java
@@ -21,8 +21,6 @@
import com.magento.idea.magento2plugin.magento.packages.Areas;
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -31,37 +29,48 @@
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComponent;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
public class NewEmailTemplateDialog extends AbstractDialog {
- private final String moduleName;
- private final Project project;
- private final NewEmailTemplateDialogValidator validator;
+
private static final String EMAIL_TEMPLATE_ID = "id";
private static final String LABEL = "label";
private static final String FILENAME = "file name";
+
+ private final String moduleName;
+ private final Project project;
+ private final NewEmailTemplateDialogValidator validator;
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
message = {NotEmptyRule.MESSAGE, EMAIL_TEMPLATE_ID})
@FieldValidation(rule = RuleRegistry.IDENTIFIER,
message = {IdentifierRule.MESSAGE, EMAIL_TEMPLATE_ID})
private JTextField identifier;
+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
message = {NotEmptyRule.MESSAGE, LABEL})
private JTextField label;
+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
message = {NotEmptyRule.MESSAGE, FILENAME})
@FieldValidation(rule = RuleRegistry.IDENTIFIER,
message = {IdentifierRule.MESSAGE, FILENAME})
private JTextField fileName;
+
private FilteredComboBox area;
private FilteredComboBox templateType;
private JTextField subject;
+ private JLabel identifierErrorMessage;//NOPMD
+ private JLabel labelErrorMessage;//NOPMD
+ private JLabel fileNameErrorMessage;//NOPMD
+
/**
* New email template dialog.
*
@@ -83,6 +92,8 @@ public NewEmailTemplateDialog(final Project project, final PsiDirectory director
// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
+
+ @Override
public void windowClosing(final WindowEvent windowEvent) {
onCancel();
}
@@ -90,11 +101,7 @@ public void windowClosing(final WindowEvent windowEvent) {
// call onCancel() on ESCAPE
contentPane.registerKeyboardAction(
- new ActionListener() {
- public void actionPerformed(final ActionEvent actionEvent) {
- onCancel();
- }
- },
+ actionEvent -> onCancel(),
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
);
@@ -208,11 +215,9 @@ private void onOK() {
final boolean emailTemplateCanBeDeclared = !this.validator.validate(this);
if (!validateFormFields() || emailTemplateCanBeDeclared) {
- exit();
return;
}
generateFile();
-
exit();
}
@@ -230,11 +235,6 @@ private void generateFile() {
xmlGenerator.generate(NewEmailTemplateAction.ACTION_NAME, true);
}
- protected void onCancel() {
- // add your code here if necessary
- dispose();
- }
-
@SuppressWarnings({"PMD.UnusedPrivateMethod"})
private void createUIComponents() {
this.area = new FilteredComboBox(getAreaList());
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.form
index ec6e68d88..da7a3a909 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.form
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.form
@@ -3,10 +3,10 @@
-
+
-
+
@@ -51,7 +51,7 @@
-
+
@@ -77,7 +77,7 @@
-
+
@@ -85,7 +85,7 @@
-
+
@@ -93,7 +93,7 @@
-
+
@@ -101,7 +101,7 @@
-
+
@@ -109,7 +109,7 @@
-
+
@@ -119,7 +119,7 @@
-
+
@@ -127,7 +127,7 @@
-
+
@@ -137,7 +137,7 @@
-
+
@@ -145,7 +145,7 @@
-
+
@@ -155,12 +155,60 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java
index 518522798..ca47d35b7 100644
--- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java
+++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java
@@ -35,6 +35,7 @@
@SuppressWarnings("PMD.TooManyFields")
public class NewModelsDialog extends AbstractDialog {
+
private final String moduleName;
private final Project project;
private JPanel contentPane;
@@ -91,6 +92,12 @@ public class NewModelsDialog extends AbstractDialog {
private JLabel entityIdColumnLabel;//NOPMD
private JLabel collectionDirectoryLabel;//NOPMD
private JLabel collectionNameLabel;//NOPMD
+ private JLabel modelNameErrorMessage;//NOPMD
+ private JLabel resourceModelNameErrorMessage;//NOPMD
+ private JLabel dbTableNameErrorMessage;//NOPMD
+ private JLabel entityIdColumnErrorMessage;//NOPMD
+ private JLabel collectionDirectoryErrorMessage;//NOPMD
+ private JLabel collectionNameErrorMessage;//NOPMD
/**
* Open new dialog for adding new controller.
@@ -160,11 +167,6 @@ public static void open(
dialog.setVisible(true);
}
- @Override
- protected void onCancel() {
- dispose();
- }
-
/**
* Process generation.
*/
@@ -173,8 +175,8 @@ private void onOK() {
generateModelFile();
generateResourceModelFile();
generateCollectionFile();
+ exit();
}
- exit();
}
/**