Search in sources :

Example 1 with VerticalLayout

use of com.intellij.ui.components.panels.VerticalLayout in project intellij-community by JetBrains.

the class ScopeEditorPanel method createActionsPanel.

private JComponent createActionsPanel() {
    final JButton include = new JButton(IdeBundle.message("button.include"));
    final JButton includeRec = new JButton(IdeBundle.message("button.include.recursively"));
    final JButton exclude = new JButton(IdeBundle.message("button.exclude"));
    final JButton excludeRec = new JButton(IdeBundle.message("button.exclude.recursively"));
    myPackageTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            final boolean recursiveEnabled = isButtonEnabled(true);
            includeRec.setEnabled(recursiveEnabled);
            excludeRec.setEnabled(recursiveEnabled);
            final boolean nonRecursiveEnabled = isButtonEnabled(false);
            include.setEnabled(nonRecursiveEnabled);
            exclude.setEnabled(nonRecursiveEnabled);
        }
    });
    JPanel buttonsPanel = new JPanel(new VerticalLayout(5));
    buttonsPanel.add(include);
    buttonsPanel.add(includeRec);
    buttonsPanel.add(exclude);
    buttonsPanel.add(excludeRec);
    include.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            includeSelected(false);
        }
    });
    includeRec.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            includeSelected(true);
        }
    });
    exclude.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            excludeSelected(false);
        }
    });
    excludeRec.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            excludeSelected(true);
        }
    });
    return buttonsPanel;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) VerticalLayout(com.intellij.ui.components.panels.VerticalLayout)

Example 2 with VerticalLayout

use of com.intellij.ui.components.panels.VerticalLayout 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)

Aggregations

VerticalLayout (com.intellij.ui.components.panels.VerticalLayout)2 ListTable (com.intellij.codeInspection.ui.ListTable)1 ListWrappingTableModel (com.intellij.codeInspection.ui.ListWrappingTableModel)1 CheckBox (com.intellij.util.ui.CheckBox)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 NotNull (org.jetbrains.annotations.NotNull)1