Skip to content

Commit a741849

Browse files
864: Enhanced error outputting for new Magento 2 Block generation
1 parent 6b1ff0e commit a741849

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewBlockDialog.form

+19-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</grid>
5454
</children>
5555
</grid>
56-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
56+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
5757
<margin top="0" left="0" bottom="0" right="0"/>
5858
<constraints>
5959
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -85,7 +85,7 @@
8585
</component>
8686
<component id="fdc52" class="javax.swing.JTextField" binding="blockParentDir">
8787
<constraints>
88-
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
88+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
8989
<preferred-size width="150" height="-1"/>
9090
</grid>
9191
</constraints>
@@ -96,7 +96,7 @@
9696
</component>
9797
<component id="be25f" class="javax.swing.JLabel">
9898
<constraints>
99-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
99+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
100100
</constraints>
101101
<properties>
102102
<labelFor value="fdc52"/>
@@ -106,6 +106,22 @@
106106
<html.disable class="java.lang.Boolean" value="true"/>
107107
</clientProperties>
108108
</component>
109+
<component id="48e8" class="javax.swing.JLabel" binding="blockNameErrorMessage">
110+
<constraints>
111+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
112+
</constraints>
113+
<properties>
114+
<text value=""/>
115+
</properties>
116+
</component>
117+
<component id="340c3" class="javax.swing.JLabel" binding="blockParentDirErrorMessage">
118+
<constraints>
119+
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
120+
</constraints>
121+
<properties>
122+
<text value=""/>
123+
</properties>
124+
</component>
109125
</children>
110126
</grid>
111127
<grid id="ddd4f" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

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

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import com.intellij.openapi.project.Project;
99
import com.intellij.psi.PsiDirectory;
10-
import com.intellij.psi.PsiFile;
1110
import com.magento.idea.magento2plugin.actions.generation.NewBlockAction;
1211
import com.magento.idea.magento2plugin.actions.generation.data.BlockFileData;
1312
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation;
@@ -26,13 +25,15 @@
2625
import java.awt.event.WindowEvent;
2726
import javax.swing.JButton;
2827
import javax.swing.JComponent;
28+
import javax.swing.JLabel;
2929
import javax.swing.JPanel;
3030
import javax.swing.JRadioButton;
3131
import javax.swing.JTextField;
3232
import javax.swing.JTextPane;
3333
import javax.swing.KeyStroke;
3434

3535
public class NewBlockDialog extends AbstractDialog {
36+
3637
private final PsiDirectory baseDir;
3738
private final String moduleName;
3839
private JPanel contentPanel;
@@ -44,18 +45,18 @@ public class NewBlockDialog extends AbstractDialog {
4445
private static final String NAME = "name";
4546
private static final String DIRECTORY = "directory";
4647

47-
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
48-
message = {NotEmptyRule.MESSAGE, NAME})
49-
@FieldValidation(rule = RuleRegistry.PHP_CLASS,
50-
message = {PhpClassRule.MESSAGE, NAME})
48+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, NAME})
49+
@FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassRule.MESSAGE, NAME})
5150
private JTextField blockName;
5251

53-
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
54-
message = {NotEmptyRule.MESSAGE, DIRECTORY})
52+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, DIRECTORY})
5553
@FieldValidation(rule = RuleRegistry.PHP_DIRECTORY,
5654
message = {PhpDirectoryRule.MESSAGE, DIRECTORY})
5755
private JTextField blockParentDir;
5856

57+
private JLabel blockNameErrorMessage;//NOPMD
58+
private JLabel blockParentDirErrorMessage;//NOPMD
59+
5960
/**
6061
* Constructor.
6162
*
@@ -113,8 +114,8 @@ public static void open(final Project project, final PsiDirectory directory) {
113114
protected void onOK() {
114115
if (validateFormFields()) {
115116
generateFile();
117+
exit();
116118
}
117-
exit();
118119
}
119120

120121
private void generateFile() {

0 commit comments

Comments
 (0)