File tree Expand file tree Collapse file tree 6 files changed +27
-2
lines changed
src/com/magento/idea/magento2plugin/actions/generation/dialog Expand file tree Collapse file tree 6 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 11validator.notEmpty =The {0} field must not be empty
2+ validator.box.notEmpty =The {0} field must contain a valid selection from the dropdown
23validator.package.validPath =Please specify a valid Magento 2 installation path
34validator.alphaNumericCharacters =The {0} must contain letters and numbers only
45validator.alphaNumericAndUnderscoreCharacters ={0} must contain letters, numbers and underscores only
Original file line number Diff line number Diff line change @@ -184,7 +184,11 @@ private String resolveFieldValueByComponentType(final Object field) {
184184 if (field instanceof JTextField ) {
185185 return ((JTextField ) field ).isEditable () ? ((JTextField ) field ).getText () : null ;
186186 } else if (field instanceof JComboBox ) {
187- return ((JComboBox ) field ).getSelectedItem ().toString ();
187+ try {
188+ return ((JComboBox ) field ).getSelectedItem ().toString ();
189+ } catch (NullPointerException exception ) {
190+ return "" ;
191+ }
188192 }
189193 return null ;
190194 }
Original file line number Diff line number Diff line change 1212import com .magento .idea .magento2plugin .actions .generation .data .CrontabXmlData ;
1313import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .FieldValidation ;
1414import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .RuleRegistry ;
15+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .BoxNotEmptyRule ;
1516import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .ConfigPathRule ;
1617import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .CronScheduleRule ;
1718import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .DirectoryRule ;
@@ -100,6 +101,8 @@ public class NewCronjobDialog extends AbstractDialog {
100101 message = {ConfigPathRule .MESSAGE , CONFIG_PATH })
101102 private JTextField configPathField ;
102103
104+ @ FieldValidation (rule = RuleRegistry .BOX_NOT_EMPTY ,
105+ message = {BoxNotEmptyRule .MESSAGE , CRON_GROUP })
103106 @ FieldValidation (rule = RuleRegistry .NOT_EMPTY ,
104107 message = {NotEmptyRule .MESSAGE , CRON_GROUP })
105108 private FilteredComboBox cronGroupComboBox ;
Original file line number Diff line number Diff line change 88import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .AclResourceIdRule ;
99import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .AlphanumericRule ;
1010import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .AlphanumericWithUnderscoreRule ;
11+ import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .BoxNotEmptyRule ;
1112import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .ConfigPathRule ;
1213import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .CronScheduleRule ;
1314import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .DirectoryRule ;
2324
2425public enum RuleRegistry {
2526 NOT_EMPTY (NotEmptyRule .class ),
27+ BOX_NOT_EMPTY (BoxNotEmptyRule .class ),
2628 PHP_CLASS (PhpClassRule .class ),
2729 ROUTE_ID (RouteIdRule .class ),
2830 ALPHANUMERIC (AlphanumericRule .class ),
Original file line number Diff line number Diff line change 1+ package com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule ;
2+
3+ public class BoxNotEmptyRule implements ValidationRule {
4+ public static final String MESSAGE = "validator.box.notEmpty" ;
5+ private static final ValidationRule INSTANCE = new BoxNotEmptyRule ();
6+
7+ @ Override
8+ public boolean check (final String value ) {
9+ return !value .isEmpty ();
10+ }
11+
12+ public static ValidationRule getInstance () {
13+ return INSTANCE ;
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public class NotEmptyRule implements ValidationRule {
1111
1212 @ Override
1313 public boolean check (final String value ) {
14- return value .length () != 0 ;
14+ return ! value .isEmpty () ;
1515 }
1616
1717 public static ValidationRule getInstance () {
You can’t perform that action at this time.
0 commit comments