From 939209cf812e5bb11b0ce9411f63bef89a9550fe Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Thu, 16 May 2019 14:39:23 +0200 Subject: [PATCH] IDEA-210281 Cleanup Gradle settings: Module per source set setting is deprecated GitOrigin-RevId: 821c9da03b55b776bb8a3b507ec95f917b98034f --- .../plugin-resources/META-INF/plugin.xml | 3 ++ ...eaGradleProjectSettingsControlBuilder.java | 29 ++++++++++++------- ...deaGradleSystemSettingsControlBuilder.java | 1 + 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/gradle/plugin-resources/META-INF/plugin.xml b/plugins/gradle/plugin-resources/META-INF/plugin.xml index 07f820f79e8f..a78200d6e647 100644 --- a/plugins/gradle/plugin-resources/META-INF/plugin.xml +++ b/plugins/gradle/plugin-resources/META-INF/plugin.xml @@ -120,6 +120,9 @@ + + diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleProjectSettingsControlBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleProjectSettingsControlBuilder.java index 9a487b12dc8e..c882145f7022 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleProjectSettingsControlBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleProjectSettingsControlBuilder.java @@ -115,6 +115,7 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet @Nullable private JBCheckBox myResolveModulePerSourceSetCheckBox; + private JBLabel myResolveModulePerSourceSetHintLabel; private boolean dropResolveModulePerSourceSetCheckBox; @Nullable @@ -301,18 +302,21 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet myImportPanel = addComponentsGroup(null, content, indentLevel, panel -> { if (!dropResolveModulePerSourceSetCheckBox) { panel.add( - myResolveModulePerSourceSetCheckBox = new JBCheckBox("Generate separate " + getIDEName() + " module per Gradle source set"), + myResolveModulePerSourceSetCheckBox = new JBCheckBox("Generate " + getIDEName() + " module per Gradle source set"), ExternalSystemUiUtil.getFillLineConstraints(indentLevel)); - JBLabel label = new JBLabel( - XmlStringUtil.wrapInHtml("Disable to ???"), + myResolveModulePerSourceSetHintLabel = new JBLabel( + XmlStringUtil.wrapInHtml("This setting is deprecated and remains only for troubleshooting since it's not fully compatible with the Gradle's model.
" + + "Please consider restoring it to the default (checked)"), UIUtil.ComponentStyle.SMALL); - label.setForeground(UIUtil.getLabelFontColor(UIUtil.FontColor.BRIGHTER)); + myResolveModulePerSourceSetHintLabel.setIcon(AllIcons.General.BalloonWarning12); + myResolveModulePerSourceSetHintLabel.setVerticalTextPosition(SwingConstants.TOP); + myResolveModulePerSourceSetHintLabel.setForeground(UIUtil.getLabelFontColor(UIUtil.FontColor.BRIGHTER)); GridBag constraints = ExternalSystemUiUtil.getFillLineConstraints(indentLevel); constraints.insets.top = 0; constraints.insets.left += UIUtil.getCheckBoxTextHorizontalOffset(myResolveModulePerSourceSetCheckBox); - panel.add(label, constraints); + panel.add(myResolveModulePerSourceSetHintLabel, constraints); } if (!dropResolveExternalAnnotationsCheckBox) { @@ -631,12 +635,7 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet myGradleHomePathField.setText(gradleHome == null ? "" : gradleHome); myGradleHomePathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor()); } - if (myResolveModulePerSourceSetCheckBox != null) { - myResolveModulePerSourceSetCheckBox.setSelected(settings.isResolveModulePerSourceSet()); - } - if (myResolveExternalAnnotationsCheckBox != null) { - myResolveExternalAnnotationsCheckBox.setSelected(settings.isResolveExternalAnnotations()); - } + resetImportControls(settings); resetGradleJdkComboBox(project, settings, wizardContext); resetWrapperControls(settings.getExternalProjectPath(), settings, isDefaultModuleCreation); @@ -661,8 +660,16 @@ public class IdeaGradleProjectSettingsControlBuilder implements GradleProjectSet @Override public void update(String linkedProjectPath, GradleProjectSettings settings, boolean isDefaultModuleCreation) { resetWrapperControls(linkedProjectPath, settings, isDefaultModuleCreation); + resetImportControls(settings); + } + + private void resetImportControls(GradleProjectSettings settings) { if (myResolveModulePerSourceSetCheckBox != null) { myResolveModulePerSourceSetCheckBox.setSelected(settings.isResolveModulePerSourceSet()); + boolean showSetting = !settings.isResolveModulePerSourceSet() + || Registry.is("gradle.settings.showModulePerSourceSetSetting", false); + myResolveModulePerSourceSetCheckBox.setVisible(showSetting); + myResolveModulePerSourceSetHintLabel.setVisible(showSetting); } if (myResolveExternalAnnotationsCheckBox != null) { myResolveExternalAnnotationsCheckBox.setSelected(settings.isResolveExternalAnnotations()); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleSystemSettingsControlBuilder.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleSystemSettingsControlBuilder.java index 5a0ab26248c4..34cc8160a7fb 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleSystemSettingsControlBuilder.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/settings/IdeaGradleSystemSettingsControlBuilder.java @@ -248,6 +248,7 @@ public class IdeaGradleSystemSettingsControlBuilder implements GradleSystemSetti fixLabel.setFontSize(UIUtil.FontSize.SMALL); fixLabel.setForeground(UIUtil.getLabelFontColor(UIUtil.FontColor.BRIGHTER)); fixLabel.setIcon(AllIcons.General.BalloonWarning12); + label.setVerticalTextPosition(SwingConstants.TOP); GridBag constraints = ExternalSystemUiUtil.getFillLineConstraints(indentLevel); constraints.insets.top = 0; canvas.add(fixLabel, constraints);