From 3b0b1914ec95a7265d33c80e96e941d9bc43d5b8 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Tue, 21 Dec 2021 23:07:22 +0200 Subject: [PATCH 01/14] 873: Code refactoring --- .../generation/NewEmailTemplateAction.java | 7 +++--- .../dialog/NewEmailTemplateDialog.java | 25 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) 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/dialog/NewEmailTemplateDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java index 2ee468ebf..c12f14cb3 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; @@ -36,15 +34,18 @@ 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, @@ -58,6 +59,7 @@ public class NewEmailTemplateDialog extends AbstractDialog { @FieldValidation(rule = RuleRegistry.IDENTIFIER, message = {IdentifierRule.MESSAGE, FILENAME}) private JTextField fileName; + private FilteredComboBox area; private FilteredComboBox templateType; private JTextField subject; @@ -83,6 +85,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 +94,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 ); @@ -230,11 +230,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()); From 8e92c6388303d95422ee39e2743bf742afcafa77 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Tue, 21 Dec 2021 23:16:05 +0200 Subject: [PATCH 02/14] 873: Enhanced error outputting for new Magento 2 email template generation --- .../dialog/NewEmailTemplateDialog.form | 52 ++++++++++++++----- .../dialog/NewEmailTemplateDialog.java | 9 +++- 2 files changed, 46 insertions(+), 15 deletions(-) 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 c12f14cb3..461f3588f 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEmailTemplateDialog.java @@ -29,6 +29,7 @@ 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; @@ -51,9 +52,11 @@ public class NewEmailTemplateDialog extends AbstractDialog { @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, @@ -64,6 +67,10 @@ public class NewEmailTemplateDialog extends AbstractDialog { private FilteredComboBox templateType; private JTextField subject; + private JLabel identifierErrorMessage;//NOPMD + private JLabel labelErrorMessage;//NOPMD + private JLabel fileNameErrorMessage;//NOPMD + /** * New email template dialog. * @@ -208,11 +215,9 @@ private void onOK() { final boolean emailTemplateCanBeDeclared = !this.validator.validate(this); if (!validateFormFields() || emailTemplateCanBeDeclared) { - exit(); return; } generateFile(); - exit(); } From 457429ae3412f6537c5c0c13e6fbffa2e668581d Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Tue, 21 Dec 2021 23:20:59 +0200 Subject: [PATCH 03/14] 874: Code refactoring --- .../actions/generation/NewModelsAction.java | 6 +++--- .../actions/generation/dialog/NewModelsDialog.java | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) 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/NewModelsDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java index 518522798..e16df74a7 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; @@ -160,11 +161,6 @@ public static void open( dialog.setVisible(true); } - @Override - protected void onCancel() { - dispose(); - } - /** * Process generation. */ @@ -173,8 +169,8 @@ private void onOK() { generateModelFile(); generateResourceModelFile(); generateCollectionFile(); + exit(); } - exit(); } /** From e83ab093d2cb161345ca56ab0f6d8562b63dabc2 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Tue, 21 Dec 2021 23:26:06 +0200 Subject: [PATCH 04/14] 874: Enhanced error outputting for new Magento 2 models generation --- .../generation/dialog/NewModelsDialog.form | 74 +++++++++++++++---- .../generation/dialog/NewModelsDialog.java | 6 ++ 2 files changed, 67 insertions(+), 13 deletions(-) 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 e16df74a7..ca47d35b7 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModelsDialog.java @@ -92,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. From 58d6269fbe5e54cd2d9db88a9cd7e9927c34859b Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Wed, 22 Dec 2021 17:40:51 +0200 Subject: [PATCH 05/14] 875: Code refactoring --- .../generation/NewDataModelAction.java | 10 +++--- .../generation/dialog/NewDataModelDialog.java | 36 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewDataModelAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewDataModelAction.java index e15ff1551..cd3393b26 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/NewDataModelAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/NewDataModelAction.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; public class NewDataModelAction extends AnAction { + public static final String ACTION_NAME = "Magento 2 Data Model"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Data Model"; @@ -29,24 +30,23 @@ public NewDataModelAction() { } @Override - public void actionPerformed(@NotNull final AnActionEvent event) { + public void actionPerformed(final @NotNull 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; } - NewDataModelDialog.open(project, directory); } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java index 040572b21..d9389495b 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java @@ -47,24 +47,25 @@ import javax.swing.KeyStroke; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; +import org.jetbrains.annotations.NotNull; @SuppressWarnings({ "PMD.ExcessiveImports" }) public class NewDataModelDialog extends AbstractDialog { - private final Project project; - private final String moduleName; - private final ValidatorBundle validatorBundle; - private final CommonBundle commonBundle; - private final List properties; - private static final String MODEL_NAME = "Model Name"; private static final String PROPERTY_NAME = "Name"; private static final String PROPERTY_TYPE = "Type"; private static final String PROPERTY_ACTION = "Action"; private static final String PROPERTY_DELETE = "Delete"; + private final Project project; + private final String moduleName; + private final ValidatorBundle validatorBundle; + private final CommonBundle commonBundle; + private final List properties; + private JPanel contentPanel; private JButton buttonOK; private JButton buttonCancel; @@ -72,16 +73,17 @@ public class NewDataModelDialog extends AbstractDialog { private JButton addProperty; private JCheckBox createInterface; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, MODEL_NAME}) - @FieldValidation(rule = RuleRegistry.PHP_CLASS, - message = {PhpClassRule.MESSAGE, MODEL_NAME}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, MODEL_NAME}) + @FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassRule.MESSAGE, MODEL_NAME}) private JTextField modelName; /** * Constructor. */ - public NewDataModelDialog(final Project project, final PsiDirectory directory) { + public NewDataModelDialog( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { super(); this.project = project; @@ -122,7 +124,10 @@ public void windowClosing(final WindowEvent event) { /** * Opens the dialog window. */ - public static void open(final Project project, final PsiDirectory directory) { + public static void open( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { final NewDataModelDialog dialog = new NewDataModelDialog(project, directory); dialog.pack(); dialog.centerDialog(dialog); @@ -145,8 +150,8 @@ private void onOK() { generateDataModelInterfaceFile(); generatePreferenceForInterface(); } + exit(); } - exit(); } @Override @@ -190,11 +195,6 @@ protected boolean validateFormFields() { return valid; } - @Override - public void onCancel() { - dispose(); - } - /** * Generate DTO interface file. */ From cc135f0601f7076754905cb3646e4c23881c72ed Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Wed, 22 Dec 2021 17:50:24 +0200 Subject: [PATCH 06/14] 875: Enhanced error outputting for new Magento 2 data model generation --- resources/magento2/validation.properties | 1 + .../generation/dialog/NewDataModelDialog.form | 10 +++++++++- .../generation/dialog/NewDataModelDialog.java | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/resources/magento2/validation.properties b/resources/magento2/validation.properties index 9e7a095d5..b868b58fb 100644 --- a/resources/magento2/validation.properties +++ b/resources/magento2/validation.properties @@ -1,6 +1,7 @@ validator.notEmpty=The {0} field must not be empty validator.box.notEmpty=The {0} field must contain a valid selection from the dropdown validator.package.validPath=Please specify a valid Magento 2 installation path +validator.properties.notEmpty=The properties must not be empty validator.alphaNumericCharacters=The {0} field must contain letters and numbers only validator.alphaNumericAndUnderscoreCharacters={0} must contain letters, numbers and underscores only validator.alphaAndPeriodCharacters=The {0} field must contain alphabets and periods only diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.form index 9d58d7228..b9b2cb84b 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.form @@ -10,7 +10,7 @@ - + @@ -36,6 +36,14 @@ + + + + + + + + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java index d9389495b..1c907d7a9 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java @@ -40,6 +40,7 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComponent; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTable; @@ -77,6 +78,8 @@ public class NewDataModelDialog extends AbstractDialog { @FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassRule.MESSAGE, MODEL_NAME}) private JTextField modelName; + private JLabel modelNameErrorMessage;//NOPMD + /** * Constructor. */ @@ -162,6 +165,17 @@ protected boolean validateFormFields() { valid = true; final String errorTitle = commonBundle.message("common.error"); final int column = 0; + + if (propertyTable.getRowCount() == 0) { + valid = false; + JOptionPane.showMessageDialog( + null, + validatorBundle.message("validator.properties.notEmpty"), + errorTitle, + JOptionPane.ERROR_MESSAGE + ); + } + for (int row = 0; row < propertyTable.getRowCount(); row++) { final String propertyName = ((String) propertyTable.getValueAt(row, column)).trim(); if (propertyName.isEmpty()) { From 533e98c786598ae63933793a3563f9d48d00beb0 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Wed, 22 Dec 2021 17:58:10 +0200 Subject: [PATCH 07/14] 876: Code refactoring --- .../generation/NewMessageQueueAction.java | 10 +++---- .../dialog/NewMessageQueueDialog.java | 29 ++++++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewMessageQueueAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewMessageQueueAction.java index d562f076a..f66d9f1d0 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/NewMessageQueueAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/NewMessageQueueAction.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; public class NewMessageQueueAction extends AnAction { + public static final String ACTION_NAME = "Magento 2 Message Queue"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Message Queue"; @@ -29,24 +30,23 @@ public NewMessageQueueAction() { } @Override - public void actionPerformed(@NotNull final AnActionEvent event) { + public void actionPerformed(final @NotNull 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; } - NewMessageQueueDialog.open(project, directory); } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java index e7954d2c5..e246e2cac 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java @@ -52,6 +52,7 @@ "PMD.ExcessiveImports", }) public class NewMessageQueueDialog extends AbstractDialog { + private static final String TOPIC_NAME = "Topic Name"; private static final String HANDLER_NAME = "Handler Name"; private static final String HANDLER_TYPE = "Handler Type"; @@ -64,6 +65,8 @@ public class NewMessageQueueDialog extends AbstractDialog { private static final String BINDING_TOPIC = "Binding Topic"; private JComboBox connectionName; + private final Project project; + private final String moduleName; /* TODO: Improve validation */ @FieldValidation(rule = RuleRegistry.NOT_EMPTY, @@ -146,13 +149,16 @@ public class NewMessageQueueDialog extends AbstractDialog { private JLabel consumerNameLabel;//NOPMD private JLabel handlerDirectoryLabel;//NOPMD - private final Project project; - private final String moduleName; - /** * Constructor. + * + * @param project Project + * @param directory PsiDirectory */ - public NewMessageQueueDialog(final Project project, final PsiDirectory directory) { + public NewMessageQueueDialog( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { super(); this.project = project; @@ -224,19 +230,20 @@ private void toggleConsumer() { /** * Opens the dialog window. + * + * @param project Project + * @param directory PsiDirectory */ - public static void open(final Project project, final PsiDirectory directory) { + public static void open( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { final NewMessageQueueDialog dialog = new NewMessageQueueDialog(project, directory); dialog.pack(); dialog.centerDialog(dialog); dialog.setVisible(true); } - @Override - public void onCancel() { - dispose(); - } - private void onOK() { if (validateFormFields()) { generateCommunication(); @@ -248,8 +255,8 @@ private void onOK() { if (getConnectionName().equals(MessageQueueConnections.DB.getType())) { generateConsumerClass(); } + exit(); } - exit(); } private void generateCommunication() { From 01738e9f84d3f8029e564d8e90db587f7b4fffdf Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Wed, 22 Dec 2021 20:51:13 +0200 Subject: [PATCH 08/14] 876: Enhanced error outputting for new Magento 2 message queue generation --- .../dialog/NewMessageQueueDialog.form | 143 +++++++++++++++--- .../dialog/NewMessageQueueDialog.java | 55 ++++--- 2 files changed, 153 insertions(+), 45 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.form index ab56c7f34..13e9efda6 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.form @@ -7,11 +7,12 @@ + - + @@ -21,7 +22,7 @@ - + @@ -32,7 +33,7 @@ - + @@ -44,7 +45,7 @@ - + @@ -53,7 +54,7 @@ - + @@ -63,7 +64,7 @@ - + @@ -71,7 +72,7 @@ - + @@ -103,7 +104,7 @@ - + @@ -113,7 +114,7 @@ - + @@ -121,7 +122,7 @@ - + @@ -129,7 +130,7 @@ - + @@ -139,7 +140,7 @@ - + @@ -147,7 +148,7 @@ - + @@ -155,7 +156,7 @@ - + @@ -163,12 +164,76 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -212,7 +277,7 @@ - + @@ -222,7 +287,7 @@ - + @@ -232,7 +297,7 @@ - + @@ -240,7 +305,7 @@ - + @@ -253,7 +318,7 @@ - + @@ -270,7 +335,7 @@ - + @@ -280,7 +345,7 @@ - + @@ -288,7 +353,7 @@ - + @@ -312,6 +377,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java index e246e2cac..816079a41 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java @@ -19,6 +19,7 @@ import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.AlphaWithDashRule; import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.AlphaWithPeriodRule; import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.AlphanumericWithUnderscoreRule; +import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.DirectoryRule; import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.Lowercase; import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule; import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NumericRule; @@ -55,10 +56,12 @@ public class NewMessageQueueDialog extends AbstractDialog { private static final String TOPIC_NAME = "Topic Name"; private static final String HANDLER_NAME = "Handler Name"; - private static final String HANDLER_TYPE = "Handler Type"; + private static final String HANDLER_TYPE = "Handler Class"; + private static final String HANDLER_DIR = "Handler Directory"; private static final String CONSUMER_NAME = "Consumer Name"; private static final String QUEUE_NAME = "Queue Name"; - private static final String CONSUMER_TYPE = "Consumer Type"; + private static final String CONSUMER_TYPE = "Consumer Class"; + private static final String CONSUMER_DIR = "Consumer Directory"; private static final String MAX_MESSAGES = "Maximum Messages"; private static final String EXCHANGE_NAME = "Exchange Name"; private static final String BINDING_ID = "Binding ID"; @@ -69,22 +72,18 @@ public class NewMessageQueueDialog extends AbstractDialog { private final String moduleName; /* TODO: Improve validation */ - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, TOPIC_NAME}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, TOPIC_NAME}) @FieldValidation(rule = RuleRegistry.ALPHA_WITH_PERIOD, message = {AlphaWithPeriodRule.MESSAGE, TOPIC_NAME}) - @FieldValidation(rule = RuleRegistry.LOWERCASE, - message = {Lowercase.MESSAGE, TOPIC_NAME}) + @FieldValidation(rule = RuleRegistry.LOWERCASE, message = {Lowercase.MESSAGE, TOPIC_NAME}) private JTextField topicName; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, HANDLER_NAME}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, HANDLER_NAME}) @FieldValidation(rule = RuleRegistry.ALPHA_WITH_PERIOD, message = {AlphanumericWithUnderscoreRule.MESSAGE, HANDLER_NAME}) private JTextField handlerName; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, HANDLER_TYPE}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, HANDLER_TYPE}) @FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassFqnRule.MESSAGE, HANDLER_TYPE}) private JTextField handlerClass; @@ -93,16 +92,13 @@ public class NewMessageQueueDialog extends AbstractDialog { message = {NotEmptyRule.MESSAGE, CONSUMER_NAME}) @FieldValidation(rule = RuleRegistry.ALPHA_WITH_PERIOD, message = {AlphaWithPeriodRule.MESSAGE, CONSUMER_NAME}) - @FieldValidation(rule = RuleRegistry.LOWERCASE, - message = {Lowercase.MESSAGE, CONSUMER_NAME}) + @FieldValidation(rule = RuleRegistry.LOWERCASE, message = {Lowercase.MESSAGE, CONSUMER_NAME}) private JTextField consumerName; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, QUEUE_NAME}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, QUEUE_NAME}) @FieldValidation(rule = RuleRegistry.ALPHA_WITH_PERIOD, message = {AlphaWithPeriodRule.MESSAGE, QUEUE_NAME}) - @FieldValidation(rule = RuleRegistry.LOWERCASE, - message = {Lowercase.MESSAGE, QUEUE_NAME}) + @FieldValidation(rule = RuleRegistry.LOWERCASE, message = {Lowercase.MESSAGE, QUEUE_NAME}) private JTextField queueName; @FieldValidation(rule = RuleRegistry.NOT_EMPTY, @@ -111,10 +107,8 @@ public class NewMessageQueueDialog extends AbstractDialog { message = {PhpClassFqnRule.MESSAGE, CONSUMER_TYPE}) private JTextField consumerClass; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, MAX_MESSAGES}) - @FieldValidation(rule = RuleRegistry.NUMERIC, - message = {NumericRule.MESSAGE, MAX_MESSAGES}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, MAX_MESSAGES}) + @FieldValidation(rule = RuleRegistry.NUMERIC, message = {NumericRule.MESSAGE, MAX_MESSAGES}) private JTextField maxMessages; @FieldValidation(rule = RuleRegistry.NOT_EMPTY, @@ -123,8 +117,7 @@ public class NewMessageQueueDialog extends AbstractDialog { message = {AlphaWithDashRule.MESSAGE, EXCHANGE_NAME}) private JTextField exchangeName; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, - message = {NotEmptyRule.MESSAGE, BINDING_ID}) + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, BINDING_ID}) @FieldValidation(rule = RuleRegistry.ALPHANUMERIC_WITH_UNDERSCORE, message = {AlphaWithDashRule.MESSAGE, BINDING_ID}) private JTextField bindingId; @@ -135,7 +128,12 @@ public class NewMessageQueueDialog extends AbstractDialog { message = {AlphanumericWithUnderscoreRule.MESSAGE, BINDING_TOPIC}) private JTextField bindingTopic; + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, CONSUMER_DIR}) + @FieldValidation(rule = RuleRegistry.DIRECTORY, message = {DirectoryRule.MESSAGE, CONSUMER_DIR}) private JTextField consumerDirectory; + + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, HANDLER_DIR}) + @FieldValidation(rule = RuleRegistry.DIRECTORY, message = {DirectoryRule.MESSAGE, HANDLER_DIR}) private JTextField handlerDirectory; private JPanel contentPanel; @@ -149,6 +147,19 @@ public class NewMessageQueueDialog extends AbstractDialog { private JLabel consumerNameLabel;//NOPMD private JLabel handlerDirectoryLabel;//NOPMD + private JLabel topicNameErrorMessage;//NOPMD + private JLabel handlerNameErrorMessage;//NOPMD + private JLabel handlerClassErrorMessage;//NOPMD + private JLabel consumerNameErrorMessage;//NOPMD + private JLabel queueNameErrorMessage;//NOPMD + private JLabel consumerClassErrorMessage;//NOPMD + private JLabel maxMessagesErrorMessage;//NOPMD + private JLabel exchangeNameErrorMessage;//NOPMD + private JLabel bindingIdErrorMessage;//NOPMD + private JLabel bindingTopicErrorMessage;//NOPMD + private JLabel consumerDirectoryErrorMessage;//NOPMD + private JLabel handlerDirectoryErrorMessage;//NOPMD + /** * Constructor. * From d890d835dc43ebe7c0e1d027ca0f89c3d6a04828 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Thu, 23 Dec 2021 09:31:16 +0200 Subject: [PATCH 09/14] 877: Code refactoring --- .../actions/generation/NewDbSchemaAction.java | 6 ++++-- .../actions/generation/dialog/NewDbSchemaDialog.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewDbSchemaAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewDbSchemaAction.java index f2a76930f..ee2997166 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/NewDbSchemaAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/NewDbSchemaAction.java @@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull; public class NewDbSchemaAction extends AnAction { + public static final String ACTION_NAME = "Magento 2 Declarative Schema XML"; public static final String ACTION_DESCRIPTION = "Create a new declarative schema XML"; @@ -32,16 +33,17 @@ public NewDbSchemaAction() { public void actionPerformed(final @NotNull 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; } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java index f48820135..00bf34911 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java @@ -150,8 +150,8 @@ private void onOK() { return; } generateWhitelistJsonFile(dbSchemaXmlData); + exit(); } - exit(); } /** From 63ef611d2f4fc57c9d890c8b444283a2a502301b Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Thu, 23 Dec 2021 09:35:18 +0200 Subject: [PATCH 10/14] 877: Enhanced error outputting for new Magento 2 db schema generation --- .../generation/dialog/NewDbSchemaDialog.form | 18 +++++++++++++----- .../generation/dialog/NewDbSchemaDialog.java | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.form index 7c48e7d9b..78ac30fdd 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.form @@ -56,7 +56,7 @@ - + @@ -92,7 +92,7 @@ - + @@ -101,7 +101,7 @@ - + @@ -110,7 +110,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -128,6 +128,14 @@ + + + + + + + + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java index 00bf34911..020b17443 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java @@ -46,6 +46,7 @@ @SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveImports"}) public class NewDbSchemaDialog extends AbstractDialog { + private static final String TABLE_NAME = "Table Name"; private final Project project; @@ -85,6 +86,7 @@ public class NewDbSchemaDialog extends AbstractDialog { private JLabel tableResourceLabel;//NOPMD private JLabel tableCommentLabel;//NOPMD private JLabel tableColumnsLabel;//NOPMD + private JLabel tableNameErrorMessage;//NOPMD /** * Constructor. From 94959810ebc3964f997d9103bae33c1021626850 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Thu, 23 Dec 2021 09:43:40 +0200 Subject: [PATCH 11/14] 878: Code refactoring --- .../generation/NewUiComponentGridAction.java | 6 +-- .../dialog/NewUiComponentGridDialog.java | 40 +++++++++++-------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentGridAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentGridAction.java index f507f9051..e2f4a0f5f 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentGridAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentGridAction.java @@ -16,8 +16,8 @@ import com.magento.idea.magento2plugin.MagentoIcons; import com.magento.idea.magento2plugin.actions.generation.dialog.NewUiComponentGridDialog; -@SuppressWarnings({"PMD.OnlyOneReturn"}) public class NewUiComponentGridAction extends AnAction { + public static final String ACTION_NAME = "Magento 2 UI Component Grid"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 UI Component Grid"; @@ -41,18 +41,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; } - NewUiComponentGridDialog.open(project, directory); } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java index a6d2e58e9..b07a195f7 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java @@ -79,6 +79,7 @@ "PMD.GodClass" }) public class NewUiComponentGridDialog extends AbstractDialog { + private static final String ACTION_NAME = "Action Name"; private static final String DATA_PROVIDER_CLASS_NAME = "Data Provider Class Name"; private static final String DATA_PROVIDER_DIRECTORY = "Data Provider Directory"; @@ -91,25 +92,24 @@ public class NewUiComponentGridDialog extends AbstractDialog { private JButton buttonOK; private JButton buttonCancel; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, NAME}) - @FieldValidation(rule = RuleRegistry.IDENTIFIER, message = {IdentifierRule.MESSAGE, NAME}) - private JTextField uiComponentName; - - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, NAME}) - @FieldValidation(rule = RuleRegistry.IDENTIFIER, message = {IdentifierRule.MESSAGE, NAME}) - private JTextField idField; - private JCheckBox addToolBar; private JCheckBox addBookmarksCheckBox; private JCheckBox addColumnsControlCheckBox; private JCheckBox addFullTextSearchCheckBox; private JCheckBox addListingFiltersCheckBox; private JCheckBox addListingPagingCheckBox; - private FilteredComboBox collection; private FilteredComboBox dataProviderType; private FilteredComboBox areaSelect; + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, NAME}) + @FieldValidation(rule = RuleRegistry.IDENTIFIER, message = {IdentifierRule.MESSAGE, NAME}) + private JTextField uiComponentName; + + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, NAME}) + @FieldValidation(rule = RuleRegistry.IDENTIFIER, message = {IdentifierRule.MESSAGE, NAME}) + private JTextField idField; + @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, DATA_PROVIDER_CLASS_NAME}) @FieldValidation(rule = RuleRegistry.PHP_CLASS, @@ -194,7 +194,10 @@ public class NewUiComponentGridDialog extends AbstractDialog { * @param project Project * @param directory PsiDirectory */ - public NewUiComponentGridDialog(final Project project, final PsiDirectory directory) { + public NewUiComponentGridDialog( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { super(); this.project = project; this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project); @@ -244,7 +247,10 @@ public void windowClosing(final WindowEvent event) { * @param project Project * @param directory PsiDirectory */ - public static void open(final Project project, final PsiDirectory directory) { + public static void open( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { final NewUiComponentGridDialog dialog = new NewUiComponentGridDialog(project, directory); dialog.pack(); dialog.centerDialog(dialog); @@ -312,8 +318,8 @@ private void onOK() { generateDataProviderClass(); generateDataProviderDeclaration(); generateUiComponentFile(); + exit(); } - exit(); } private void setDefaultValues() { @@ -352,7 +358,7 @@ private void generateUiComponentFile() { * Generate data provider class. */ private void generateDataProviderClass() { - if (getDataProviderType().equals(UiComponentDataProviderFile.CUSTOM_TYPE)) { + if (UiComponentDataProviderFile.CUSTOM_TYPE.equals(getDataProviderType())) { final UiComponentDataProviderGenerator dataProviderGenerator; dataProviderGenerator = new UiComponentDataProviderGenerator( getGridDataProviderData(), @@ -367,7 +373,7 @@ private void generateDataProviderClass() { * Generate data provider declaration. */ private void generateDataProviderDeclaration() { - if (getDataProviderType().equals(UiComponentDataProviderFile.COLLECTION_TYPE)) { + if (UiComponentDataProviderFile.COLLECTION_TYPE.equals(getDataProviderType())) { final DataProviderDeclarationGenerator dataProviderGenerator; dataProviderGenerator = new DataProviderDeclarationGenerator( new DataProviderDeclarationData( @@ -463,8 +469,8 @@ private void onAreaChange() { } private void onDataProviderTypeChange() { - final boolean visible = getDataProviderType().equals( - UiComponentDataProviderFile.COLLECTION_TYPE + final boolean visible = UiComponentDataProviderFile.COLLECTION_TYPE.equals( + getDataProviderType() ); collection.setVisible(visible); @@ -554,7 +560,7 @@ private String getDataProviderNamespace() { } private String getDataProviderClassFqn() { - if (!getDataProviderType().equals(UiComponentDataProviderFile.CUSTOM_TYPE)) { + if (!UiComponentDataProviderFile.CUSTOM_TYPE.equals(getDataProviderType())) { return UiComponentDataProviderFile.DEFAULT_DATA_PROVIDER; } return String.format( From 16d6c8052d8d315c98668fca05ef74adaefd7b15 Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Thu, 23 Dec 2021 09:54:14 +0200 Subject: [PATCH 12/14] 878: Enhanced error outputting for new Magento 2 UI Grid generation --- .../dialog/NewUiComponentGridDialog.form | 172 +++++++++++++++--- .../dialog/NewUiComponentGridDialog.java | 17 +- 2 files changed, 158 insertions(+), 31 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form index 1030cda99..25d59d5c8 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.form @@ -3,7 +3,7 @@ - + @@ -65,7 +65,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -135,9 +135,25 @@ + + + + + + + + + + + + + + + + - + @@ -155,7 +171,7 @@ - + @@ -163,7 +179,7 @@ - + @@ -171,7 +187,7 @@ - + @@ -179,7 +195,7 @@ - + @@ -187,7 +203,7 @@ - + @@ -195,7 +211,7 @@ - + @@ -216,9 +232,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -266,7 +314,7 @@ - + @@ -274,7 +322,7 @@ - + @@ -291,13 +339,13 @@ - + - + @@ -305,7 +353,7 @@ - + @@ -314,15 +362,31 @@ - + + + + + + + + + + + + + + + + + - + @@ -340,7 +404,7 @@ - + @@ -348,7 +412,7 @@ - + @@ -364,7 +428,7 @@ - + @@ -372,7 +436,7 @@ - + @@ -387,9 +451,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -415,7 +503,7 @@ - + @@ -423,13 +511,13 @@ - + - + @@ -437,7 +525,7 @@ - + @@ -452,6 +540,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java index b07a195f7..a46409b28 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java @@ -168,6 +168,8 @@ public class NewUiComponentGridDialog extends AbstractDialog { message = {NotEmptyRule.MESSAGE, "Parent Menu"}) private FilteredComboBox parentMenu; + private JTextField tableName; + private JLabel aclLabel; private JLabel routeLabel;//NOPMD private JLabel controllerLabel;//NOPMD @@ -186,7 +188,20 @@ public class NewUiComponentGridDialog extends AbstractDialog { private JLabel collectionLabel;//NOPMD private JLabel dataProviderParentDirectoryLabel; private JLabel tableNameLabel; - private JTextField tableName; + private JLabel uiComponentNameErrorMessage;//NOPMD + private JLabel idFieldErrorMessage;//NOPMD + private JLabel providerClassNameErrorMessage;//NOPMD + private JLabel dataProviderParentDirectoryErrorMessage;//NOPMD + private JLabel aclErrorMessage;//NOPMD + private JLabel parentAclErrorMessage;//NOPMD + private JLabel aclTitleErrorMessage;//NOPMD + private JLabel routeErrorMessage;//NOPMD + private JLabel controllerNameErrorMessage;//NOPMD + private JLabel actionNameErrorMessage;//NOPMD + private JLabel sortOrderErrorMessage;//NOPMD + private JLabel menuIdentifierErrorMessage;//NOPMD + private JLabel menuTitleErrorMessage;//NOPMD + private JLabel parentMenuErrorMessage;//NOPMD /** * New UI component grid dialog constructor. From cb5454ac6b7bb90344c6e60479b85dc3e8827f3d Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Thu, 23 Dec 2021 10:05:12 +0200 Subject: [PATCH 13/14] 879: Code refactoring --- .../generation/NewUiComponentFormAction.java | 6 +- .../dialog/NewUiComponentFormDialog.java | 55 ++++++++++--------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentFormAction.java b/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentFormAction.java index 5c099949d..502013c88 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentFormAction.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/NewUiComponentFormAction.java @@ -17,6 +17,7 @@ import com.magento.idea.magento2plugin.actions.generation.dialog.NewUiComponentFormDialog; public class NewUiComponentFormAction extends AnAction { + public static final String ACTION_NAME = "Magento 2 UI Component Form"; public static final String ACTION_DESCRIPTION = "Create a new Magento 2 UI Component Form"; @@ -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; } - NewUiComponentFormDialog.open(project, directory); } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java index d08e4e3f2..f94b687a4 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java @@ -71,6 +71,7 @@ import javax.swing.KeyStroke; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; +import org.jetbrains.annotations.NotNull; @SuppressWarnings({ "PMD.TooManyFields", @@ -80,6 +81,25 @@ "PMD.GodClass" }) public class NewUiComponentFormDialog extends AbstractDialog { + + private static final String VIEW_ACTION_NAME = "View Action Name"; + private static final String SUBMIT_ACTION_NAME = "Submit Action Name"; + private static final String DATA_PROVIDER_CLASS_NAME = "Data Provider Class Name"; + private static final String DATA_PROVIDER_DIRECTORY = "Data Provider Directory"; + + private static final String CLASS_COLUMN = "Class"; + private static final String DIRECTORY_COLUMN = "Directory"; + private static final String TYPE_COLUMN = "Type"; + private static final String LABEL_COLUMN = "Label"; + private static final String SORT_ORDER_COLUMN = "Sort Order"; + private static final String ACTION_COLUMN = "Action"; + private static final String DELETE_COLUMN = "Delete"; + private static final String NAME_COLUMN = "Name"; + private static final String FIELDSET_COLUMN = "Fieldset"; + private static final String FORM_ELEMENT_TYPE_COLUMN = "Form Element Type"; + private static final String DATA_TYPE_COLUMN = "Data Type"; + private static final String SOURCE_COLUMN = "Source"; + private final FormButtonsValidator formButtonsValidator; private final FormFieldsetsValidator formFieldsetsValidator; private final FormFieldsValidator formFieldsValidator; @@ -90,11 +110,6 @@ public class NewUiComponentFormDialog extends AbstractDialog { private JButton buttonCancel; private FilteredComboBox formAreaSelect; - private static final String VIEW_ACTION_NAME = "View Action Name"; - private static final String SUBMIT_ACTION_NAME = "Submit Action Name"; - private static final String DATA_PROVIDER_CLASS_NAME = "Data Provider Class Name"; - private static final String DATA_PROVIDER_DIRECTORY = "Data Provider Directory"; - @FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, "Name"}) @FieldValidation(rule = RuleRegistry.IDENTIFIER, message = {IdentifierRule.MESSAGE, "Name"}) private JTextField formName; @@ -181,26 +196,16 @@ public class NewUiComponentFormDialog extends AbstractDialog { private JLabel dataProviderClassNameLabel;//NOPMD private JLabel dataProviderDirectoryLabel;//NOPMD - private static final String CLASS_COLUMN = "Class"; - private static final String DIRECTORY_COLUMN = "Directory"; - private static final String TYPE_COLUMN = "Type"; - private static final String LABEL_COLUMN = "Label"; - private static final String SORT_ORDER_COLUMN = "Sort Order"; - private static final String ACTION_COLUMN = "Action"; - private static final String DELETE_COLUMN = "Delete"; - private static final String NAME_COLUMN = "Name"; - private static final String FIELDSET_COLUMN = "Fieldset"; - private static final String FORM_ELEMENT_TYPE_COLUMN = "Form Element Type"; - private static final String DATA_TYPE_COLUMN = "Data Type"; - private static final String SOURCE_COLUMN = "Source"; - /** * Open new dialog for adding new controller. * * @param project Project * @param directory PsiDirectory */ - public NewUiComponentFormDialog(final Project project, final PsiDirectory directory) { + public NewUiComponentFormDialog( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { super(); this.project = project; formButtonsValidator = new FormButtonsValidator(this); @@ -396,7 +401,10 @@ public String getArea() { * @param project Project * @param directory PsiDirectory */ - public static void open(final Project project, final PsiDirectory directory) { + public static void open( + final @NotNull Project project, + final @NotNull PsiDirectory directory + ) { final NewUiComponentFormDialog dialog = new NewUiComponentFormDialog(project, directory); dialog.pack(); dialog.centerDialog(dialog); @@ -424,8 +432,8 @@ private void onOK() { generateLayoutFile(); generateFormFile(); generateAclXmlFile(); + exit(); } - exit(); } /** @@ -536,11 +544,6 @@ private void generateAclXmlFile() { ), getModuleName(), project).generate(NewUiComponentFormAction.ACTION_NAME, false); } - @Override - protected void onCancel() { - dispose(); - } - private List getAreaList() { return new ArrayList<>( Arrays.asList( From 7c43b7ff70ea40c799c58ae6a9948f43ffa091ac Mon Sep 17 00:00:00 2001 From: bohdan-harniuk Date: Thu, 23 Dec 2021 10:59:22 +0200 Subject: [PATCH 14/14] 879: Enhanced error outputting for new Magento 2 UI Form generation --- .../dialog/NewUiComponentFormDialog.form | 168 ++++++++++++++---- .../dialog/NewUiComponentFormDialog.java | 12 ++ 2 files changed, 145 insertions(+), 35 deletions(-) diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form index a5599e727..7add87217 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form @@ -6,7 +6,7 @@ - + @@ -160,15 +160,15 @@ - - + + - + - + @@ -188,7 +188,7 @@ - + @@ -196,7 +196,7 @@ - + @@ -215,15 +215,31 @@ + + + + + + + + + + + + + + + + - - + + - + - + @@ -252,7 +268,7 @@ - + @@ -262,21 +278,37 @@ - + + + + + + + + + + + + + + + + + - - + + - + - + @@ -310,7 +342,7 @@ - + @@ -318,7 +350,7 @@ - + @@ -326,6 +358,22 @@ + + + + + + + + + + + + + + + + @@ -338,17 +386,17 @@ - - + + - + - + - + @@ -356,7 +404,7 @@ - + @@ -375,7 +423,7 @@ - + @@ -385,7 +433,7 @@ - + @@ -417,17 +465,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + + + @@ -447,7 +521,7 @@ - + @@ -455,7 +529,7 @@ - + @@ -463,7 +537,7 @@ - + @@ -471,10 +545,34 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java index f94b687a4..727ff0937 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java @@ -195,6 +195,18 @@ public class NewUiComponentFormDialog extends AbstractDialog { private JLabel dataProviderLabel;//NOPMD private JLabel dataProviderClassNameLabel;//NOPMD private JLabel dataProviderDirectoryLabel;//NOPMD + private JLabel formNameErrorMessage;//NOPMD + private JLabel formLabelErrorMessage;//NOPMD + private JLabel routeErrorMessage;//NOPMD + private JLabel viewControllerNameErrorMessage;//NOPMD + private JLabel viewActionNameErrorMessage;//NOPMD + private JLabel submitControllerNameErrorMessage;//NOPMD + private JLabel submitActionNameErrorMessage;//NOPMD + private JLabel dataProviderClassNameErrorMessage;//NOPMD + private JLabel dataProviderDirectoryErrorMessage;//NOPMD + private JLabel aclErrorMessage;//NOPMD + private JLabel parentAclErrorMessage;//NOPMD + private JLabel aclTitleErrorMessage;//NOPMD /** * Open new dialog for adding new controller.