Configuration: Fix behavior of "output directory" control

#KT-17088 Fixed
This commit is contained in:
Alexey Sedunov
2017-03-27 15:56:27 +03:00
parent 72436c1738
commit 3f7b28d840
2 changed files with 14 additions and 12 deletions
@@ -74,7 +74,7 @@
<text value="lib"/>
</properties>
</component>
<component id="97317" class="com.intellij.util.ui.ThreeStateCheckBox" binding="copyRuntimeFilesCheckBox">
<component id="97317" class="com.intellij.util.ui.ThreeStateCheckBox" binding="copyRuntimeFilesCheckBox" custom-create="true">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
@@ -56,8 +56,6 @@ import org.jetbrains.kotlin.idea.facet.KotlinFacet;
import org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
@@ -154,13 +152,6 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
"Choose Output Directory",
false);
copyRuntimeFilesCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
updateOutputDirEnabled();
}
});
fillModuleKindList();
fillJvmVersionList();
fillLanguageAndAPIVersionList();
@@ -299,7 +290,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
}
private void updateOutputDirEnabled() {
if (isEnabled) {
if (isEnabled && copyRuntimeFilesCheckBox != null) {
outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
}
@@ -618,7 +609,6 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
public void setEnabled(boolean value) {
isEnabled = value;
UIUtil.setEnabled(getContentPane(), value, true);
updateOutputDirEnabled();
}
public CommonCompilerArguments getCommonCompilerArguments() {
@@ -652,4 +642,16 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
public void setCompilerSettings(CompilerSettings compilerSettings) {
this.compilerSettings = compilerSettings;
}
private void createUIComponents() {
// Workaround: ThreeStateCheckBox doesn't send suitable notification on state change
// TODO: replace with PropertyChangerListener after fix is available in IDEA
copyRuntimeFilesCheckBox = new ThreeStateCheckBox() {
@Override
public void setState(State state) {
super.setState(state);
updateOutputDirEnabled();
}
};
}
}