Configuration: Fix behavior of "output directory" control

Do not show file chooser twice.
Disable/enable control on component initialization and change of
"Use project settings" option

 #KT-16952 Fixed
 #KT-16953 Fixed
This commit is contained in:
Alexey Sedunov
2017-03-20 16:44:23 +03:00
parent f56af41d1e
commit a795a256f4
@@ -153,22 +153,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
"Choose Output Directory", "Choose Output Directory",
false); false);
outputDirectory.addBrowseFolderListener(
"Choose Output Directory",
null,
project,
new FileChooserDescriptor(false, true, false, false, false, false),
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
false
);
copyRuntimeFilesCheckBox.addChangeListener(new ChangeListener() { copyRuntimeFilesCheckBox.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(@NotNull ChangeEvent e) { public void stateChanged(@NotNull ChangeEvent e) {
if (isEnabled) { updateOutputDirEnabled();
outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
}
} }
}); });
@@ -207,6 +195,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
warningLabel.setText(buildOverridingModulesWarning(modulesOverridingProjectSettings)); warningLabel.setText(buildOverridingModulesWarning(modulesOverridingProjectSettings));
} }
} }
updateOutputDirEnabled();
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@@ -302,6 +292,13 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
return !StringUtil.equals(StringUtil.nullize(chooser.getText(), true), currentValue); return !StringUtil.equals(StringUtil.nullize(chooser.getText(), true), currentValue);
} }
private void updateOutputDirEnabled() {
if (isEnabled) {
outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void restrictAPIVersions() { private void restrictAPIVersions() {
String selectedAPIVersion = getSelectedAPIVersion(); String selectedAPIVersion = getSelectedAPIVersion();
@@ -607,6 +604,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
public void setEnabled(boolean value) { public void setEnabled(boolean value) {
isEnabled = value; isEnabled = value;
UIUtil.setEnabled(getContentPane(), value, true); UIUtil.setEnabled(getContentPane(), value, true);
updateOutputDirEnabled();
} }
public CommonCompilerArguments getCommonCompilerArguments() { public CommonCompilerArguments getCommonCompilerArguments() {