|
11 | 11 | import com.magento.idea.magento2plugin.actions.context.xml.NewLayoutXmlAction; |
12 | 12 | import com.magento.idea.magento2plugin.actions.generation.data.LayoutXmlData; |
13 | 13 | import com.magento.idea.magento2plugin.actions.generation.data.ui.ComboBoxItemData; |
14 | | -import com.magento.idea.magento2plugin.actions.generation.dialog.util.DialogFieldErrorUtil; |
15 | 14 | import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation; |
16 | 15 | import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry; |
17 | 16 | import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierRule; |
18 | 17 | import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule; |
19 | 18 | import com.magento.idea.magento2plugin.actions.generation.generator.LayoutXmlTemplateGenerator; |
20 | | -import com.magento.idea.magento2plugin.bundles.ValidatorBundle; |
21 | 19 | import com.magento.idea.magento2plugin.magento.packages.Areas; |
22 | 20 | import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil; |
23 | 21 | import java.awt.event.KeyEvent; |
@@ -122,7 +120,7 @@ public static void open( |
122 | 120 | * Fire generation process if all fields are valid. |
123 | 121 | */ |
124 | 122 | private void onOK() { |
125 | | - if (validateFormFields() && isUnderscoreCorrect()) { |
| 123 | + if (validateFormFields()) { |
126 | 124 | final String[] layoutNameParts = getLayoutNameParts(); |
127 | 125 | new LayoutXmlTemplateGenerator( |
128 | 126 | new LayoutXmlData( |
@@ -188,51 +186,11 @@ private String[] getLayoutNameParts() { |
188 | 186 | actionName = layoutNameParts[2]; |
189 | 187 | } |
190 | 188 |
|
191 | | - return new String[]{routeName, controllerName, actionName}; |
192 | | - } |
193 | | - |
194 | | - /** |
195 | | - * Check is count of underscore is correct in layout name. |
196 | | - * |
197 | | - * @return boolean |
198 | | - */ |
199 | | - private boolean isUnderscoreCorrect() { |
200 | | - final String name = layoutName.getText().trim(); |
201 | | - |
202 | | - if (name.contains("_")) { |
203 | | - final int count = countUnderscore(name); |
204 | | - |
205 | | - if (count != 0 && count != 2) { |
206 | | - DialogFieldErrorUtil.showErrorMessageForField( |
207 | | - layoutName, |
208 | | - layoutNameErrorMessage, |
209 | | - new ValidatorBundle() |
210 | | - .message("validator.layoutNameUnderscoreQtyInvalid") |
211 | | - ); |
212 | | - |
213 | | - return false; |
214 | | - } |
| 189 | + if (layoutNameParts.length == 2 || layoutNameParts.length > 3) { // NOPMD |
| 190 | + routeName = layoutName.getText().trim(); |
215 | 191 | } |
216 | 192 |
|
217 | | - return true; |
218 | | - } |
219 | | - |
220 | | - /** |
221 | | - * Count underscore symbols in string. |
222 | | - * |
223 | | - * @param name String |
224 | | - * @return int |
225 | | - */ |
226 | | - private int countUnderscore(final String name) { |
227 | | - int count = 0; |
228 | | - |
229 | | - for (int i = 0; i < name.length(); i++) { |
230 | | - if (name.charAt(i) == '_') { //NOPMD |
231 | | - count++; |
232 | | - } |
233 | | - } |
234 | | - |
235 | | - return count; |
| 193 | + return new String[]{routeName, controllerName, actionName}; |
236 | 194 | } |
237 | 195 |
|
238 | 196 | /** |
|
0 commit comments