Search in sources :

Example 91 with DocumentEvent

use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.

the class EditableSchemesCombo method createNameEditorField.

private JTextField createNameEditorField() {
    JTextField nameEditorField = new JTextField();
    nameEditorField.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            revertSchemeName();
            cancelEdit();
        }
    }, ESC_KEY_STROKE, JComponent.WHEN_FOCUSED);
    nameEditorField.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            stopEdit();
        }
    }, ENTER_KEY_STROKE, JComponent.WHEN_FOCUSED);
    nameEditorField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            stopEdit();
        }
    });
    nameEditorField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            validateOnTyping();
        }
    });
    return nameEditorField;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 92 with DocumentEvent

use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.

the class AddFieldBreakpointDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        public void textChanged(DocumentEvent event) {
            updateUI();
        }
    });
    myClassChooser.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            PsiClass currentClass = getSelectedClass();
            TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser(DebuggerBundle.message("add.field.breakpoint.dialog.classchooser.title"));
            if (currentClass != null) {
                PsiFile containingFile = currentClass.getContainingFile();
                if (containingFile != null) {
                    PsiDirectory containingDirectory = containingFile.getContainingDirectory();
                    if (containingDirectory != null) {
                        chooser.selectDirectory(containingDirectory);
                    }
                }
            }
            chooser.showDialog();
            PsiClass selectedClass = chooser.getSelected();
            if (selectedClass != null) {
                myClassChooser.setText(selectedClass.getQualifiedName());
            }
        }
    });
    myFieldChooser.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            PsiClass selectedClass = getSelectedClass();
            if (selectedClass != null) {
                PsiField[] fields = selectedClass.getFields();
                MemberChooser<PsiFieldMember> chooser = new MemberChooser<>(ContainerUtil.map2Array(fields, PsiFieldMember.class, PsiFieldMember::new), false, false, myProject);
                chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", fields.length));
                chooser.setCopyJavadocVisible(false);
                TransactionGuard.getInstance().submitTransactionAndWait(() -> chooser.show());
                List<PsiFieldMember> selectedElements = chooser.getSelectedElements();
                if (selectedElements != null && selectedElements.size() == 1) {
                    PsiField field = selectedElements.get(0).getElement();
                    myFieldChooser.setText(field.getName());
                }
            }
        }
    });
    myFieldChooser.setEnabled(false);
    return myPanel;
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) PsiFieldMember(com.intellij.codeInsight.generation.PsiFieldMember) DocumentEvent(javax.swing.event.DocumentEvent) MemberChooser(com.intellij.ide.util.MemberChooser) ActionListener(java.awt.event.ActionListener) List(java.util.List)

Example 93 with DocumentEvent

use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.

the class ClassHasNoToStringMethodInspection method createOptionsPanel.

/**
     * Creates the options panel in the settings for user changeable options.
     *
     * @return the options panel
     */
@Override
public JComponent createOptionsPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 0.0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    panel.add(new JLabel("Exclude classes (reg exp):"), constraints);
    final JFormattedTextField excludeClassNamesField = new JFormattedTextField(new RegExFormatter());
    excludeClassNamesField.setValue(excludeClassNamesPattern);
    excludeClassNamesField.setColumns(25);
    excludeClassNamesField.setInputVerifier(new RegExInputVerifier());
    excludeClassNamesField.setFocusLostBehavior(JFormattedTextField.COMMIT);
    excludeClassNamesField.setMinimumSize(excludeClassNamesField.getPreferredSize());
    UIUtil.fixFormattedField(excludeClassNamesField);
    Document document = excludeClassNamesField.getDocument();
    document.addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            try {
                excludeClassNamesField.commitEdit();
                excludeClassNamesPattern = (Pattern) excludeClassNamesField.getValue();
                excludeClassNames = excludeClassNamesPattern.pattern();
            } catch (final Exception ignore) {
            }
        }
    });
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 1.0;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.NONE;
    panel.add(excludeClassNamesField, constraints);
    final CheckBox excludeExceptionCheckBox = new CheckBox("Ignore exception classes", this, "excludeException");
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    panel.add(excludeExceptionCheckBox, constraints);
    final CheckBox excludeDeprecatedCheckBox = new CheckBox("Ignore deprecated classes", this, "excludeDeprecated");
    constraints.gridy = 2;
    panel.add(excludeDeprecatedCheckBox, constraints);
    final CheckBox excludeEnumCheckBox = new CheckBox("Ignore enum classes", this, "excludeEnum");
    constraints.gridy = 3;
    panel.add(excludeEnumCheckBox, constraints);
    final CheckBox excludeAbstractCheckBox = new CheckBox("Ignore abstract classes", this, "excludeAbstract");
    constraints.gridy = 4;
    panel.add(excludeAbstractCheckBox, constraints);
    final CheckBox excludeInTestCodeCheckBox = new CheckBox("Ignore test classes", this, "excludeTestCode");
    constraints.gridy = 5;
    panel.add(excludeInTestCodeCheckBox, constraints);
    final CheckBox excludeInnerClasses = new CheckBox("Ignore inner classes", this, "excludeInnerClasses");
    constraints.gridy = 6;
    constraints.weighty = 1.0;
    panel.add(excludeInnerClasses, constraints);
    return panel;
}
Also used : Pattern(java.util.regex.Pattern) DocumentAdapter(com.intellij.ui.DocumentAdapter) Document(javax.swing.text.Document) DocumentEvent(javax.swing.event.DocumentEvent) RegExInputVerifier(com.intellij.codeInspection.ui.RegExInputVerifier) PatternSyntaxException(java.util.regex.PatternSyntaxException) RegExFormatter(com.intellij.codeInspection.ui.RegExFormatter) CheckBox(com.intellij.util.ui.CheckBox)

Example 94 with DocumentEvent

use of javax.swing.event.DocumentEvent 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)

Example 95 with DocumentEvent

use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.

the class GitRebaseDialog method setupBranches.

/**
   * Setup branch drop down.
   */
private void setupBranches() {
    GitUIUtil.getTextField(myOntoComboBox).getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            validateFields();
        }
    });
    final ActionListener rootListener = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            loadRefs();
            updateBranches();
        }
    };
    final ActionListener showListener = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            updateOntoFrom();
        }
    };
    myShowRemoteBranchesCheckBox.addActionListener(showListener);
    myShowTagsCheckBox.addActionListener(showListener);
    rootListener.actionPerformed(null);
    myGitRootComboBox.addActionListener(rootListener);
    myBranchComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            updateTrackedBranch();
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

DocumentEvent (javax.swing.event.DocumentEvent)139 DocumentListener (javax.swing.event.DocumentListener)70 DocumentAdapter (com.intellij.ui.DocumentAdapter)64 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)34 JTextField (javax.swing.JTextField)22 JLabel (javax.swing.JLabel)18 JPanel (javax.swing.JPanel)18 Dimension (java.awt.Dimension)16 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)13 ItemEvent (java.awt.event.ItemEvent)13 ItemListener (java.awt.event.ItemListener)13 ChangeEvent (javax.swing.event.ChangeEvent)13 JButton (javax.swing.JButton)12 JCheckBox (javax.swing.JCheckBox)12 ChangeListener (javax.swing.event.ChangeListener)11 Document (javax.swing.text.Document)10 GridBagLayout (java.awt.GridBagLayout)9 NotNull (org.jetbrains.annotations.NotNull)9 GridBagConstraints (java.awt.GridBagConstraints)8