mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
improve "Overly complex boolean expression" ui
This commit is contained in:
@@ -1305,7 +1305,7 @@ negated.conditional.ignore.option=Ignore '!= null' comparisons
|
||||
negated.conditional.invert.quickfix=Invert condition
|
||||
negated.if.else.ignore.option=Ignore '!= null' comparisons
|
||||
negated.if.else.invert.quickfix=Invert If Condition
|
||||
overly.complex.boolean.expression.overly.option=Maximum number of terms:
|
||||
overly.complex.boolean.expression.max.terms.option=Maximum number of terms:
|
||||
pointless.boolean.expression.ignore.option=Ignore named constant in determining pointless expressions
|
||||
simplifiable.conditional.expression.problem.descriptor=<code>#ref</code> can be simplified to ''{0}'' #loc
|
||||
simplifiable.if.statement.problem.descriptor=<code>#ref</code> statement can be replaced with ''{0}'' #loc
|
||||
@@ -1407,7 +1407,7 @@ redundant.method.override.problem.descriptor=Method <code>#ref()</code> is ident
|
||||
redundant.method.override.quickfix=Remove redundant method
|
||||
refused.bequest.problem.descriptor=Method <code>#ref()</code> ignores defined method in superclass #loc
|
||||
refused.bequest.ignore.empty.super.methods.option=Ignore empty super methods (degrades performance of this inspection)
|
||||
overly.complex.boolean.expression.ignore.pure.conjunctions.and.disjunctions.option=Ignore pure conjunctions and disjunctions
|
||||
overly.complex.boolean.expression.ignore.option=Ignore pure conjunctions and disjunctions
|
||||
pointless.indexof.comparison.display.name=Pointless 'indexOf()' comparison
|
||||
pointless.indexof.comparison.always.true.problem.descriptor=<code>#ref</code> is always true #loc
|
||||
pointless.indexof.comparison.always.false.problem.descriptor=<code>#ref</code> is always false #loc
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.siyeh.ig.controlflow.OverlyComplexBooleanExpressionInspection">
|
||||
<grid id="f1d35" binding="m_contentPanel" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="4" left="4" bottom="4" right="4"/>
|
||||
<constraints>
|
||||
<xy x="69" y="73" width="360" height="202"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="fcc4" class="javax.swing.JCheckBox" binding="m_ignoreConjunctionsDisjunctionsCheckBox">
|
||||
<constraints>
|
||||
<xy x="4" y="29" width="226" height="22"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="false"/>
|
||||
<text resource-bundle="com/siyeh/InspectionGadgetsBundle" key="overly.complex.boolean.expression.ignore.pure.conjunctions.and.disjunctions.option"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="41baa">
|
||||
<constraints>
|
||||
<xy x="65" y="51" width="11" height="147"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="47185" class="javax.swing.JFormattedTextField" binding="m_termLimitTextField">
|
||||
<constraints>
|
||||
<xy x="148" y="4" width="20" height="20"/>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0">
|
||||
<preferred-size width="20" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="427a" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<xy x="4" y="7" width="134" height="14"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="com/siyeh/InspectionGadgetsBundle" key="overly.complex.boolean.expression.overly.option"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+39
-20
@@ -32,6 +32,7 @@ import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.Document;
|
||||
import java.awt.*;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashSet;
|
||||
@@ -51,10 +52,6 @@ public class OverlyComplexBooleanExpressionInspection
|
||||
s_booleanOperators.add("|");
|
||||
}
|
||||
|
||||
private JFormattedTextField m_termLimitTextField;
|
||||
private JCheckBox m_ignoreConjunctionsDisjunctionsCheckBox;
|
||||
private JPanel m_contentPanel;
|
||||
|
||||
/** @noinspection PublicField*/
|
||||
public int m_limit = 3;
|
||||
|
||||
@@ -77,21 +74,28 @@ public class OverlyComplexBooleanExpressionInspection
|
||||
|
||||
@Override
|
||||
public JComponent createOptionsPanel() {
|
||||
final ButtonModel pureModel =
|
||||
m_ignoreConjunctionsDisjunctionsCheckBox.getModel();
|
||||
pureModel.setSelected(m_ignorePureConjunctionsDisjunctions);
|
||||
pureModel.addChangeListener(new ChangeListener() {
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
final JCheckBox ignoreConjunctionsDisjunctionsCheckBox =
|
||||
new JCheckBox(InspectionGadgetsBundle.message(
|
||||
"overly.complex.boolean.expression.ignore.option"),
|
||||
m_ignorePureConjunctionsDisjunctions);
|
||||
ignoreConjunctionsDisjunctionsCheckBox.addChangeListener(
|
||||
new ChangeListener() {
|
||||
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
m_ignorePureConjunctionsDisjunctions = pureModel.isSelected();
|
||||
}
|
||||
});
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
m_ignorePureConjunctionsDisjunctions =
|
||||
ignoreConjunctionsDisjunctionsCheckBox.isSelected();
|
||||
}
|
||||
}
|
||||
);
|
||||
final NumberFormat formatter = NumberFormat.getIntegerInstance();
|
||||
formatter.setParseIntegerOnly(true);
|
||||
m_termLimitTextField.setValue(Integer.valueOf(m_limit));
|
||||
m_termLimitTextField.setColumns(4);
|
||||
UIUtil.fixFormattedField(m_termLimitTextField);
|
||||
final Document document = m_termLimitTextField.getDocument();
|
||||
final JFormattedTextField termLimitTextField =
|
||||
new JFormattedTextField(formatter);
|
||||
termLimitTextField.setValue(Integer.valueOf(m_limit));
|
||||
termLimitTextField.setColumns(2);
|
||||
UIUtil.fixFormattedField(termLimitTextField);
|
||||
final Document document = termLimitTextField.getDocument();
|
||||
document.addDocumentListener(new DocumentListener() {
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
textChanged();
|
||||
@@ -107,15 +111,30 @@ public class OverlyComplexBooleanExpressionInspection
|
||||
|
||||
private void textChanged() {
|
||||
try {
|
||||
m_termLimitTextField.commitEdit();
|
||||
final Number number = (Number)m_termLimitTextField.getValue();
|
||||
termLimitTextField.commitEdit();
|
||||
final Number number = (Number)termLimitTextField.getValue();
|
||||
m_limit = number.intValue();
|
||||
} catch (ParseException e) {
|
||||
// No luck this time
|
||||
}
|
||||
}
|
||||
});
|
||||
return m_contentPanel;
|
||||
final GridBagConstraints constraints = new GridBagConstraints();
|
||||
final JLabel label = new JLabel(InspectionGadgetsBundle.message(
|
||||
"overly.complex.boolean.expression.max.terms.option"));
|
||||
constraints.anchor = GridBagConstraints.BASELINE_LEADING;
|
||||
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
panel.add(label, constraints);
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
constraints.gridx = 1;
|
||||
panel.add(termLimitTextField, constraints);
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = 1;
|
||||
constraints.gridwidth = 2;
|
||||
constraints.weightx = 1.0;
|
||||
constraints.weighty = 1.0;
|
||||
panel.add(ignoreConjunctionsDisjunctionsCheckBox, constraints);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,4 +282,4 @@ public class OverlyComplexBooleanExpressionInspection
|
||||
isPureConjunctionDisJunction(rOperand, operator);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user