Search in sources :

Example 96 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 97 with DocumentEvent

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

the class HtmlUnknownTagInspection method createOptionsPanel.

@NotNull
protected static JComponent createOptionsPanel(@NotNull final HtmlUnknownElementInspection inspection) {
    final JPanel result = new JPanel(new BorderLayout());
    final JPanel internalPanel = new JPanel(new BorderLayout());
    result.add(internalPanel, BorderLayout.NORTH);
    final Ref<FieldPanel> panelRef = new Ref<>();
    final FieldPanel additionalAttributesPanel = new FieldPanel(null, null, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            Messages.showTextAreaDialog(panelRef.get().getTextField(), StringUtil.wordsToBeginFromUpperCase(inspection.getPanelTitle()), inspection.getClass().getSimpleName(), s -> reparseProperties(s), strings -> StringUtil.join(strings, ","));
        }
    }, null);
    ((JButton) additionalAttributesPanel.getComponent(1)).setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
    panelRef.set(additionalAttributesPanel);
    additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            final Document document = e.getDocument();
            try {
                final String text = document.getText(0, document.getLength());
                if (text != null) {
                    inspection.updateAdditionalEntries(text.trim());
                }
            } catch (BadLocationException e1) {
                inspection.getLogger().error(e1);
            }
        }
    });
    final JCheckBox checkBox = new JCheckBox(inspection.getCheckboxTitle());
    checkBox.setSelected(inspection.isCustomValuesEnabled());
    checkBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final boolean b = checkBox.isSelected();
            if (b != inspection.isCustomValuesEnabled()) {
                inspection.enableCustomValues(b);
                additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled());
            }
        }
    });
    internalPanel.add(checkBox, BorderLayout.NORTH);
    internalPanel.add(additionalAttributesPanel, BorderLayout.CENTER);
    additionalAttributesPanel.setPreferredSize(new Dimension(150, additionalAttributesPanel.getPreferredSize().height));
    additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled());
    additionalAttributesPanel.setText(inspection.getAdditionalEntries());
    return result;
}
Also used : ActionListener(java.awt.event.ActionListener) TemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider) NonNls(org.jetbrains.annotations.NonNls) ConfigurableTemplateLanguageFileViewProvider(com.intellij.psi.templateLanguages.ConfigurableTemplateLanguageFileViewProvider) TemplateLanguageUtil(com.intellij.psi.templateLanguages.TemplateLanguageUtil) Nls(org.jetbrains.annotations.Nls) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) Messages(com.intellij.openapi.ui.Messages) DocumentEvent(javax.swing.event.DocumentEvent) LocalQuickFix(com.intellij.codeInspection.LocalQuickFix) PlatformIcons(com.intellij.util.PlatformIcons) StringUtil(com.intellij.openapi.util.text.StringUtil) FileViewProvider(com.intellij.psi.FileViewProvider) FieldPanel(com.intellij.ui.FieldPanel) BadLocationException(javax.swing.text.BadLocationException) LocalQuickFixOnPsiElement(com.intellij.codeInspection.LocalQuickFixOnPsiElement) ActionEvent(java.awt.event.ActionEvent) java.awt(java.awt) ChangeTemplateDataLanguageAction(com.intellij.psi.templateLanguages.ChangeTemplateDataLanguageAction) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Function(com.intellij.util.Function) Document(javax.swing.text.Document) NotNull(org.jetbrains.annotations.NotNull) LangBundle(com.intellij.lang.LangBundle) Ref(com.intellij.openapi.util.Ref) DocumentAdapter(com.intellij.ui.DocumentAdapter) javax.swing(javax.swing) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Document(javax.swing.text.Document) Ref(com.intellij.openapi.util.Ref) ActionListener(java.awt.event.ActionListener) FieldPanel(com.intellij.ui.FieldPanel) BadLocationException(javax.swing.text.BadLocationException) NotNull(org.jetbrains.annotations.NotNull)

Example 98 with DocumentEvent

use of javax.swing.event.DocumentEvent in project kotlin by JetBrains.

the class K2JSRunConfigurationEditor method setUpChooseGenerateFilePath.

private void setUpChooseGenerateFilePath() {
    FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.getDirectoryChooserDescriptor("directory where generated files will be stored");
    fileChooserDescriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
    generatedChooseFile.addBrowseFolderListener(null, null, project, fileChooserDescriptor);
    final JTextField textField = generatedChooseFile.getTextField();
    textField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(@NotNull DocumentEvent e) {
            onChange();
        }

        @Override
        public void removeUpdate(@NotNull DocumentEvent e) {
            onChange();
        }

        @Override
        public void changedUpdate(@NotNull DocumentEvent e) {
            onChange();
        }

        private void onChange() {
            File file = new File(generatedChooseFile.getText());
            if (!file.isDirectory()) {
                textField.setForeground(JBColor.red);
            } else {
                textField.setForeground(JBColor.foreground());
            }
        }
    });
}
Also used : DocumentListener(javax.swing.event.DocumentListener) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentEvent(javax.swing.event.DocumentEvent) File(java.io.File)

Example 99 with DocumentEvent

use of javax.swing.event.DocumentEvent in project joda-time by JodaOrg.

the class AgeCalculator method addTopArea.

private void addTopArea(Container container) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    panel.add(fixedHeight(new JLabel("Birthdate")));
    panel.add(Box.createHorizontalStrut(10));
    final JTextField birthdateField = new JTextField(iBirthdateStr + ' ');
    Document doc = birthdateField.getDocument();
    doc.addDocumentListener(new DocumentListener() {

        public void insertUpdate(DocumentEvent e) {
            update(e);
        }

        public void removeUpdate(DocumentEvent e) {
            update(e);
        }

        public void changedUpdate(DocumentEvent e) {
            update(e);
        }

        private void update(DocumentEvent e) {
            iBirthdateStr = birthdateField.getText();
            updateResults();
        }
    });
    panel.add(fixedHeight(birthdateField));
    panel.add(Box.createHorizontalStrut(10));
    Object[] ids = DateTimeZone.getAvailableIDs().toArray();
    final JComboBox zoneSelector = new JComboBox(ids);
    zoneSelector.setSelectedItem(DateTimeZone.getDefault().getID());
    panel.add(fixedSize(zoneSelector));
    zoneSelector.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            String id = (String) zoneSelector.getSelectedItem();
            iChronology = ISOChronology.getInstance(DateTimeZone.forID(id));
            updateResults();
        }
    });
    container.add(fixedHeight(panel));
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) Document(javax.swing.text.Document) DocumentEvent(javax.swing.event.DocumentEvent) ActionListener(java.awt.event.ActionListener)

Example 100 with DocumentEvent

use of javax.swing.event.DocumentEvent in project kotlin by JetBrains.

the class AddFieldBreakpointDialog method createCenterPanel.

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

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

        @Override
        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() {

        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            PsiClass selectedClass = getSelectedClass();
            DescriptorMemberChooserObject[] properties = FieldBreakpointDialogUtilKt.collectProperties(selectedClass);
            MemberChooser<DescriptorMemberChooserObject> chooser = new MemberChooser<DescriptorMemberChooserObject>(properties, false, false, myProject);
            chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", properties.length));
            chooser.setCopyJavadocVisible(false);
            chooser.show();
            List<DescriptorMemberChooserObject> selectedElements = chooser.getSelectedElements();
            if (selectedElements != null && selectedElements.size() == 1) {
                KtProperty field = (KtProperty) 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) DocumentEvent(javax.swing.event.DocumentEvent) MemberChooser(com.intellij.ide.util.MemberChooser) KtProperty(org.jetbrains.kotlin.psi.KtProperty) DescriptorMemberChooserObject(org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject) ActionListener(java.awt.event.ActionListener) List(java.util.List)

Aggregations

DocumentEvent (javax.swing.event.DocumentEvent)122 DocumentAdapter (com.intellij.ui.DocumentAdapter)64 DocumentListener (javax.swing.event.DocumentListener)53 ActionEvent (java.awt.event.ActionEvent)34 ActionListener (java.awt.event.ActionListener)32 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)13 JPanel (javax.swing.JPanel)12 JTextField (javax.swing.JTextField)12 ItemEvent (java.awt.event.ItemEvent)10 ItemListener (java.awt.event.ItemListener)10 JButton (javax.swing.JButton)10 Document (javax.swing.text.Document)10 NotNull (org.jetbrains.annotations.NotNull)9 JLabel (javax.swing.JLabel)8 ChangeEvent (javax.swing.event.ChangeEvent)8 JCheckBox (javax.swing.JCheckBox)7 JTextComponent (javax.swing.text.JTextComponent)7 ZapTextField (org.zaproxy.zap.utils.ZapTextField)7 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6