Skip to content

Commit 0d85916

Browse files
867: Enhanced error outputting for new Magento 2 Controller generation
1 parent 15d9974 commit 0d85916

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

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

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="454" height="423"/>
6+
<xy x="48" y="54" width="454" height="431"/>
77
</constraints>
88
<properties>
99
<preferredSize width="450" height="300"/>
@@ -51,7 +51,7 @@
5151
</grid>
5252
</children>
5353
</grid>
54-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
54+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
5555
<margin top="0" left="0" bottom="0" right="0"/>
5656
<constraints>
5757
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -61,15 +61,15 @@
6161
<children>
6262
<component id="5a121" class="javax.swing.JLabel">
6363
<constraints>
64-
<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"/>
64+
<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"/>
6565
</constraints>
6666
<properties>
6767
<text resource-bundle="magento2/common" key="common.controller.name"/>
6868
</properties>
6969
</component>
7070
<component id="4e6cb" class="javax.swing.JTextField" binding="controllerName">
7171
<constraints>
72-
<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">
72+
<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">
7373
<preferred-size width="150" height="-1"/>
7474
</grid>
7575
</constraints>
@@ -79,15 +79,15 @@
7979
</component>
8080
<component id="d25a" class="javax.swing.JLabel">
8181
<constraints>
82-
<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"/>
82+
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
8383
</constraints>
8484
<properties>
8585
<text resource-bundle="magento2/common" key="common.parentDirectory"/>
8686
</properties>
8787
</component>
8888
<component id="7df01" class="javax.swing.JTextField" binding="controllerParentDir">
8989
<constraints>
90-
<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">
90+
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
9191
<preferred-size width="150" height="-1"/>
9292
</grid>
9393
</constraints>
@@ -111,13 +111,38 @@
111111
</constraints>
112112
<properties/>
113113
</component>
114+
<component id="77374" class="javax.swing.JLabel" binding="actionNameErrorMessage">
115+
<constraints>
116+
<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"/>
117+
</constraints>
118+
<properties>
119+
<text value=""/>
120+
</properties>
121+
</component>
122+
<component id="d71e2" class="javax.swing.JLabel" binding="controllerNameErrorMessage">
123+
<constraints>
124+
<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"/>
125+
</constraints>
126+
<properties>
127+
<text value=""/>
128+
</properties>
129+
</component>
130+
<component id="f1afe" class="javax.swing.JLabel" binding="controllerParentDirErrorMessage">
131+
<constraints>
132+
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
133+
</constraints>
134+
<properties>
135+
<text value=""/>
136+
</properties>
137+
</component>
114138
</children>
115139
</grid>
116140
<component id="b8894" class="com.magento.idea.magento2plugin.ui.FilteredComboBox" binding="controllerAreaSelect" custom-create="true">
117141
<constraints>
118142
<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"/>
119143
</constraints>
120144
<properties>
145+
<editable value="true"/>
121146
<toolTipText value=""/>
122147
</properties>
123148
<clientProperties>
@@ -145,6 +170,7 @@
145170
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
146171
</constraints>
147172
<properties>
173+
<editable value="true"/>
148174
<toolTipText value=""/>
149175
</properties>
150176
<clientProperties>

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import javax.swing.JButton;
3434
import javax.swing.JCheckBox;
3535
import javax.swing.JComponent;
36+
import javax.swing.JLabel;
3637
import javax.swing.JPanel;
3738
import javax.swing.JTextField;
3839
import javax.swing.KeyStroke;
@@ -43,14 +44,14 @@
4344
"PMD.ExcessiveImports"
4445
})
4546
public class NewControllerDialog extends AbstractDialog {
47+
4648
private final String moduleName;
4749
private final Project project;
4850
private JPanel contentPane;
4951
private JButton buttonOK;
5052
private JButton buttonCancel;
5153
private FilteredComboBox controllerAreaSelect;
5254
private FilteredComboBox httpMethodSelect;
53-
private JTextField controllerParentDir;
5455
private JCheckBox inheritClass;
5556
private JPanel adminPanel;
5657
private JTextField acl;
@@ -64,12 +65,16 @@ public class NewControllerDialog extends AbstractDialog {
6465
message = {PhpDirectoryRule.MESSAGE, CONTROLLER_NAME})
6566
private JTextField controllerName;
6667

67-
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
68-
message = {NotEmptyRule.MESSAGE, ACTION_NAME})
69-
@FieldValidation(rule = RuleRegistry.PHP_CLASS,
70-
message = {PhpClassRule.MESSAGE, ACTION_NAME})
68+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, ACTION_NAME})
69+
@FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassRule.MESSAGE, ACTION_NAME})
7170
private JTextField actionName;
7271

72+
private JTextField controllerParentDir;
73+
74+
private JLabel actionNameErrorMessage;//NOPMD
75+
private JLabel controllerNameErrorMessage;//NOPMD
76+
private JLabel controllerParentDirErrorMessage;//NOPMD
77+
7378
/**
7479
* Open new dialog for adding new controller.
7580
*
@@ -196,8 +201,8 @@ public static void open(final Project project, final PsiDirectory directory) {
196201
private void onOK() {
197202
if (validateFormFields()) {
198203
generateFile();
204+
exit();
199205
}
200-
exit();
201206
}
202207

203208
/**
@@ -264,11 +269,6 @@ private Boolean getIsInheritClass() {
264269
return inheritClass.isSelected();
265270
}
266271

267-
@Override
268-
protected void onCancel() {
269-
dispose();
270-
}
271-
272272
private List<String> getAreaList() {
273273
return new ArrayList<>(
274274
Arrays.asList(

0 commit comments

Comments
 (0)