Skip to content

Commit cc135f0

Browse files
875: Enhanced error outputting for new Magento 2 data model generation
1 parent 58d6269 commit cc135f0

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

resources/magento2/validation.properties

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
validator.notEmpty=The {0} field must not be empty
22
validator.box.notEmpty=The {0} field must contain a valid selection from the dropdown
33
validator.package.validPath=Please specify a valid Magento 2 installation path
4+
validator.properties.notEmpty=The properties must not be empty
45
validator.alphaNumericCharacters=The {0} field must contain letters and numbers only
56
validator.alphaNumericAndUnderscoreCharacters={0} must contain letters, numbers and underscores only
67
validator.alphaAndPeriodCharacters=The {0} field must contain alphabets and periods only

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</properties>
1111
<border type="none"/>
1212
<children>
13-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
13+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1414
<margin top="0" left="0" bottom="0" right="0"/>
1515
<constraints>
1616
<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"/>
@@ -36,6 +36,14 @@
3636
<text value=""/>
3737
</properties>
3838
</component>
39+
<component id="8fecc" class="javax.swing.JLabel" binding="modelNameErrorMessage">
40+
<constraints>
41+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
42+
</constraints>
43+
<properties>
44+
<text value=""/>
45+
</properties>
46+
</component>
3947
</children>
4048
</grid>
4149
<grid id="ebe15" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

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

+14
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.swing.JButton;
4141
import javax.swing.JCheckBox;
4242
import javax.swing.JComponent;
43+
import javax.swing.JLabel;
4344
import javax.swing.JOptionPane;
4445
import javax.swing.JPanel;
4546
import javax.swing.JTable;
@@ -77,6 +78,8 @@ public class NewDataModelDialog extends AbstractDialog {
7778
@FieldValidation(rule = RuleRegistry.PHP_CLASS, message = {PhpClassRule.MESSAGE, MODEL_NAME})
7879
private JTextField modelName;
7980

81+
private JLabel modelNameErrorMessage;//NOPMD
82+
8083
/**
8184
* Constructor.
8285
*/
@@ -162,6 +165,17 @@ protected boolean validateFormFields() {
162165
valid = true;
163166
final String errorTitle = commonBundle.message("common.error");
164167
final int column = 0;
168+
169+
if (propertyTable.getRowCount() == 0) {
170+
valid = false;
171+
JOptionPane.showMessageDialog(
172+
null,
173+
validatorBundle.message("validator.properties.notEmpty"),
174+
errorTitle,
175+
JOptionPane.ERROR_MESSAGE
176+
);
177+
}
178+
165179
for (int row = 0; row < propertyTable.getRowCount(); row++) {
166180
final String propertyName = ((String) propertyTable.getValueAt(row, column)).trim();
167181
if (propertyName.isEmpty()) {

0 commit comments

Comments
 (0)