Search in sources :

Example 16 with DocumentEvent

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

the class TerminalSettingsPanel method createPanel.

public JComponent createPanel(@NotNull TerminalOptionsProvider provider, @NotNull TerminalProjectOptionsProvider projectOptionsProvider) {
    myOptionsProvider = provider;
    myProjectOptionsProvider = projectOptionsProvider;
    myProjectSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Project settings"));
    myGlobalSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Application settings"));
    FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
    myShellPathField.addBrowseFolderListener("", "Shell executable path", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
    myStartDirectoryField.addBrowseFolderListener("", "Starting directory", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    myShellPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            myShellPathField.getTextField().setForeground(StringUtil.equals(myShellPathField.getText(), myProjectOptionsProvider.getDefaultShellPath()) ? getDefaultValueColor() : getChangedValueColor());
        }
    });
    myStartDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            myStartDirectoryField.getTextField().setForeground(StringUtil.equals(myStartDirectoryField.getText(), myProjectOptionsProvider.getDefaultStartingDirectory()) ? getDefaultValueColor() : getChangedValueColor());
        }
    });
    for (LocalTerminalCustomizer c : LocalTerminalCustomizer.EP_NAME.getExtensions()) {
        UnnamedConfigurable configurable = c.getConfigurable(projectOptionsProvider.getProject());
        if (configurable != null) {
            myConfigurables.add(configurable);
            JComponent component = configurable.createComponent();
            if (component != null) {
                myConfigurablesPanel.add(component, BorderLayout.CENTER);
            }
        }
    }
    return myWholePanel;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) UnnamedConfigurable(com.intellij.openapi.options.UnnamedConfigurable) DocumentEvent(javax.swing.event.DocumentEvent)

Example 17 with DocumentEvent

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

the class AddNamespaceDialog method addUpdateListener.

private void addUpdateListener(ComboBox comboBox) {
    final ComboBoxEditor boxEditor = comboBox.getEditor();
    if (boxEditor != null) {
        final Component component = boxEditor.getEditorComponent();
        if (component instanceof JTextField) {
            ((JTextField) component).getDocument().addDocumentListener(new DocumentAdapter() {

                protected void textChanged(DocumentEvent e) {
                    updateOkAction();
                }
            });
        }
    }
    comboBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateOkAction();
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) ItemListener(java.awt.event.ItemListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 18 with DocumentEvent

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

the class BaseIntroduceDialog method init.

protected void init(XPathExpression expression, int numberOfExpressions, String title) {
    setModal(true);
    setTitle(title);
    final JLabel jLabel = getTypeLabel();
    jLabel.setText(expression.getType().getName());
    final JCheckBox jCheckBox = getReplaceAll();
    if (numberOfExpressions > 1) {
        jCheckBox.setText(MessageFormat.format(jCheckBox.getText(), String.valueOf(numberOfExpressions)));
    } else {
        jCheckBox.setVisible(false);
    }
    getNameField().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(DocumentEvent e) {
            getOKAction().setEnabled(myInputValidator.checkInput(getName()));
        }
    });
    getOKAction().setEnabled(false);
    init();
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 19 with DocumentEvent

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

the class RequiredAttributesInspection method createOptionsPanel.

@Override
@Nullable
public JComponent createOptionsPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    FieldPanel additionalAttributesPanel = new FieldPanel(InspectionsBundle.message("inspection.javadoc.html.not.required.label.text"), InspectionsBundle.message("inspection.javadoc.html.not.required.dialog.title"), null, null);
    panel.add(additionalAttributesPanel, BorderLayout.NORTH);
    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) {
                    myAdditionalRequiredHtmlAttributes = text.trim();
                }
            } catch (BadLocationException e1) {
                LOG.error(e1);
            }
        }
    });
    additionalAttributesPanel.setText(myAdditionalRequiredHtmlAttributes);
    return panel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) Document(javax.swing.text.Document) FieldPanel(com.intellij.ui.FieldPanel) BadLocationException(javax.swing.text.BadLocationException) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with DocumentEvent

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

the class EmmetAbbreviationBalloon method show.

public void show(@NotNull final CustomTemplateCallback customTemplateCallback) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        if (ourTestingAbbreviation == null) {
            throw new RuntimeException("Testing abbreviation is not set. See EmmetAbbreviationBalloon#setTestingAbbreviation");
        }
        myCallback.onEnter(ourTestingAbbreviation);
        return;
    }
    final TextFieldWithStoredHistory field = new TextFieldWithStoredHistory(myAbbreviationsHistoryKey);
    final Dimension fieldPreferredSize = field.getPreferredSize();
    field.setPreferredSize(new Dimension(Math.max(220, fieldPreferredSize.width), fieldPreferredSize.height));
    field.setHistorySize(10);
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    final BalloonImpl balloon = (BalloonImpl) popupFactory.createDialogBalloonBuilder(field, myTitle).setCloseButtonEnabled(false).setBlockClicksThroughBalloon(true).setAnimationCycle(0).setHideOnKeyOutside(true).setHideOnClickOutside(true).createBalloon();
    final DocumentAdapter documentListener = new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (!isValid(customTemplateCallback)) {
                balloon.hide();
                return;
            }
            validateTemplateKey(field, balloon, field.getText(), customTemplateCallback);
        }
    };
    field.addDocumentListener(documentListener);
    final KeyAdapter keyListener = new KeyAdapter() {

        @Override
        public void keyPressed(@NotNull KeyEvent e) {
            if (!field.isPopupVisible()) {
                if (!isValid(customTemplateCallback)) {
                    balloon.hide();
                    return;
                }
                switch(e.getKeyCode()) {
                    case KeyEvent.VK_ENTER:
                        final String abbreviation = field.getText();
                        if (validateTemplateKey(field, balloon, abbreviation, customTemplateCallback)) {
                            myCallback.onEnter(abbreviation);
                            PropertiesComponent.getInstance().setValue(myLastAbbreviationKey, abbreviation);
                            field.addCurrentTextToHistory();
                            balloon.hide();
                        }
                        break;
                    case KeyEvent.VK_ESCAPE:
                        balloon.hide(false);
                        break;
                }
            }
        }
    };
    field.addKeyboardListener(keyListener);
    balloon.addListener(new JBPopupListener.Adapter() {

        @Override
        public void beforeShown(LightweightWindowEvent event) {
            field.setText(PropertiesComponent.getInstance().getValue(myLastAbbreviationKey, ""));
        }

        @Override
        public void onClosed(LightweightWindowEvent event) {
            field.removeKeyListener(keyListener);
            field.removeDocumentListener(documentListener);
            super.onClosed(event);
        }
    });
    balloon.show(popupFactory.guessBestPopupLocation(customTemplateCallback.getEditor()), Balloon.Position.below);
    final IdeFocusManager focusManager = IdeFocusManager.getInstance(customTemplateCallback.getProject());
    focusManager.doWhenFocusSettlesDown(() -> {
        focusManager.requestFocus(field, true);
        field.selectText();
    });
}
Also used : KeyAdapter(java.awt.event.KeyAdapter) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) DocumentEvent(javax.swing.event.DocumentEvent) NotNull(org.jetbrains.annotations.NotNull) LightweightWindowEvent(com.intellij.openapi.ui.popup.LightweightWindowEvent) KeyEvent(java.awt.event.KeyEvent) JBPopupListener(com.intellij.openapi.ui.popup.JBPopupListener) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory)

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