mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IDEA-173655 Poor text wrapping in the inspections Options
This commit is contained in:
@@ -27,6 +27,11 @@ import com.siyeh.ig.fixes.IntroduceVariableFix;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.intellij.codeInspection.InspectionsBundle.message;
|
||||
import static com.intellij.xml.util.XmlStringUtil.wrapInHtml;
|
||||
import static javax.swing.SwingConstants.TOP;
|
||||
|
||||
public class DataFlowInspection extends DataFlowInspectionBase {
|
||||
@Override
|
||||
@@ -71,7 +76,17 @@ public class DataFlowInspection extends DataFlowInspectionBase {
|
||||
return new NullableStuffInspection.NavigateToNullLiteralArguments(parameter);
|
||||
}
|
||||
|
||||
private static JCheckBox createCheckBoxWithHTML(String text, boolean selected, Consumer<JCheckBox> consumer) {
|
||||
JCheckBox box = new JCheckBox(wrapInHtml(text));
|
||||
box.setVerticalTextPosition(TOP);
|
||||
box.setSelected(selected);
|
||||
box.getModel().addItemListener(event -> consumer.accept(box));
|
||||
return box;
|
||||
}
|
||||
|
||||
private class OptionsPanel extends JPanel {
|
||||
private static final int BUTTON_OFFSET = 20;
|
||||
private final JButton myConfigureAnnotations;
|
||||
private final JCheckBox myIgnoreAssertions;
|
||||
private final JCheckBox myReportConstantReferences;
|
||||
private final JCheckBox mySuggestNullables;
|
||||
@@ -90,53 +105,48 @@ public class DataFlowInspection extends DataFlowInspectionBase {
|
||||
gc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gc.anchor = GridBagConstraints.NORTHWEST;
|
||||
|
||||
mySuggestNullables = new JCheckBox(
|
||||
InspectionsBundle.message("inspection.data.flow.nullable.quickfix.option"));
|
||||
mySuggestNullables.setSelected(SUGGEST_NULLABLE_ANNOTATIONS);
|
||||
mySuggestNullables.getModel().addItemListener(e -> SUGGEST_NULLABLE_ANNOTATIONS = mySuggestNullables.isSelected());
|
||||
mySuggestNullables = createCheckBoxWithHTML(
|
||||
message("inspection.data.flow.nullable.quickfix.option"),
|
||||
SUGGEST_NULLABLE_ANNOTATIONS, box -> SUGGEST_NULLABLE_ANNOTATIONS = box.isSelected());
|
||||
|
||||
myDontReportTrueAsserts = new JCheckBox(
|
||||
InspectionsBundle.message("inspection.data.flow.true.asserts.option"));
|
||||
myDontReportTrueAsserts.setSelected(DONT_REPORT_TRUE_ASSERT_STATEMENTS);
|
||||
myDontReportTrueAsserts.getModel().addItemListener(e -> DONT_REPORT_TRUE_ASSERT_STATEMENTS = myDontReportTrueAsserts.isSelected());
|
||||
|
||||
myIgnoreAssertions = new JCheckBox("Ignore assert statements");
|
||||
myIgnoreAssertions.setSelected(IGNORE_ASSERT_STATEMENTS);
|
||||
myIgnoreAssertions.getModel().addItemListener(e -> IGNORE_ASSERT_STATEMENTS = myIgnoreAssertions.isSelected());
|
||||
myDontReportTrueAsserts = createCheckBoxWithHTML(
|
||||
message("inspection.data.flow.true.asserts.option"),
|
||||
DONT_REPORT_TRUE_ASSERT_STATEMENTS, box -> DONT_REPORT_TRUE_ASSERT_STATEMENTS = box.isSelected());
|
||||
|
||||
myReportConstantReferences = new JCheckBox("Warn when reading a value guaranteed to be constant");
|
||||
myReportConstantReferences.setSelected(REPORT_CONSTANT_REFERENCE_VALUES);
|
||||
myReportConstantReferences.getModel().addItemListener(
|
||||
e -> REPORT_CONSTANT_REFERENCE_VALUES = myReportConstantReferences.isSelected());
|
||||
myIgnoreAssertions = createCheckBoxWithHTML(
|
||||
"Ignore assert statements",
|
||||
IGNORE_ASSERT_STATEMENTS, box -> IGNORE_ASSERT_STATEMENTS = box.isSelected());
|
||||
|
||||
myTreatUnknownMembersAsNullable = new JCheckBox("Treat non-annotated members and parameters as @Nullable");
|
||||
myTreatUnknownMembersAsNullable.setSelected(TREAT_UNKNOWN_MEMBERS_AS_NULLABLE);
|
||||
myTreatUnknownMembersAsNullable.getModel().addItemListener(
|
||||
e -> TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = myTreatUnknownMembersAsNullable.isSelected());
|
||||
myReportConstantReferences = createCheckBoxWithHTML(
|
||||
"Warn when reading a value guaranteed to be constant",
|
||||
REPORT_CONSTANT_REFERENCE_VALUES, box -> REPORT_CONSTANT_REFERENCE_VALUES = box.isSelected());
|
||||
|
||||
myReportNullArguments = new JCheckBox("Report not-null required parameter with null-literal argument usages");
|
||||
myReportNullArguments.setSelected(REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER);
|
||||
myReportNullArguments.getModel().addItemListener(e -> REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER = myReportNullArguments.isSelected());
|
||||
myTreatUnknownMembersAsNullable = createCheckBoxWithHTML(
|
||||
"Treat non-annotated members and parameters as @Nullable",
|
||||
TREAT_UNKNOWN_MEMBERS_AS_NULLABLE, box -> TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = box.isSelected());
|
||||
|
||||
myReportNullableMethodsReturningNotNull = new JCheckBox("Report nullable methods that always return a non-null value");
|
||||
myReportNullableMethodsReturningNotNull.setSelected(REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL);
|
||||
myReportNullableMethodsReturningNotNull.getModel().addItemListener(
|
||||
e -> REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL = myReportNullableMethodsReturningNotNull.isSelected());
|
||||
myReportNullArguments = createCheckBoxWithHTML(
|
||||
"Report not-null required parameter with null-literal argument usages",
|
||||
REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER, box -> REPORT_NULLS_PASSED_TO_NOT_NULL_PARAMETER = box.isSelected());
|
||||
|
||||
myReportUncheckedOptionals = new JCheckBox("Report Optional.get() calls without previous isPresent check");
|
||||
myReportUncheckedOptionals.setSelected(REPORT_UNCHECKED_OPTIONALS);
|
||||
myReportUncheckedOptionals.getModel().addItemListener(e -> REPORT_UNCHECKED_OPTIONALS = myReportUncheckedOptionals.isSelected());
|
||||
myReportNullableMethodsReturningNotNull = createCheckBoxWithHTML(
|
||||
"Report nullable methods that always return a non-null value",
|
||||
REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL, box -> REPORT_NULLABLE_METHODS_RETURNING_NOT_NULL = box.isSelected());
|
||||
|
||||
myReportUncheckedOptionals = createCheckBoxWithHTML(
|
||||
"Report Optional.get() calls without previous isPresent check",
|
||||
REPORT_UNCHECKED_OPTIONALS, box -> REPORT_UNCHECKED_OPTIONALS = box.isSelected());
|
||||
|
||||
gc.insets = JBUI.emptyInsets();
|
||||
gc.gridy = 0;
|
||||
add(mySuggestNullables, gc);
|
||||
|
||||
final JButton configureAnnotations = NullableNotNullDialog.createConfigureAnnotationsButton(this);
|
||||
myConfigureAnnotations = NullableNotNullDialog.createConfigureAnnotationsButton(this);
|
||||
gc.gridy++;
|
||||
gc.fill = GridBagConstraints.NONE;
|
||||
gc.insets.left = 20;
|
||||
gc.insets.left = BUTTON_OFFSET;
|
||||
gc.insets.bottom = 15;
|
||||
add(configureAnnotations, gc);
|
||||
add(myConfigureAnnotations, gc);
|
||||
|
||||
gc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gc.weighty = 1;
|
||||
@@ -162,6 +172,16 @@ public class DataFlowInspection extends DataFlowInspectionBase {
|
||||
gc.gridy++;
|
||||
add(myReportUncheckedOptionals, gc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension preferred = super.getPreferredSize();
|
||||
if (!isPreferredSizeSet()) {
|
||||
// minimize preferred width to align HTML text within ScrollPane
|
||||
Dimension size = myConfigureAnnotations.getPreferredSize();
|
||||
preferred.width = size.width + BUTTON_OFFSET;
|
||||
}
|
||||
return preferred;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,8 @@ inspection.annotate.method.quickfix.name=Annotate method as ''@{0}''
|
||||
#dataflow
|
||||
inspection.data.flow.display.name=Constant conditions \\& exceptions
|
||||
inspection.contract.display.name=Contract issues
|
||||
inspection.data.flow.nullable.quickfix.option=<html><body>Suggest @Nullable annotation for methods that may possibly return null and <br>report nullable values passed to non-annotated parameters</body></html>
|
||||
inspection.data.flow.true.asserts.option=<html><body>Don't report assertions with condition statically proven to be always <code>true</code></body></html>
|
||||
inspection.data.flow.nullable.quickfix.option=Suggest @Nullable annotation for methods that may possibly return <code>null</code> and report nullable values passed to non-annotated parameters
|
||||
inspection.data.flow.true.asserts.option=Don't report assertions with condition statically proven to be always <code>true</code>
|
||||
inspection.data.flow.redundant.instanceof.quickfix=Replace with != null
|
||||
inspection.data.flow.simplify.boolean.expression.quickfix=Simplify boolean expression
|
||||
inspection.data.flow.simplify.to.assignment.quickfix.name=Simplify to normal assignment
|
||||
|
||||
Reference in New Issue
Block a user