Search in sources :

Example 6 with CheckBox

use of com.intellij.util.ui.CheckBox in project intellij-community by JetBrains.

the class IfCanBeSwitchInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final JPanel panel = new JPanel(new GridBagLayout());
    final JLabel label = new JLabel(InspectionGadgetsBundle.message("if.can.be.switch.minimum.branch.option"));
    final NumberFormat formatter = NumberFormat.getIntegerInstance();
    formatter.setParseIntegerOnly(true);
    final JFormattedTextField valueField = new JFormattedTextField(formatter);
    valueField.setValue(Integer.valueOf(minimumBranches));
    valueField.setColumns(2);
    final Document document = valueField.getDocument();
    document.addDocumentListener(new DocumentAdapter() {

        @Override
        public void textChanged(DocumentEvent e) {
            try {
                valueField.commitEdit();
                minimumBranches = ((Number) valueField.getValue()).intValue();
            } catch (ParseException ignore) {
            // No luck this time
            }
        }
    });
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.insets.bottom = 4;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.BASELINE_LEADING;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets.right = 10;
    panel.add(label, constraints);
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 1.0;
    constraints.insets.right = 0;
    panel.add(valueField, constraints);
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    final CheckBox checkBox1 = new CheckBox(InspectionGadgetsBundle.message("if.can.be.switch.int.option"), this, "suggestIntSwitches");
    panel.add(checkBox1, constraints);
    constraints.gridy = 2;
    final CheckBox checkBox2 = new CheckBox(InspectionGadgetsBundle.message("if.can.be.switch.enum.option"), this, "suggestEnumSwitches");
    panel.add(checkBox2, constraints);
    constraints.gridy = 3;
    constraints.weighty = 1.0;
    final CheckBox checkBox3 = new CheckBox(InspectionGadgetsBundle.message("if.can.be.switch.null.safe.option"), this, "onlySuggestNullSafe");
    panel.add(checkBox3, constraints);
    return panel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) Document(javax.swing.text.Document) DocumentEvent(javax.swing.event.DocumentEvent) CheckBox(com.intellij.util.ui.CheckBox) ParseException(java.text.ParseException) NumberFormat(java.text.NumberFormat)

Example 7 with CheckBox

use of com.intellij.util.ui.CheckBox in project intellij-community by JetBrains.

the class AutoCloseableResourceInspection method createOptionsPanel.

@NotNull
@Override
public JComponent createOptionsPanel() {
    final JComponent panel = new JPanel(new VerticalLayout(2));
    final ListTable table = new ListTable(new ListWrappingTableModel(ignoredTypes, InspectionGadgetsBundle.message("ignored.autocloseable.types.column.label")));
    final JPanel tablePanel = UiUtils.createAddRemoveTreeClassChooserPanel(table, InspectionGadgetsBundle.message("choose.autocloseable.type.to.ignore.title"), "java.lang.AutoCloseable");
    final ListTable table2 = new ListTable(new ListWrappingTableModel(Arrays.asList(myMethodMatcher.getClassNames(), myMethodMatcher.getMethodNamePatterns()), InspectionGadgetsBundle.message("result.of.method.call.ignored.class.column.title"), InspectionGadgetsBundle.message("method.name.regex"))) {

        @Override
        public void setEnabled(boolean enabled) {
            // hack to display correctly on initial opening of
            // inspection settings (otherwise it is always enabled)
            super.setEnabled(enabled && !ignoreFromMethodCall);
        }
    };
    final JPanel tablePanel2 = UiUtils.createAddRemoveTreeClassChooserPanel(table2, "Choose class");
    final JPanel wrapperPanel = new JPanel(new BorderLayout());
    wrapperPanel.setBorder(IdeBorderFactory.createTitledBorder("Ignore AutoCloseable instances returned from these methods", false));
    wrapperPanel.add(tablePanel2);
    panel.add(tablePanel);
    panel.add(wrapperPanel);
    final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("auto.closeable.resource.returned.option"), this, "ignoreFromMethodCall");
    checkBox.addChangeListener(e -> table2.setEnabled(!ignoreFromMethodCall));
    panel.add(checkBox);
    panel.add(new CheckBox(InspectionGadgetsBundle.message("any.method.may.close.resource.argument"), this, "anyMethodMayClose"));
    return panel;
}
Also used : CheckBox(com.intellij.util.ui.CheckBox) ListTable(com.intellij.codeInspection.ui.ListTable) VerticalLayout(com.intellij.ui.components.panels.VerticalLayout) ListWrappingTableModel(com.intellij.codeInspection.ui.ListWrappingTableModel) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with CheckBox

use of com.intellij.util.ui.CheckBox in project intellij-community by JetBrains.

the class SerializableInspectionUtil method createOptions.

@NotNull
public static JComponent createOptions(@NotNull SerializableInspectionBase inspection) {
    final JComponent panel = new JPanel(new GridBagLayout());
    final JPanel chooserList = UiUtils.createTreeClassChooserList(inspection.superClassList, InspectionGadgetsBundle.message("ignore.classes.in.hierarchy.column.name"), InspectionGadgetsBundle.message("choose.super.class.to.ignore"));
    UiUtils.setComponentSize(chooserList, 7, 25);
    final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("ignore.anonymous.inner.classes"), inspection, "ignoreAnonymousInnerClasses");
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(chooserList, constraints);
    final JComponent[] additionalOptions = inspection.createAdditionalOptions();
    for (JComponent additionalOption : additionalOptions) {
        constraints.gridy++;
        if (additionalOption instanceof JPanel) {
            constraints.fill = GridBagConstraints.BOTH;
            constraints.weighty = 1.0;
        } else {
            constraints.fill = GridBagConstraints.HORIZONTAL;
            constraints.weighty = 0.0;
        }
        panel.add(additionalOption, constraints);
    }
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridy++;
    constraints.weighty = 0.0;
    panel.add(checkBox, constraints);
    return panel;
}
Also used : CheckBox(com.intellij.util.ui.CheckBox) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with CheckBox

use of com.intellij.util.ui.CheckBox in project intellij-community by JetBrains.

the class PublicMethodNotExposedInInterfaceInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final JPanel panel = new JPanel(new GridBagLayout());
    final JPanel annotationsListControl = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(ignorableAnnotations, InspectionGadgetsBundle.message("ignore.if.annotated.by"));
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weighty = 1.0;
    constraints.weightx = 1.0;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(annotationsListControl, constraints);
    final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("public.method.not.in.interface.option"), this, "onlyWarnIfContainingClassImplementsAnInterface");
    constraints.gridy = 1;
    constraints.weighty = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    panel.add(checkBox, constraints);
    return panel;
}
Also used : CheckBox(com.intellij.util.ui.CheckBox)

Example 10 with CheckBox

use of com.intellij.util.ui.CheckBox in project intellij-community by JetBrains.

the class IgnoreResultOfCallInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final JPanel panel = new JPanel(new BorderLayout());
    final ListTable table = new ListTable(new ListWrappingTableModel(Arrays.asList(myMethodMatcher.getClassNames(), myMethodMatcher.getMethodNamePatterns()), InspectionGadgetsBundle.message("result.of.method.call.ignored.class.column.title"), InspectionGadgetsBundle.message("result.of.method.call.ignored.method.column.title")));
    final JPanel tablePanel = UiUtils.createAddRemoveTreeClassChooserPanel(table, "Choose class");
    final CheckBox checkBox = new CheckBox(InspectionGadgetsBundle.message("result.of.method.call.ignored.non.library.option"), this, "m_reportAllNonLibraryCalls");
    panel.add(tablePanel, BorderLayout.CENTER);
    panel.add(checkBox, BorderLayout.SOUTH);
    return panel;
}
Also used : CheckBox(com.intellij.util.ui.CheckBox) ListTable(com.intellij.codeInspection.ui.ListTable) ListWrappingTableModel(com.intellij.codeInspection.ui.ListWrappingTableModel)

Aggregations

CheckBox (com.intellij.util.ui.CheckBox)28 ListTable (com.intellij.codeInspection.ui.ListTable)9 ListWrappingTableModel (com.intellij.codeInspection.ui.ListWrappingTableModel)9 Nullable (org.jetbrains.annotations.Nullable)5 DocumentAdapter (com.intellij.ui.DocumentAdapter)2 NumberFormat (java.text.NumberFormat)2 DocumentEvent (javax.swing.event.DocumentEvent)2 Document (javax.swing.text.Document)2 NotNull (org.jetbrains.annotations.NotNull)2 ListEditForm (com.intellij.codeInspection.ui.ListEditForm)1 RegExFormatter (com.intellij.codeInspection.ui.RegExFormatter)1 RegExInputVerifier (com.intellij.codeInspection.ui.RegExInputVerifier)1 OnePixelSplitter (com.intellij.ui.OnePixelSplitter)1 VerticalLayout (com.intellij.ui.components.panels.VerticalLayout)1 GridBag (com.intellij.util.ui.GridBag)1 TextField (com.siyeh.ig.ui.TextField)1 ParseException (java.text.ParseException)1 Pattern (java.util.regex.Pattern)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1