Search in sources :

Example 51 with DocumentAdapter

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

the class I18nInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final GridBagLayout layout = new GridBagLayout();
    final JPanel panel = new JPanel(layout);
    final JCheckBox assertStatementsCheckbox = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.assert"), ignoreForAssertStatements);
    assertStatementsCheckbox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForAssertStatements = assertStatementsCheckbox.isSelected();
        }
    });
    final JCheckBox exceptionConstructorCheck = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.for.exception.constructor.arguments"), ignoreForExceptionConstructors);
    exceptionConstructorCheck.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForExceptionConstructors = exceptionConstructorCheck.isSelected();
        }
    });
    final JTextField specifiedExceptions = new JTextField(ignoreForSpecifiedExceptionConstructors);
    specifiedExceptions.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            ignoreForSpecifiedExceptionConstructors = specifiedExceptions.getText();
        }
    });
    final JCheckBox junitAssertCheckbox = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.for.junit.assert.arguments"), ignoreForJUnitAsserts);
    junitAssertCheckbox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForJUnitAsserts = junitAssertCheckbox.isSelected();
        }
    });
    final JCheckBox classRef = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.qualified.class.names"), ignoreForClassReferences);
    classRef.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForClassReferences = classRef.isSelected();
        }
    });
    final JCheckBox propertyRef = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.property.keys"), ignoreForPropertyKeyReferences);
    propertyRef.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForPropertyKeyReferences = propertyRef.isSelected();
        }
    });
    final JCheckBox nonAlpha = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.nonalphanumerics"), ignoreForNonAlpha);
    nonAlpha.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForNonAlpha = nonAlpha.isSelected();
        }
    });
    final JCheckBox assignedToConstants = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.assigned.to.constants"), ignoreAssignedToConstants);
    assignedToConstants.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreAssignedToConstants = assignedToConstants.isSelected();
        }
    });
    final JCheckBox chkToString = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.tostring"), ignoreToString);
    chkToString.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreToString = chkToString.isSelected();
        }
    });
    final JCheckBox ignoreEnumConstants = new JCheckBox("Ignore enum constants", ignoreForEnumConstants);
    ignoreEnumConstants.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(@NotNull ChangeEvent e) {
            ignoreForEnumConstants = ignoreEnumConstants.isSelected();
        }
    });
    final GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.insets.bottom = 2;
    gc.gridx = GridBagConstraints.REMAINDER;
    gc.gridy = 0;
    gc.weightx = 1;
    gc.weighty = 0;
    panel.add(assertStatementsCheckbox, gc);
    gc.gridy++;
    panel.add(junitAssertCheckbox, gc);
    gc.gridy++;
    panel.add(exceptionConstructorCheck, gc);
    gc.gridy++;
    final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    panel.add(new FieldPanel(specifiedExceptions, null, CodeInsightBundle.message("inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"), openProjects.length == 0 ? null : new ActionListener() {

        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            createIgnoreExceptionsConfigurationDialog(openProjects[0], specifiedExceptions).show();
        }
    }, null), gc);
    gc.gridy++;
    panel.add(classRef, gc);
    gc.gridy++;
    panel.add(propertyRef, gc);
    gc.gridy++;
    panel.add(assignedToConstants, gc);
    gc.gridy++;
    panel.add(chkToString, gc);
    gc.gridy++;
    panel.add(nonAlpha, gc);
    gc.gridy++;
    panel.add(ignoreEnumConstants, gc);
    gc.gridy++;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weighty = 1;
    final JTextField text = new JTextField(nonNlsCommentPattern);
    final FieldPanel nonNlsCommentPatternComponent = new FieldPanel(text, CodeInsightBundle.message("inspection.i18n.option.ignore.comment.pattern"), CodeInsightBundle.message("inspection.i18n.option.ignore.comment.title"), null, () -> {
        nonNlsCommentPattern = text.getText();
        cacheNonNlsCommentPattern();
    });
    panel.add(nonNlsCommentPatternComponent, gc);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setBorder(null);
    scrollPane.setPreferredSize(new Dimension(panel.getPreferredSize().width + scrollPane.getVerticalScrollBar().getPreferredSize().width, panel.getPreferredSize().height + scrollPane.getHorizontalScrollBar().getPreferredSize().height));
    return scrollPane;
}
Also used : ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Project(com.intellij.openapi.project.Project) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) ChangeListener(javax.swing.event.ChangeListener) FieldPanel(com.intellij.ui.FieldPanel)

Example 52 with DocumentAdapter

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

the class SetPropertyDialog method init.

protected void init() {
    super.init();
    if (myPropertyName != null) {
        updatePropertyValue(myPropertyName);
    } else {
        myPropertyNameBox.getEditor().setItem("");
    }
    myPropertyNameBox.addItemListener(e -> {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            String name = getPropertyName();
            updatePropertyValue(name);
            getOKAction().setEnabled(name != null && !"".equals(name.trim()));
        }
    });
    Component editor = myPropertyNameBox.getEditor().getEditorComponent();
    if (editor instanceof JTextField) {
        JTextField jTextField = (JTextField) editor;
        jTextField.getDocument().addDocumentListener(new DocumentAdapter() {

            protected void textChanged(DocumentEvent e) {
                String name = getPropertyName();
                updatePropertyValue(name);
                getOKAction().setEnabled(name != null && !"".equals(name.trim()));
            }
        });
    }
    getOKAction().setEnabled(myPropertyName != null && !"".equals(myPropertyName.trim()));
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 53 with DocumentAdapter

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

the class SshSettingsPanel method init.

private void init() {
    register(myPasswordChoice, SvnConfiguration.SshConnectionType.PASSWORD);
    register(myPrivateKeyChoice, SvnConfiguration.SshConnectionType.PRIVATE_KEY);
    register(mySubversionConfigChoice, SvnConfiguration.SshConnectionType.SUBVERSION_CONFIG);
    ItemListener connectionTypeChangedListener = e -> {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            enableOptions(e.getSource());
        }
    };
    myPasswordChoice.addItemListener(connectionTypeChangedListener);
    myPrivateKeyChoice.addItemListener(connectionTypeChangedListener);
    mySubversionConfigChoice.addItemListener(connectionTypeChangedListener);
    enableOptions(mySubversionConfigChoice);
    registerBrowseDialog(myExecutablePathField, SvnBundle.message("ssh.settings.browse.executable.dialog.title"));
    registerBrowseDialog(myPrivateKeyPathField, SvnBundle.message("ssh.settings.browse.private.key.dialog.title"));
    mySshTunnelField.getEmptyText().setText(SshTunnelRuntimeModule.DEFAULT_SSH_TUNNEL_VALUE);
    mySshTunnelField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            updateSshTunnelDependentValues(mySshTunnelField.getText());
        }
    });
    myUpdateTunnelButton.addActionListener(e -> {
        String tunnel = mySshTunnelField.getText();
        mySvnConfiguration.setSshTunnelSetting(StringUtil.nullize(tunnel));
        setSshTunnelSetting(mySvnConfiguration.getSshTunnelSetting());
    });
}
Also used : ConfigurableUi(com.intellij.openapi.options.ConfigurableUi) UIUtil(com.intellij.util.ui.UIUtil) ItemEvent(java.awt.event.ItemEvent) FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) StringUtil(com.intellij.openapi.util.text.StringUtil) SshTunnelRuntimeModule(org.jetbrains.idea.svn.commandLine.SshTunnelRuntimeModule) JBRadioButton(com.intellij.ui.components.JBRadioButton) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) ItemListener(java.awt.event.ItemListener) JBLabel(com.intellij.ui.components.JBLabel) SvnBundle(org.jetbrains.idea.svn.SvnBundle) Nullable(org.jetbrains.annotations.Nullable) JBTextField(com.intellij.ui.components.JBTextField) EnvironmentUtil(com.intellij.util.EnvironmentUtil) PortField(com.intellij.ui.PortField) NotNull(org.jetbrains.annotations.NotNull) SvnConfiguration(org.jetbrains.idea.svn.SvnConfiguration) DocumentEvent(javax.swing.event.DocumentEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) SvnConfigurationState(org.jetbrains.idea.svn.SvnConfigurationState) javax.swing(javax.swing) DocumentAdapter(com.intellij.ui.DocumentAdapter) ItemListener(java.awt.event.ItemListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 54 with DocumentAdapter

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

the class DependsOnGroupsInspection method createOptionsPanel.

@Override
@Nullable
public JComponent createOptionsPanel() {
    final LabeledComponent<JTextField> definedGroups = new LabeledComponent<>();
    definedGroups.setText("&Defined Groups");
    final JTextField textField = new JTextField(StringUtil.join(ArrayUtil.toStringArray(groups), ","));
    textField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(final DocumentEvent e) {
            groups.clear();
            String text = textField.getText();
            if (!StringUtil.isEmptyOrSpaces(text)) {
                ContainerUtil.addAll(groups, text.split("[, ]"));
            }
        }
    });
    definedGroups.setComponent(textField);
    final JPanel optionsPanel = new JPanel(new BorderLayout());
    optionsPanel.add(definedGroups, BorderLayout.NORTH);
    return optionsPanel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) LabeledComponent(com.intellij.openapi.ui.LabeledComponent) Nullable(org.jetbrains.annotations.Nullable)

Example 55 with DocumentAdapter

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

the class DuplicateStringLiteralInspection method createOptionsPanel.

@Override
public JComponent createOptionsPanel() {
    final OptionsPanel optionsPanel = new OptionsPanel();
    optionsPanel.myIgnorePropertyKeyExpressions.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            IGNORE_PROPERTY_KEYS = optionsPanel.myIgnorePropertyKeyExpressions.isSelected();
        }
    });
    optionsPanel.myMinStringLengthField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(final DocumentEvent e) {
            try {
                MIN_STRING_LENGTH = Integer.parseInt(optionsPanel.myMinStringLengthField.getText());
            } catch (NumberFormatException ignored) {
            }
        }
    });
    optionsPanel.myIgnorePropertyKeyExpressions.setSelected(IGNORE_PROPERTY_KEYS);
    optionsPanel.myMinStringLengthField.setText(Integer.toString(MIN_STRING_LENGTH));
    return optionsPanel.myPanel;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

DocumentAdapter (com.intellij.ui.DocumentAdapter)64 DocumentEvent (javax.swing.event.DocumentEvent)64 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)10 ItemEvent (java.awt.event.ItemEvent)7 ItemListener (java.awt.event.ItemListener)7 Document (javax.swing.text.Document)7 JTextComponent (javax.swing.text.JTextComponent)5 NotNull (org.jetbrains.annotations.NotNull)5 Project (com.intellij.openapi.project.Project)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 FieldPanel (com.intellij.ui.FieldPanel)4 JBTextField (com.intellij.ui.components.JBTextField)4 ChangeEvent (javax.swing.event.ChangeEvent)4 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 VariantsCompletionAction (com.intellij.find.editorHeaderActions.VariantsCompletionAction)2 MemberChooser (com.intellij.ide.util.MemberChooser)2 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)2