Skip to content

Commit f71c17d

Browse files
author
Vitaliy Boyko
committed
267: static fixes
1 parent d909ef8 commit f71c17d

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

src/com/magento/idea/magento2plugin/project/SettingsForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class SettingsForm implements PhpFrameworkConfigurable {
4444
private JTextField moduleDefaultLicenseName;
4545
private JCheckBox mftfSupportEnabled;
4646
private TextFieldWithBrowseButton magentoPath;
47-
private final SettingsFormValidator validator = SettingsFormValidator.getInstance(this);
47+
private final SettingsFormValidator validator = new SettingsFormValidator(this);
4848
private JLabel magentoVersionLabel;//NOPMD
4949
private JLabel magentoPathLabel;//NOPMD
5050

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
1-
/**
1+
/*
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.project.validator;
67

78
import com.intellij.openapi.options.ConfigurationException;
8-
import com.magento.idea.magento2plugin.util.magento.MagentoVersionUtil;
99
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
1010
import com.magento.idea.magento2plugin.project.SettingsForm;
1111
import com.magento.idea.magento2plugin.util.RegExUtil;
1212
import com.magento.idea.magento2plugin.util.magento.MagentoBasePathUtil;
13+
import com.magento.idea.magento2plugin.util.magento.MagentoVersionUtil;
1314

1415
public class SettingsFormValidator {
15-
private static SettingsFormValidator INSTANCE = null;
16-
private SettingsForm form;
17-
private ValidatorBundle validatorBundle;
18-
19-
public static SettingsFormValidator getInstance(SettingsForm form) {
20-
if (null == INSTANCE) {
21-
INSTANCE = new SettingsFormValidator();
22-
}
23-
INSTANCE.form = form;
24-
return INSTANCE;
25-
}
16+
private final SettingsForm form;
17+
private final ValidatorBundle validatorBundle;
2618

27-
public SettingsFormValidator() {
19+
public SettingsFormValidator(
20+
final SettingsForm form
21+
) {
22+
this.form = form;
2823
this.validatorBundle = new ValidatorBundle();
2924
}
3025

26+
/**
27+
* Validate form.
28+
*
29+
* @throws ConfigurationException
30+
*/
3131
public void validate() throws ConfigurationException {
3232
if (!form.getSettings().pluginEnabled) {
3333
return;
3434
}
3535

3636
if (!MagentoBasePathUtil.isMagentoFolderValid(form.getMagentoPath())) {
37-
throw new ConfigurationException(validatorBundle.message("validator.package.validPath"));
37+
throw new ConfigurationException(
38+
validatorBundle.message("validator.package.validPath")
39+
);
3840
}
3941

40-
String magentoVersion = form.getMagentoVersion();
42+
final String magentoVersion = form.getMagentoVersion();
4143
if (magentoVersion.length() == 0) {
42-
throw new ConfigurationException(validatorBundle.message("validator.notEmpty", "Magento Version"));
44+
throw new ConfigurationException(
45+
validatorBundle.message("validator.notEmpty", "Magento Version")
46+
);
4347
}
4448

45-
if (!magentoVersion.matches(RegExUtil.MAGENTO_VERSION) && !magentoVersion.equals(MagentoVersionUtil.DEFAULT_VERSION)) {
46-
throw new ConfigurationException(validatorBundle.message("validator.magentoVersionInvalid"));
49+
if (!magentoVersion.matches(RegExUtil.MAGENTO_VERSION) &&
50+
!magentoVersion.equals(MagentoVersionUtil.DEFAULT_VERSION)) {
51+
throw new ConfigurationException(
52+
validatorBundle.message("validator.magentoVersionInvalid")
53+
);
4754
}
4855
}
4956
}

0 commit comments

Comments
 (0)