mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 15:06:56 +07:00
[compiler] Use UI DSL in JavacConfigurable
#IDEA-334671 GitOrigin-RevId: ecdcfa43f7008c1c7dc2b85423ffbb1d365505ba
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0a10bd37e2
commit
a0e94a1336
@@ -15,14 +15,10 @@
|
||||
*/
|
||||
package com.intellij.compiler.impl.javaCompiler.javac;
|
||||
|
||||
import com.intellij.compiler.impl.javaCompiler.CompilerModuleOptionsComponent;
|
||||
import com.intellij.compiler.options.ComparingUtils;
|
||||
import com.intellij.openapi.compiler.JavaCompilerBundle;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -31,25 +27,12 @@ import javax.swing.*;
|
||||
* @author Eugene Zhuravlev
|
||||
*/
|
||||
public class JavacConfigurable implements Configurable{
|
||||
private JPanel myPanel;
|
||||
private JBCheckBox myCbPreferTargetJdkCompiler;
|
||||
private JCheckBox myCbDebuggingInfo;
|
||||
private JCheckBox myCbDeprecation;
|
||||
private JCheckBox myCbGenerateNoWarnings;
|
||||
private RawCommandLineEditor myAdditionalOptionsField;
|
||||
private CompilerModuleOptionsComponent myOptionsOverride;
|
||||
private final Project myProject;
|
||||
private final JavacConfigurableUi myUi;
|
||||
private final JpsJavaCompilerOptions myJavacSettings;
|
||||
|
||||
public JavacConfigurable(Project project, final JpsJavaCompilerOptions javacSettings) {
|
||||
myProject = project;
|
||||
myJavacSettings = javacSettings;
|
||||
myAdditionalOptionsField.setDialogCaption(JavaCompilerBundle.message("java.compiler.option.additional.command.line.parameters"));
|
||||
myAdditionalOptionsField.setDescriptor(null, false);
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myOptionsOverride = new CompilerModuleOptionsComponent(myProject);
|
||||
myUi = new JavacConfigurableUi(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,40 +47,40 @@ public class JavacConfigurable implements Configurable{
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
return myPanel;
|
||||
return myUi.getPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
boolean isModified = false;
|
||||
isModified |= ComparingUtils.isModified(myCbPreferTargetJdkCompiler, myJavacSettings.PREFER_TARGET_JDK_COMPILER);
|
||||
isModified |= ComparingUtils.isModified(myCbDeprecation, myJavacSettings.DEPRECATION);
|
||||
isModified |= ComparingUtils.isModified(myCbDebuggingInfo, myJavacSettings.DEBUGGING_INFO);
|
||||
isModified |= ComparingUtils.isModified(myCbGenerateNoWarnings, myJavacSettings.GENERATE_NO_WARNINGS);
|
||||
isModified |= ComparingUtils.isModified(myAdditionalOptionsField, myJavacSettings.ADDITIONAL_OPTIONS_STRING);
|
||||
isModified |= !myOptionsOverride.getModuleOptionsMap().equals(myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE);
|
||||
isModified |= ComparingUtils.isModified(myUi.preferTargetJdkCompilerCb, myJavacSettings.PREFER_TARGET_JDK_COMPILER);
|
||||
isModified |= ComparingUtils.isModified(myUi.deprecationCb, myJavacSettings.DEPRECATION);
|
||||
isModified |= ComparingUtils.isModified(myUi.debuggingInfoCb, myJavacSettings.DEBUGGING_INFO);
|
||||
isModified |= ComparingUtils.isModified(myUi.generateNoWarningsCb, myJavacSettings.GENERATE_NO_WARNINGS);
|
||||
isModified |= ComparingUtils.isModified(myUi.additionalOptionsField, myJavacSettings.ADDITIONAL_OPTIONS_STRING);
|
||||
isModified |= !myUi.optionsOverrideComponent.getModuleOptionsMap().equals(myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE);
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
myJavacSettings.PREFER_TARGET_JDK_COMPILER = myCbPreferTargetJdkCompiler.isSelected();
|
||||
myJavacSettings.DEPRECATION = myCbDeprecation.isSelected();
|
||||
myJavacSettings.DEBUGGING_INFO = myCbDebuggingInfo.isSelected();
|
||||
myJavacSettings.GENERATE_NO_WARNINGS = myCbGenerateNoWarnings.isSelected();
|
||||
myJavacSettings.ADDITIONAL_OPTIONS_STRING = myAdditionalOptionsField.getText();
|
||||
myJavacSettings.PREFER_TARGET_JDK_COMPILER = myUi.preferTargetJdkCompilerCb.isSelected();
|
||||
myJavacSettings.DEPRECATION = myUi.deprecationCb.isSelected();
|
||||
myJavacSettings.DEBUGGING_INFO = myUi.debuggingInfoCb.isSelected();
|
||||
myJavacSettings.GENERATE_NO_WARNINGS = myUi.generateNoWarningsCb.isSelected();
|
||||
myJavacSettings.ADDITIONAL_OPTIONS_STRING = myUi.additionalOptionsField.getText();
|
||||
myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE.clear();
|
||||
myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE.putAll(myOptionsOverride.getModuleOptionsMap());
|
||||
myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE.putAll(myUi.optionsOverrideComponent.getModuleOptionsMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
myCbPreferTargetJdkCompiler.setSelected(myJavacSettings.PREFER_TARGET_JDK_COMPILER);
|
||||
myCbDeprecation.setSelected(myJavacSettings.DEPRECATION);
|
||||
myCbDebuggingInfo.setSelected(myJavacSettings.DEBUGGING_INFO);
|
||||
myCbGenerateNoWarnings.setSelected(myJavacSettings.GENERATE_NO_WARNINGS);
|
||||
myAdditionalOptionsField.setText(myJavacSettings.ADDITIONAL_OPTIONS_STRING);
|
||||
myOptionsOverride.setModuleOptionsMap(myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE);
|
||||
myUi.preferTargetJdkCompilerCb.setSelected(myJavacSettings.PREFER_TARGET_JDK_COMPILER);
|
||||
myUi.deprecationCb.setSelected(myJavacSettings.DEPRECATION);
|
||||
myUi.debuggingInfoCb.setSelected(myJavacSettings.DEBUGGING_INFO);
|
||||
myUi.generateNoWarningsCb.setSelected(myJavacSettings.GENERATE_NO_WARNINGS);
|
||||
myUi.additionalOptionsField.setText(myJavacSettings.ADDITIONAL_OPTIONS_STRING);
|
||||
myUi.optionsOverrideComponent.setModuleOptionsMap(myJavacSettings.ADDITIONAL_OPTIONS_OVERRIDE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.compiler.impl.javaCompiler.javac
|
||||
|
||||
import com.intellij.compiler.impl.javaCompiler.CompilerModuleOptionsComponent
|
||||
import com.intellij.openapi.compiler.JavaCompilerBundle
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.ui.RawCommandLineEditor
|
||||
import com.intellij.ui.components.JBCheckBox
|
||||
import com.intellij.ui.dsl.builder.*
|
||||
import javax.swing.JCheckBox
|
||||
|
||||
class JavacConfigurableUi(project: Project) {
|
||||
lateinit var preferTargetJdkCompilerCb: JBCheckBox
|
||||
lateinit var debuggingInfoCb: JCheckBox
|
||||
lateinit var deprecationCb: JCheckBox
|
||||
lateinit var generateNoWarningsCb: JCheckBox
|
||||
lateinit var additionalOptionsField: RawCommandLineEditor
|
||||
lateinit var optionsOverrideComponent: CompilerModuleOptionsComponent
|
||||
|
||||
val panel = panel {
|
||||
group(JavaCompilerBundle.message("javac.options.group.title")) {
|
||||
row {
|
||||
preferTargetJdkCompilerCb = checkBox(JavaCompilerBundle.message("java.compiler.option.prefer.target.jdk.compiler"))
|
||||
.component
|
||||
}
|
||||
|
||||
row {
|
||||
debuggingInfoCb = checkBox(JavaCompilerBundle.message("java.compiler.option.generate.debugging.info"))
|
||||
.component
|
||||
}
|
||||
|
||||
row {
|
||||
deprecationCb = checkBox(JavaCompilerBundle.message("java.compiler.option.report.deprecated"))
|
||||
.component
|
||||
}
|
||||
|
||||
row {
|
||||
generateNoWarningsCb = checkBox(JavaCompilerBundle.message("java.compiler.option.generate.no.warnings"))
|
||||
.component
|
||||
}
|
||||
.bottomGap(BottomGap.SMALL)
|
||||
|
||||
row {
|
||||
additionalOptionsField = cell(RawCommandLineEditor())
|
||||
.resizableColumn()
|
||||
.align(AlignX.FILL)
|
||||
.applyToComponent { setDescriptor(null, false) }
|
||||
.label(
|
||||
JavaCompilerBundle.message("java.compiler.option.additional.command.line.parameters"),
|
||||
LabelPosition.TOP
|
||||
)
|
||||
.comment(JavaCompilerBundle.message("settings.recommended.in.paths"))
|
||||
.component
|
||||
}
|
||||
.bottomGap(BottomGap.SMALL)
|
||||
|
||||
row {
|
||||
optionsOverrideComponent = cell(CompilerModuleOptionsComponent(project))
|
||||
.resizableColumn()
|
||||
.align(AlignX.FILL)
|
||||
.component
|
||||
}
|
||||
.resizableRow()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.compiler.impl.javaCompiler.javac.JavacConfigurable">
|
||||
<grid id="280f7" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="79" y="160" width="692" height="212"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/JavaCompilerBundle" title-key="javac.options.group.title"/>
|
||||
<children>
|
||||
<component id="8538e" class="javax.swing.JCheckBox" binding="myCbDeprecation">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="java.compiler.option.report.deprecated"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3d38f" class="javax.swing.JCheckBox" binding="myCbDebuggingInfo">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="java.compiler.option.generate.debugging.info"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="90803" class="javax.swing.JCheckBox" binding="myCbGenerateNoWarnings">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="java.compiler.option.generate.no.warnings"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3752c" class="com.intellij.ui.components.JBCheckBox" binding="myCbPreferTargetJdkCompiler">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="java.compiler.option.prefer.target.jdk.compiler"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e7c13" class="com.intellij.compiler.impl.javaCompiler.CompilerModuleOptionsComponent" binding="myOptionsOverride" custom-create="true" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="f8a80" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="java.compiler.option.additional.command.line.parameters"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d321" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.recommended.in.paths"/>
|
||||
<toolTipText resource-bundle="messages/JavaCompilerBundle" key="settings.recommended.in.paths"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="479c2" class="com.intellij.ui.RawCommandLineEditor" binding="myAdditionalOptionsField">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -149,7 +149,7 @@ settings.same.as.language.level=Same as language level
|
||||
settings.all.modules.will.be.compiled.with.project.bytecode.version=All modules will be compiled with project bytecode version
|
||||
settings.module.column=Module
|
||||
settings.target.bytecode.version=Target bytecode version
|
||||
settings.recommended.in.paths=('/' recommended in paths for cross-platform configurations)
|
||||
settings.recommended.in.paths='/' recommended in paths for cross-platform configurations
|
||||
settings.override.compiler.parameters.per.module=Override compiler parameters per-module:
|
||||
settings.override.module.column=Module
|
||||
settings.override.compilation.options.column=Compilation options
|
||||
|
||||
Reference in New Issue
Block a user