Search in sources :

Example 66 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter 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)

Example 67 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.

the class ProjectSpecificSettingsStep method registerValidators.

@Override
protected void registerValidators() {
    super.registerValidators();
    if (myProjectGenerator instanceof PythonProjectGenerator && !((PythonProjectGenerator) myProjectGenerator).hideInterpreter()) {
        myLocationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

            @Override
            protected void textChanged(DocumentEvent e) {
                final String path = myLocationField.getText().trim();
                ((PythonProjectGenerator) myProjectGenerator).locationChanged(PathUtil.getFileName(path));
            }
        });
        mySdkCombo.getComboBox().addItemListener(e -> {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                final Runnable checkValidOnSwing = () -> ApplicationManager.getApplication().invokeLater(this::checkValid);
                ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
                    try {
                        final Sdk sdk = getSdk();
                        if (sdk == null) {
                            return;
                        }
                        final boolean noPackages = PyPackageManager.getInstance(sdk).refreshAndGetPackages(true).isEmpty();
                        if (noPackages) {
                            LOGGER.warn(String.format("No packages on %s", sdk.getHomePath()));
                        }
                        checkValidOnSwing.run();
                    } catch (final ExecutionException exception) {
                        LOGGER.warn(exception);
                        checkValidOnSwing.run();
                    }
                }, "Refreshing List of Packages, Please Wait", false, null);
            }
        });
        UiNotifyConnector.doWhenFirstShown(mySdkCombo, this::checkValid);
    }
}
Also used : PythonProjectGenerator(com.jetbrains.python.newProject.PythonProjectGenerator) DocumentAdapter(com.intellij.ui.DocumentAdapter) Sdk(com.intellij.openapi.projectRoots.Sdk) DocumentEvent(javax.swing.event.DocumentEvent) ExecutionException(com.intellij.execution.ExecutionException)

Example 68 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.

the class AbstractCreateVirtualEnvDialog method registerValidators.

protected void registerValidators(final FacetValidatorsManager validatorsManager) {
    myDestination.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            validatorsManager.validate();
        }
    });
    myDestination.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            validatorsManager.validate();
        }
    });
    myName.addCaretListener(new CaretListener() {

        @Override
        public void caretUpdate(CaretEvent event) {
            validatorsManager.validate();
        }
    });
    myDestination.getTextField().addCaretListener(new CaretListener() {

        @Override
        public void caretUpdate(CaretEvent event) {
            validatorsManager.validate();
        }
    });
}
Also used : CaretEvent(javax.swing.event.CaretEvent) CaretListener(javax.swing.event.CaretListener) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 69 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter 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 70 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project flutter-intellij by flutter.

the class FlutterSettingsConfigurable method init.

private void init() {
    mySdkCombo.getComboBox().setEditable(true);
    final JTextComponent sdkEditor = (JTextComponent) mySdkCombo.getComboBox().getEditor().getEditorComponent();
    sdkEditor.getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            updateVersionText();
        }
    });
    mySdkCombo.addBrowseFolderListener("Select Flutter SDK Path", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
    myPrivacyPolicy.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            try {
                BrowserLauncher.getInstance().browse(new URI(FlutterBundle.message("flutter.analytics.privacyUrl")));
            } catch (URISyntaxException ignore) {
            }
        }
    });
    // noinspection Convert2Lambda
    myFormatCodeOnSaveCheckBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            myOrganizeImportsOnSaveCheckBox.setEnabled(myFormatCodeOnSaveCheckBox.isSelected());
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) ChangeEvent(javax.swing.event.ChangeEvent) MouseAdapter(java.awt.event.MouseAdapter) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) ChangeListener(javax.swing.event.ChangeListener) URISyntaxException(java.net.URISyntaxException) DocumentEvent(javax.swing.event.DocumentEvent) URI(java.net.URI)

Aggregations

DocumentAdapter (com.intellij.ui.DocumentAdapter)81 DocumentEvent (javax.swing.event.DocumentEvent)81 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)11 Document (javax.swing.text.Document)8 JTextComponent (javax.swing.text.JTextComponent)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 ItemEvent (java.awt.event.ItemEvent)6 ItemListener (java.awt.event.ItemListener)6 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 JBTextField (com.intellij.ui.components.JBTextField)5 ChangeEvent (javax.swing.event.ChangeEvent)5 Project (com.intellij.openapi.project.Project)4 FieldPanel (com.intellij.ui.FieldPanel)4 ChangeListener (javax.swing.event.ChangeListener)4 List (java.util.List)3 DocumentListener (javax.swing.event.DocumentListener)3 ProjectSelector (com.google.cloud.tools.intellij.project.ProjectSelector)2