Skip to content

Commit 8f3f516

Browse files
author
Vitaliy
authored
Merge branch '2.1.0-develop' into issue-297
2 parents 556bb98 + a9c7c86 commit 8f3f516

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</constraints>
8181
<properties>
8282
<horizontalAlignment value="0"/>
83-
<text value="Regenerate URN mappings:"/>
83+
<text value="Regenerate URN mappings"/>
8484
</properties>
8585
</component>
8686
<component id="aad3b" class="javax.swing.JTextField" binding="magentoVersion">

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@
3333
import org.jetbrains.annotations.NotNull;
3434
import org.jetbrains.annotations.Nullable;
3535

36+
@SuppressWarnings({
37+
"PMD.TooManyFields",
38+
"PMD.TooManyMethods"
39+
})
3640
public class SettingsForm implements PhpFrameworkConfigurable {
37-
3841
private final Project project;
3942
private JCheckBox pluginEnabled;
4043
private JButton buttonReindex;
@@ -77,13 +80,13 @@ public void mouseClicked(final MouseEvent event) {
7780
}
7881
);
7982

80-
buttonReindex.setEnabled(getSettings().pluginEnabled);
81-
regenerateUrnMapButton.setEnabled(getSettings().pluginEnabled);
82-
8383
regenerateUrnMapButton.addMouseListener(
8484
new RegenerateUrnMapListener(project)
8585
);
8686

87+
refreshFormStatus(getSettings().pluginEnabled);
88+
pluginEnabled.addActionListener(e -> refreshFormStatus(pluginEnabled.isSelected()));
89+
8790
moduleDefaultLicenseName.setText(getSettings().defaultLicense);
8891
mftfSupportEnabled.setSelected(getSettings().mftfSupportEnabled);
8992
magentoPath.getTextField().setText(getSettings().magentoPath);
@@ -95,6 +98,15 @@ public void mouseClicked(final MouseEvent event) {
9598
return (JComponent) panel;
9699
}
97100

101+
private void refreshFormStatus(final boolean isEnabled) {
102+
buttonReindex.setEnabled(isEnabled);
103+
regenerateUrnMapButton.setEnabled(isEnabled);
104+
magentoVersion.setEnabled(isEnabled);
105+
mftfSupportEnabled.setEnabled(isEnabled);
106+
magentoPath.setEnabled(isEnabled);
107+
moduleDefaultLicenseName.setEnabled(isEnabled);
108+
}
109+
98110
protected void reindex() {
99111
IndexManager.manualReindex();
100112
MagentoComponentManager.getInstance(project).flushModules();

src/com/magento/idea/magento2plugin/project/validator/SettingsFormValidator.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,31 @@ public SettingsFormValidator(
2424
}
2525

2626
/**
27-
* Validate form.
27+
* Validates form if plugin is enabled.
2828
*
2929
* @throws ConfigurationException Exception
3030
*/
3131
public void validate() throws ConfigurationException {
32-
if (!form.getSettings().pluginEnabled) {
33-
return;
34-
}
35-
36-
if (!MagentoBasePathUtil.isMagentoFolderValid(form.getMagentoPath())) {
37-
throw new ConfigurationException(
38-
validatorBundle.message("validator.package.validPath")
39-
);
40-
}
41-
42-
final String magentoVersion = form.getMagentoVersion();
43-
if (magentoVersion.length() == 0) {
44-
throw new ConfigurationException(
45-
validatorBundle.message("validator.notEmpty", "Magento Version")
46-
);
47-
}
48-
49-
if (!magentoVersion.matches(RegExUtil.MAGENTO_VERSION)
50-
&& !magentoVersion.equals(MagentoVersionUtil.DEFAULT_VERSION)) {
51-
throw new ConfigurationException(
52-
validatorBundle.message("validator.magentoVersionInvalid")
53-
);
32+
if (form.isBeingUsed()) {
33+
if (!MagentoBasePathUtil.isMagentoFolderValid(form.getMagentoPath())) {
34+
throw new ConfigurationException(
35+
validatorBundle.message("validator.package.validPath")
36+
);
37+
}
38+
39+
final String magentoVersion = form.getMagentoVersion();
40+
if (magentoVersion.length() == 0) {
41+
throw new ConfigurationException(
42+
validatorBundle.message("validator.notEmpty", "Magento Version")
43+
);
44+
}
45+
46+
if (!magentoVersion.matches(RegExUtil.MAGENTO_VERSION)
47+
&& !magentoVersion.equals(MagentoVersionUtil.DEFAULT_VERSION)) {
48+
throw new ConfigurationException(
49+
validatorBundle.message("validator.magentoVersionInvalid")
50+
);
51+
}
5452
}
5553
}
56-
}
54+
}

0 commit comments

Comments
 (0)