Search in sources :

Example 76 with DocumentEvent

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

the class ChooseResourceDialog method createSearchField.

@NotNull
private SearchField createSearchField() {
    SearchField searchField = new // no history: interferes with arrow down to jump into the list
    SearchField(// no history: interferes with arrow down to jump into the list
    false) {

        @Override
        protected void showPopup() {
        // Turn off search popup; we're overriding the Down key to jump into the list instead
        }
    };
    searchField.getTextEditor().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            // Allow arrow down to jump directly into the list
            if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                e.consume();
                getSelectedPanel().selectFirst();
            }
        }
    });
    searchField.setMaximumSize(new Dimension(JBUI.scale(300), searchField.getMaximumSize().height));
    searchField.addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            updateFilter();
        }
    });
    return searchField;
}
Also used : SearchField(com.android.tools.idea.ui.SearchField) DocumentEvent(javax.swing.event.DocumentEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 77 with DocumentEvent

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

the class SelectDirWithFlashBuilderProjectsStep method setupInitialPathComponent.

private void setupInitialPathComponent() {
    myInitialPathComponent.getComponent().getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            onInitialPathChanged();
        }
    });
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, false, false) {

        public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) {
            return (super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || FlashBuilderProjectFinder.isFlashBuilderProject(file)) || FlashBuilderProjectFinder.hasArchiveExtension(file.getPath()));
        }

        public Icon getIcon(final VirtualFile file) {
            // do not use Flash Builder specific icon for zip
            return !file.isDirectory() && (FlashBuilderProjectFinder.hasFxpExtension(file.getPath()) || FlashBuilderProjectFinder.isFlashBuilderProject(file)) ? dressIcon(file, getBuilder().getIcon()) : super.getIcon(file);
        }
    };
    myInitialPathComponent.getComponent().addBrowseFolderListener(FlexBundle.message("select.flash.builder.workspace.or.project"), null, getWizardContext().getProject(), descriptor);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 78 with DocumentEvent

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

the class SwingUtils method addTextChangeListener.

public static void addTextChangeListener(final JTextComponent textComponent, final TextChangeListener textChangeListener) {
    final String[] oldTextContainer = { textComponent.getText() };
    textChangeListener.textChanged("", textComponent.getText());
    textComponent.getDocument().addDocumentListener(new DocumentListener() {

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

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

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

        public void textChanged() {
            String oldText = ObjectUtils.notNull(oldTextContainer[0], "");
            String newText = ObjectUtils.notNull(textComponent.getText(), "");
            if (!oldText.equals(newText)) {
                textChangeListener.textChanged(oldText, newText);
                oldTextContainer[0] = newText;
            }
        }
    });
}
Also used : DocumentListener(javax.swing.event.DocumentListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 79 with DocumentEvent

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

the class DartGeneratorPeer method enableIntellijLiveValidation.

private void enableIntellijLiveValidation() {
    final JTextComponent editorComponent = (JTextComponent) mySdkPathComboWithBrowse.getComboBox().getEditor().getEditorComponent();
    editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(final DocumentEvent e) {
            validateInIntelliJ();
        }
    });
    myCreateSampleProjectCheckBox.addActionListener(e -> validateInIntelliJ());
    myTemplatesList.addListSelectionListener(e -> validateInIntelliJ());
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent)

Example 80 with DocumentEvent

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

the class CompilerOptionsConfigurable method initButtonsAndAdditionalOptions.

private void initButtonsAndAdditionalOptions() {
    if (myMode == Mode.BC || myMode == Mode.Module) {
        final CompilerOptionsListener optionsListener = new CompilerOptionsListener() {

            public void optionsInTableChanged() {
                updateTreeTable();
            }

            public void additionalOptionsChanged() {
                updateAdditionalOptionsControls();
            }
        };
        if (myMode == Mode.BC) {
            myBCManager.getModuleLevelCompilerOptions().addOptionsListener(optionsListener, myDisposable);
        }
        myProjectLevelOptionsHolder.getProjectLevelCompilerOptions().addOptionsListener(optionsListener, myDisposable);
    }
    final ActionListener projectDefaultsListener = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            ModifiableCompilerOptions compilerOptions = myProjectLevelOptionsHolder.getProjectLevelCompilerOptions();
            final CompilerOptionsConfigurable configurable = new CompilerOptionsConfigurable(Mode.Project, null, myProject, myNature, myDependenciesConfigurable, compilerOptions);
            ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable);
        }
    };
    final ActionListener moduleDefaultsListener = new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            ModifiableCompilerOptions compilerOptions = myBCManager.getModuleLevelCompilerOptions();
            final CompilerOptionsConfigurable configurable = new CompilerOptionsConfigurable(Mode.Module, myModule, myProject, myNature, myDependenciesConfigurable, compilerOptions);
            ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable);
        }
    };
    myConfigFileTextWithBrowse.addBrowseFolderListener(null, null, myProject, FlexUtils.createFileChooserDescriptor("xml"));
    myConfigFileTextWithBrowse.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            updateAdditionalOptionsControls();
            fireConfigFileChanged();
        }
    });
    myConfigFileLabel.setVisible(myMode == Mode.BC);
    myConfigFileTextWithBrowse.setVisible(myMode == Mode.BC);
    myInheritedOptionsLabel.setVisible(myMode == Mode.BC || myMode == Mode.Module);
    myInheritedOptionsField.setVisible(myMode == Mode.BC || myMode == Mode.Module);
    final String labelText = myMode == Mode.BC ? "Additional compiler options:" : myMode == Mode.Module ? "Default options for module:" : "Default options for project:";
    myAdditionalOptionsLabel.setText(labelText);
    myAdditionalOptionsField.setDialogCaption(StringUtil.capitalizeWords(labelText, true));
    myAdditionalOptionsField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            updateAdditionalOptionsControls();
            fireAdditionalOptionsChanged();
        }
    });
    myNoteLabel.setIcon(UIUtil.getBalloonInformationIcon());
    myProjectDefaultsButton.addActionListener(projectDefaultsListener);
    myProjectDefaultsButton.setVisible(myMode == Mode.BC || myMode == Mode.Module);
    myModuleDefaultsButton.addActionListener(moduleDefaultsListener);
    myModuleDefaultsButton.setVisible(myMode == Mode.BC);
}
Also used : CompilerOptionsListener(com.intellij.lang.javascript.flex.projectStructure.model.CompilerOptionsListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentEvent(javax.swing.event.DocumentEvent) ModifiableCompilerOptions(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableCompilerOptions)

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