diff --git a/java/execution/impl/src/com/intellij/execution/application/JavaApplicationSettingsEditor.java b/java/execution/impl/src/com/intellij/execution/application/JavaApplicationSettingsEditor.java index ef4509f0c6d7..49146db7eac8 100644 --- a/java/execution/impl/src/com/intellij/execution/application/JavaApplicationSettingsEditor.java +++ b/java/execution/impl/src/com/intellij/execution/application/JavaApplicationSettingsEditor.java @@ -1,6 +1,7 @@ // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.application; +import com.intellij.compiler.options.CompileStepBeforeRun; import com.intellij.diagnostic.logging.LogsFragment; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.JavaRunConfigurationExtensionManager; @@ -31,7 +32,7 @@ public class JavaApplicationSettingsEditor extends RunConfigurationFragmentedEdi protected List> createRunFragments() { List> fragments = new ArrayList<>(); BeforeRunComponent beforeRunComponent = new BeforeRunComponent(); - fragments.add(BeforeRunFragment.createComponent(beforeRunComponent)); + fragments.add(BeforeRunFragment.createBeforeRun(beforeRunComponent, CompileStepBeforeRun.ID)); fragments.addAll(BeforeRunFragment.createGroup()); ModuleClasspathCombo.Item item = new ModuleClasspathCombo.Item(ExecutionBundle.message("application.configuration.include.provided.scope")); diff --git a/platform/execution-impl/src/com/intellij/execution/ui/BeforeRunFragment.java b/platform/execution-impl/src/com/intellij/execution/ui/BeforeRunFragment.java index 0bb7001a108e..71c1bfe93cc5 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/BeforeRunFragment.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/BeforeRunFragment.java @@ -5,6 +5,8 @@ import com.intellij.execution.ExecutionBundle; import com.intellij.execution.configurations.RunConfigurationBase; import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Key; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; @@ -15,6 +17,8 @@ import java.util.List; public final class BeforeRunFragment> extends RunConfigurationEditorFragment { private final BeforeRunComponent myComponent; + private final Key myKey; + private RunnerAndConfigurationSettingsImpl mySettings; public static > List> createGroup() { ArrayList> list = new ArrayList<>(); @@ -31,18 +35,25 @@ public final class BeforeRunFragment> extends return list; } - public static > BeforeRunFragment createComponent(BeforeRunComponent component) { - return new BeforeRunFragment<>(component); + public static > BeforeRunFragment createBeforeRun(BeforeRunComponent component, + Key key) { + return new BeforeRunFragment<>(component, key); } - private BeforeRunFragment(BeforeRunComponent component) { + private BeforeRunFragment(BeforeRunComponent component, Key key) { super("beforeRunTasks", ExecutionBundle.message("run.configuration.before.run.task"), ExecutionBundle.message("run.configuration.before.run.group"), wrap(component), -2); myComponent = component; + myKey = key; component.myChangeListener = () -> fireEditorStateChanged(); Disposer.register(this, component); } + @Override + public boolean isInitiallyVisible(S s) { + return ContainerUtil.exists(mySettings.getManager().getBeforeRunTasks(s), task -> task.getProviderId() != myKey); + } + private static JComponent wrap(BeforeRunComponent component) { JPanel panel = new JPanel(new BorderLayout()); JPanel labelPanel = new JPanel(new BorderLayout()); @@ -69,7 +80,8 @@ public final class BeforeRunFragment> extends @Override public void resetEditorFrom(@NotNull RunnerAndConfigurationSettingsImpl s) { - myComponent.reset(s); + mySettings = s; + myComponent.reset(mySettings); } @Override diff --git a/platform/execution-impl/src/com/intellij/execution/ui/RunConfigurationEditorFragment.java b/platform/execution-impl/src/com/intellij/execution/ui/RunConfigurationEditorFragment.java index e52f200cd3cc..dc2fdf48d16e 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/RunConfigurationEditorFragment.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/RunConfigurationEditorFragment.java @@ -25,9 +25,9 @@ public abstract class RunConfigurationEditorFragment SettingsEditorFragment createSettingsTag(String id, String name, String group, - Predicate getter, - BiConsumer setter, - int menuPosition) { + Predicate getter, + BiConsumer setter, + int menuPosition) { Ref> ref = new Ref<>(); TagButton button = new TagButton(name, () -> ref.get().setSelected(false)); RunConfigurationEditorFragment fragment = new RunConfigurationEditorFragment(id, name, group, button, 0) { diff --git a/platform/execution-impl/src/com/intellij/execution/ui/RunnerAndConfigurationSettingsEditor.java b/platform/execution-impl/src/com/intellij/execution/ui/RunnerAndConfigurationSettingsEditor.java index 1e75b1a99884..5b631592b9f5 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/RunnerAndConfigurationSettingsEditor.java +++ b/platform/execution-impl/src/com/intellij/execution/ui/RunnerAndConfigurationSettingsEditor.java @@ -25,14 +25,14 @@ public class RunnerAndConfigurationSettingsEditor extends SettingsEditor)s.getConfiguration()); myConfigurationEditor.resetEditorFrom((RunnerAndConfigurationSettingsImpl)s); + myConfigurationEditor.resetFrom((RunConfigurationBase)s.getConfiguration()); } @Override protected void applyEditorTo(@NotNull RunnerAndConfigurationSettings s) throws ConfigurationException { - myConfigurationEditor.applyTo((RunConfigurationBase)s.getConfiguration()); myConfigurationEditor.applyEditorTo((RunnerAndConfigurationSettingsImpl)s); + myConfigurationEditor.applyTo((RunConfigurationBase)s.getConfiguration()); } @Override