Skip to content

Commit 715575e

Browse files
868: Enhanced error outputting for new Magento 2 Cron Job generation
1 parent 36fc257 commit 715575e

File tree

2 files changed

+68
-22
lines changed

2 files changed

+68
-22
lines changed

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

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" 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="941" height="420"/>
6+
<xy x="48" y="54" width="941" height="479"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -49,7 +49,7 @@
4949
</grid>
5050
</children>
5151
</grid>
52-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="8" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
52+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="12" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
5353
<margin top="0" left="0" bottom="0" right="0"/>
5454
<constraints>
5555
<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"/>
@@ -78,7 +78,7 @@
7878
</component>
7979
<component id="e23f7" class="javax.swing.JLabel">
8080
<constraints>
81-
<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"/>
81+
<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"/>
8282
</constraints>
8383
<properties>
8484
<labelFor value="b2d70"/>
@@ -87,20 +87,20 @@
8787
</component>
8888
<component id="462a3" class="javax.swing.JLabel">
8989
<constraints>
90-
<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"/>
90+
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9191
</constraints>
9292
<properties>
9393
<text resource-bundle="magento2/common" key="common.schedule"/>
9494
</properties>
9595
</component>
9696
<vspacer id="efb9e">
9797
<constraints>
98-
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
98+
<grid row="11" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
9999
</constraints>
100100
</vspacer>
101101
<component id="93bb3" class="javax.swing.JRadioButton" binding="fixedScheduleRadioButton">
102102
<constraints>
103-
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
103+
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
104104
</constraints>
105105
<properties>
106106
<selected value="true"/>
@@ -109,16 +109,16 @@
109109
</component>
110110
<component id="649c" class="javax.swing.JRadioButton" binding="configurableScheduleRadioButton">
111111
<constraints>
112-
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
112+
<grid row="8" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
113113
</constraints>
114114
<properties>
115115
<text resource-bundle="magento2/common" key="common.schedule.configurable"/>
116116
</properties>
117117
</component>
118-
<grid id="832a2" binding="fixedSchedulePanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
118+
<grid id="832a2" binding="fixedSchedulePanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
119119
<margin top="0" left="0" bottom="0" right="0"/>
120120
<constraints>
121-
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
121+
<grid row="9" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
122122
</constraints>
123123
<properties/>
124124
<border type="none"/>
@@ -162,12 +162,20 @@
162162
<text resource-bundle="magento2/common" key="common.schedule.atMidnight"/>
163163
</properties>
164164
</component>
165+
<component id="a207e" class="javax.swing.JLabel" binding="cronjobScheduleFieldErrorMessage">
166+
<constraints>
167+
<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"/>
168+
</constraints>
169+
<properties>
170+
<text value=""/>
171+
</properties>
172+
</component>
165173
</children>
166174
</grid>
167175
<grid id="f84c7" binding="configurableSchedulePanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
168176
<margin top="0" left="0" bottom="0" right="0"/>
169177
<constraints>
170-
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
178+
<grid row="10" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
171179
</constraints>
172180
<properties>
173181
<visible value="false"/>
@@ -194,39 +202,39 @@
194202
</grid>
195203
<component id="122dc" class="javax.swing.JLabel">
196204
<constraints>
197-
<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"/>
205+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
198206
</constraints>
199207
<properties>
200208
<text resource-bundle="magento2/common" key="common.cronGroup"/>
201209
</properties>
202210
</component>
203211
<component id="77d9d" class="com.magento.idea.magento2plugin.ui.FilteredComboBox" binding="cronGroupComboBox" custom-create="true">
204212
<constraints>
205-
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
213+
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
206214
</constraints>
207215
<properties>
208216
<toolTipText value=""/>
209217
</properties>
210218
</component>
211219
<component id="d14bf" class="javax.swing.JLabel">
212220
<constraints>
213-
<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"/>
221+
<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"/>
214222
</constraints>
215223
<properties>
216224
<text resource-bundle="magento2/common" key="common.name"/>
217225
</properties>
218226
</component>
219227
<component id="555fd" class="javax.swing.JTextField" binding="cronjobNameField">
220228
<constraints>
221-
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
229+
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
222230
<preferred-size width="150" height="-1"/>
223231
</grid>
224232
</constraints>
225233
<properties/>
226234
</component>
227235
<component id="b2d70" class="javax.swing.JTextField" binding="cronjobDirectoryField">
228236
<constraints>
229-
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
237+
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
230238
<preferred-size width="150" height="-1"/>
231239
</grid>
232240
</constraints>
@@ -235,6 +243,38 @@
235243
<text value="Cron"/>
236244
</properties>
237245
</component>
246+
<component id="d2f0c" class="javax.swing.JLabel" binding="cronjobClassNameFieldErrorMessage">
247+
<constraints>
248+
<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"/>
249+
</constraints>
250+
<properties>
251+
<text value=""/>
252+
</properties>
253+
</component>
254+
<component id="8a62f" class="javax.swing.JLabel" binding="cronjobDirectoryFieldErrorMessage">
255+
<constraints>
256+
<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"/>
257+
</constraints>
258+
<properties>
259+
<text value=""/>
260+
</properties>
261+
</component>
262+
<component id="d9cce" class="javax.swing.JLabel" binding="cronjobNameFieldErrorMessage">
263+
<constraints>
264+
<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"/>
265+
</constraints>
266+
<properties>
267+
<text value=""/>
268+
</properties>
269+
</component>
270+
<component id="7c57c" class="javax.swing.JLabel" binding="cronGroupComboBoxErrorMessage">
271+
<constraints>
272+
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
273+
</constraints>
274+
<properties>
275+
<text value=""/>
276+
</properties>
277+
</component>
238278
</children>
239279
</grid>
240280
</children>

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
2727
import com.magento.idea.magento2plugin.util.CamelCaseToSnakeCase;
2828
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
29-
import org.jetbrains.annotations.NotNull;
30-
3129
import java.awt.event.ActionEvent;
3230
import java.awt.event.FocusEvent;
3331
import java.awt.event.FocusListener;
@@ -37,11 +35,13 @@
3735
import java.util.List;
3836
import javax.swing.JButton;
3937
import javax.swing.JComponent;
38+
import javax.swing.JLabel;
4039
import javax.swing.JOptionPane;
4140
import javax.swing.JPanel;
4241
import javax.swing.JRadioButton;
4342
import javax.swing.JTextField;
4443
import javax.swing.KeyStroke;
44+
import org.jetbrains.annotations.NotNull;
4545

4646
@SuppressWarnings({
4747
"PMD.UncommentedEmptyMethodBody",
@@ -56,6 +56,11 @@
5656
"PMD.ExcessiveImports",
5757
})
5858
public class NewCronjobDialog extends AbstractDialog {
59+
60+
private final Project project;
61+
private final String moduleName;
62+
private final CamelCaseToSnakeCase camelCaseToSnakeCase;
63+
5964
private JPanel contentPane;
6065
private JButton buttonOK;
6166
private JButton buttonCancel;
@@ -66,6 +71,7 @@ public class NewCronjobDialog extends AbstractDialog {
6671
private JRadioButton atMidnightRadioButton;
6772
private JPanel fixedSchedulePanel;
6873
private JPanel configurableSchedulePanel;
74+
6975
private static final String CLASS_NAME = "class name";
7076
private static final String DIRECTORY = "directory";
7177
private static final String CRON_NAME = "name";
@@ -109,9 +115,11 @@ public class NewCronjobDialog extends AbstractDialog {
109115
message = {NotEmptyRule.MESSAGE, CRON_GROUP})
110116
private FilteredComboBox cronGroupComboBox;
111117

112-
private Project project;
113-
private String moduleName;
114-
private CamelCaseToSnakeCase camelCaseToSnakeCase;
118+
private JLabel cronjobClassNameFieldErrorMessage;//NOPMD
119+
private JLabel cronjobDirectoryFieldErrorMessage;//NOPMD
120+
private JLabel cronjobNameFieldErrorMessage;//NOPMD
121+
private JLabel cronGroupComboBoxErrorMessage;//NOPMD
122+
private JLabel cronjobScheduleFieldErrorMessage;//NOPMD
115123

116124
/**
117125
* Open a new cronjob generation dialog form.
@@ -282,10 +290,8 @@ private String suggestCronjobName(final String cronjobClassname) {
282290
*/
283291
private void onOK() {
284292
if (!validateFormFields()) {
285-
exit();
286293
return;
287294
}
288-
289295
final NamespaceBuilder namespaceBuilder = new NamespaceBuilder(
290296
this.getCronjobModule(),
291297
this.getCronjobClassName(),

0 commit comments

Comments
 (0)