Skip to content

Commit d669023

Browse files
author
Vitaliy
authored
Merge pull request #180 from coderimus/fix/improve-new-module-form-and-creation-process
Improvement: module name must not be equal to the package name.
2 parents ea5140d + 594d18c commit d669023

File tree

6 files changed

+51
-16
lines changed

6 files changed

+51
-16
lines changed

resources/fileTemplates/internal/Magento Module Composer.json.ft

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
"${PACKAGE}\\\\${MODULE_NAME}\\": ""
2222
}
2323
}
24-
}
24+
}

resources/magento2/common.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
common.package.name=Package Name
2+
common.module.name=Module Name
3+
common.module.version=Module Version
4+
common.module.license=Module's license(s)
5+
common.module.dependencies=Module Dependencies
6+
common.module.description=Module Description
7+
common.ok=OK
8+
common.cancel=Cancel
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
inspection.plugin.duplicateInSameFile=The plugin name already used in this file. For more details see Inspection Description.
2-
inspection.plugin.duplicateInOtherPlaces=The plugin name "{0}" for targeted "{1}" class is already used in the module "{2}" ({3} scope). For more details see Inspection Description.
2+
inspection.plugin.duplicateInOtherPlaces=The plugin name "{0}" for targeted "{1}" class is already used in the module "{2}" ({3} scope). For more details see Inspection Description.

resources/magento2/validation.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ validator.magentoVersionInvalid=Please specify valid Magento version or use 'any
1313
validator.class.targetClassNotFound=Target class is not found. Check the di.xml file
1414
validator.cronSchedule.invalidExpression={0} has invalid cron schedule expression (e.g. * * * * *)
1515
validator.configPath.invalidFormat={0} has invalid config path format (e.g. section/group/field)
16+
validator.moduleNameIsTheSameAsPackage=Module name must be different from the package name
17+
validator.mustNotBeEmptyShouldContainLettersOrNumbers=Must not be empty, should contain letters or numbers

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

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="2" 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="462" height="496"/>
6+
<xy x="48" y="54" width="746" height="596"/>
77
</constraints>
88
<properties>
99
<preferredSize width="450" height="591"/>
@@ -36,15 +36,15 @@
3636
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
3737
</constraints>
3838
<properties>
39-
<text value="OK"/>
39+
<text resource-bundle="magento2/common" key="common.ok"/>
4040
</properties>
4141
</component>
4242
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
4343
<constraints>
4444
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
4545
</constraints>
4646
<properties>
47-
<text value="Cancel"/>
47+
<text resource-bundle="magento2/common" key="common.cancel"/>
4848
</properties>
4949
</component>
5050
</children>
@@ -56,7 +56,9 @@
5656
<constraints>
5757
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
5858
</constraints>
59-
<properties/>
59+
<properties>
60+
<toolTipText value=""/>
61+
</properties>
6062
<border type="none"/>
6163
<children>
6264
<component id="ad3ba" class="javax.swing.JTextField" binding="packageName" default-binding="true">
@@ -65,7 +67,10 @@
6567
<preferred-size width="150" height="-1"/>
6668
</grid>
6769
</constraints>
68-
<properties/>
70+
<properties>
71+
<text value=""/>
72+
<toolTipText resource-bundle="magento2/validation" key="validator.mustNotBeEmptyShouldContainLettersOrNumbers"/>
73+
</properties>
6974
<clientProperties>
7075
<html.disable class="java.lang.Boolean" value="true"/>
7176
</clientProperties>
@@ -75,7 +80,9 @@
7580
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
7681
</constraints>
7782
<properties>
78-
<text value="Package Name"/>
83+
<text resource-bundle="magento2/common" key="common.package.name"/>
84+
<toolTipText value=""/>
85+
<verifyInputWhenFocusTarget value="false"/>
7986
</properties>
8087
</component>
8188
<component id="e4858" class="javax.swing.JTextField" binding="moduleName">
@@ -84,7 +91,10 @@
8491
<preferred-size width="150" height="-1"/>
8592
</grid>
8693
</constraints>
87-
<properties/>
94+
<properties>
95+
<text value=""/>
96+
<toolTipText resource-bundle="magento2/validation" key="validator.mustNotBeEmptyShouldContainLettersOrNumbers"/>
97+
</properties>
8898
<clientProperties>
8999
<html.disable class="java.lang.Boolean" value="true"/>
90100
</clientProperties>
@@ -94,7 +104,8 @@
94104
<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"/>
95105
</constraints>
96106
<properties>
97-
<text value="Module Name"/>
107+
<text resource-bundle="magento2/common" key="common.module.name"/>
108+
<toolTipText value=""/>
98109
</properties>
99110
</component>
100111
<component id="423dc" class="javax.swing.JTextField" binding="moduleVersion">
@@ -115,15 +126,17 @@
115126
<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"/>
116127
</constraints>
117128
<properties>
118-
<text value="Module Version"/>
129+
<text resource-bundle="magento2/common" key="common.module.version"/>
130+
<toolTipText value=""/>
119131
</properties>
120132
</component>
121133
<component id="c5925" class="javax.swing.JLabel" binding="moduleLicenseLabel">
122134
<constraints>
123135
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
124136
</constraints>
125137
<properties>
126-
<text value="License(s)"/>
138+
<text resource-bundle="magento2/common" key="common.module.license"/>
139+
<toolTipText value=""/>
127140
</properties>
128141
</component>
129142
<component id="26905" class="javax.swing.JTextField" binding="moduleLicenseCustom">
@@ -154,7 +167,7 @@
154167
<constraints/>
155168
<properties>
156169
<model/>
157-
<toolTipText value="Module's Lincese"/>
170+
<toolTipText value=""/>
158171
</properties>
159172
</component>
160173
</children>
@@ -164,7 +177,8 @@
164177
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
165178
</constraints>
166179
<properties>
167-
<text value="Module Dependencies"/>
180+
<text resource-bundle="magento2/common" key="common.module.dependencies"/>
181+
<toolTipText value=""/>
168182
</properties>
169183
</component>
170184
<scrollpane id="90d78" binding="moduleDependenciesScrollPanel">
@@ -195,7 +209,7 @@
195209
</constraints>
196210
<properties>
197211
<text value="N/A"/>
198-
<toolTipText value="Module Description"/>
212+
<toolTipText value=""/>
199213
</properties>
200214
<clientProperties>
201215
<html.disable class="java.lang.Boolean" value="true"/>
@@ -206,9 +220,13 @@
206220
<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"/>
207221
</constraints>
208222
<properties>
209-
<text value="Module Description"/>
223+
<text resource-bundle="magento2/common" key="common.module.description"/>
224+
<toolTipText value=""/>
210225
</properties>
211226
</component>
212227
</children>
213228
</grid>
229+
<inspectionSuppressions>
230+
<suppress inspection="I18nForm" id="bda0f"/>
231+
</inspectionSuppressions>
214232
</form>

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewModuleDialogValidator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ public boolean validate()
6666
return false;
6767
}
6868

69+
if (moduleName.equals(packageName)) {
70+
String errorMessage = validatorBundle.message("validator.moduleNameIsTheSameAsPackage", "Module Name");
71+
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
72+
73+
return false;
74+
}
75+
6976
if (!Character.isUpperCase(moduleName.charAt(0)) && !Character.isDigit(moduleName.charAt(0))) {
7077
String errorMessage = validatorBundle.message("validator.startWithNumberOrCapitalLetter", "Module Name");
7178
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);

0 commit comments

Comments
 (0)