Search in sources :

Example 21 with DocumentEvent

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

the class MavenEnvironmentForm method createComponent.

public JComponent createComponent() {
    // all listeners will be removed when dialog is closed
    mavenHomeComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.maven.home.directory"), "", null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
    mavenHomeField.addDocumentListener(new DocumentAdapter() {

        protected void textChanged(DocumentEvent e) {
            updateMavenVersionLabel();
        }
    });
    settingsFileComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.maven.settings.file"), "", null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
    localRepositoryComponent.getComponent().addBrowseFolderListener(ProjectBundle.message("maven.select.local.repository"), "", null, FileChooserDescriptorFactory.createSingleFolderDescriptor());
    return panel;
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 22 with DocumentEvent

use of javax.swing.event.DocumentEvent in project zaproxy by zaproxy.

the class DialogAddUser method getNameTextField.

protected ZapTextField getNameTextField() {
    if (nameTextField == null) {
        nameTextField = new ZapTextField(25);
        nameTextField.getDocument().addDocumentListener(new DocumentListener() {

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

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

            @Override
            public void changedUpdate(DocumentEvent e) {
                checkValidAndEnableConfirmButton();
            }
        });
    }
    return nameTextField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ZapTextField(org.zaproxy.zap.utils.ZapTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Example 23 with DocumentEvent

use of javax.swing.event.DocumentEvent in project zaproxy by zaproxy.

the class OptionsLangPanel method getFileTextField.

private ZapTextField getFileTextField() {
    if (fileTextField == null) {
        fileTextField = new ZapTextField();
        fileTextFieldDoc = fileTextField.getDocument();
        fileTextFieldDoc.addDocumentListener(new DocumentListener() {

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

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

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

            private void updated(DocumentEvent e) {
                try {
                    String inputString = e.getDocument().getText(0, e.getDocument().getLength());
                    importButton.setEnabled(inputString.endsWith(".zaplang"));
                } catch (BadLocationException e1) {
                //logger.error(e1.getMessage());
                }
            }
        });
    }
    return fileTextField;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ZapTextField(org.zaproxy.zap.utils.ZapTextField) DocumentEvent(javax.swing.event.DocumentEvent) BadLocationException(javax.swing.text.BadLocationException)

Example 24 with DocumentEvent

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

the class ArrayRendererConfigurable method createComponent.

public JComponent createComponent() {
    myPanel = new JPanel(new GridBagLayout());
    myStartIndex = new JTextField(5);
    myEndIndex = new JTextField(5);
    myEntriesLimit = new JTextField(5);
    final FontMetrics fontMetrics = myStartIndex.getFontMetrics(myStartIndex.getFont());
    final Dimension minSize = new Dimension(myStartIndex.getPreferredSize());
    //noinspection HardCodedStringLiteral
    minSize.width = fontMetrics.stringWidth("AAAAA");
    myStartIndex.setMinimumSize(minSize);
    myEndIndex.setMinimumSize(minSize);
    myEntriesLimit.setMinimumSize(minSize);
    JLabel startIndexLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.start.index"));
    startIndexLabel.setLabelFor(myStartIndex);
    JLabel endIndexLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.end.index"));
    endIndexLabel.setLabelFor(myEndIndex);
    JLabel entriesLimitLabel = new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count1"));
    entriesLimitLabel.setLabelFor(myEntriesLimit);
    myPanel.add(startIndexLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0));
    myPanel.add(myStartIndex, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0));
    myPanel.add(endIndexLabel, new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsRight(8), 0, 0));
    myPanel.add(myEndIndex, new GridBagConstraints(3, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
    myPanel.add(entriesLimitLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(4, 0, 0, 8), 0, 0));
    myPanel.add(myEntriesLimit, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(4, 0, 0, 8), 0, 0));
    myPanel.add(new JLabel(DebuggerBundle.message("label.array.renderer.configurable.max.count2")), new GridBagConstraints(2, GridBagConstraints.RELATIVE, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insetsTop(4), 0, 0));
    // push other components up
    myPanel.add(new JLabel(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
    final DocumentListener listener = new DocumentListener() {

        private void updateEntriesLimit() {
            final boolean state = myIndexUpdateEnabled;
            myIndexUpdateEnabled = false;
            try {
                if (myEntriesLimitUpdateEnabled) {
                    myEntriesLimit.setText(String.valueOf(getInt(myEndIndex) - getInt(myStartIndex) + 1));
                }
            } finally {
                myIndexUpdateEnabled = state;
            }
        }

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

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

        public void removeUpdate(DocumentEvent e) {
            updateEntriesLimit();
        }
    };
    myStartIndex.getDocument().addDocumentListener(listener);
    myEndIndex.getDocument().addDocumentListener(listener);
    myEntriesLimit.getDocument().addDocumentListener(new DocumentListener() {

        private void updateEndIndex() {
            final boolean state = myEntriesLimitUpdateEnabled;
            myEntriesLimitUpdateEnabled = false;
            try {
                if (myIndexUpdateEnabled) {
                    myEndIndex.setText(String.valueOf(getInt(myEntriesLimit) + getInt(myStartIndex) - 1));
                }
            } finally {
                myEntriesLimitUpdateEnabled = state;
            }
        }

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

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

        public void changedUpdate(DocumentEvent e) {
            updateEndIndex();
        }
    });
    return myPanel;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 25 with DocumentEvent

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

the class SetBackgroundImageDialog method setupComponents.

private void setupComponents() {
    myAdjusting = true;
    myPreviewPanel.setLayout(new CardLayout());
    myPreviewPanel.add(myEditorPreview.getPanel(), "editor");
    myPreviewPanel.add(myIdePreview, "ide");
    ((CardLayout) myPreviewPanel.getLayout()).show(myPreviewPanel, "editor");
    myPathField.getComboBox().setEditable(true);
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false).withFileFilter(file -> ImageFileTypeManager.getInstance().isImage(file));
    myPathField.addBrowseFolderListener(null, null, null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
    JTextComponent textComponent = getComboEditor();
    textComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            if (myAdjusting)
                return;
            imagePathChanged();
        }
    });
    for (Enumeration<AbstractButton> e = getTargetRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::targetChanged);
    }
    for (Enumeration<AbstractButton> e = getFillRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    for (Enumeration<AbstractButton> e = getPlaceRbGroup().getElements(); e.hasMoreElements(); ) {
        AbstractButton button = e.nextElement();
        button.setActionCommand(button.getText());
        button.addItemListener(this::fillOrPlaceChanged);
    }
    ChangeListener opacitySync = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (myAdjusting)
                return;
            myAdjusting = true;
            boolean b = e.getSource() == myOpacitySpinner;
            if (b) {
                int value = (Integer) myOpacitySpinner.getValue();
                myOpacitySpinner.setValue(Math.min(Math.max(0, value), 100));
                myOpacitySlider.setValue(value);
            } else {
                myOpacitySpinner.setValue(myOpacitySlider.getValue());
            }
            myAdjusting = false;
            opacityChanged();
        }
    };
    myOpacitySpinner.addChangeListener(opacitySync);
    myOpacitySlider.addChangeListener(opacitySync);
    myOpacitySlider.setValue(15);
    myOpacitySpinner.setValue(15);
    myScaleRb.setSelected(true);
    myCenterRb.setSelected(true);
    myEditorRb.setSelected(true);
    boolean perProject = !Comparing.equal(getBackgroundSpec(myProject, getSystemProp(true)), getBackgroundSpec(null, getSystemProp(true)));
    myThisProjectOnlyCb.setSelected(perProject);
    myAdjusting = false;
}
Also used : FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

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