Search in sources :

Example 21 with DocumentListener

use of com.intellij.openapi.editor.event.DocumentListener in project intellij-community by JetBrains.

the class GroovyMapParameterDialog method setUpNameComboBox.

private void setUpNameComboBox(String[] possibleNames) {
    final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, GroovyFileType.GROOVY_FILE_TYPE, myNameComboBox);
    myNameComboBox.setEditor(comboEditor);
    myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
    myNameComboBox.setEditable(true);
    myNameComboBox.setMaximumRowCount(8);
    myListenerList.add(DataChangedListener.class, new DataChangedListener());
    myNameComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fireNameDataChanged();
        }
    });
    ((EditorTextField) myNameComboBox.getEditor().getEditorComponent()).addDocumentListener(new DocumentListener() {

        @Override
        public void beforeDocumentChange(DocumentEvent event) {
        }

        @Override
        public void documentChanged(DocumentEvent event) {
            fireNameDataChanged();
        }
    });
    contentPane.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true);
            });
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
    for (String possibleName : possibleNames) {
        myNameComboBox.addItem(possibleName);
    }
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) DocumentListener(com.intellij.openapi.editor.event.DocumentListener) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) EditorTextField(com.intellij.ui.EditorTextField) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 22 with DocumentListener

use of com.intellij.openapi.editor.event.DocumentListener in project oxy-template-support-plugin by mutant-industries.

the class CompiledPreviewController method initCompiledCodeUpdater.

// ----------------------------------------------------------------------------------------------------
private void initCompiledCodeUpdater() {
    updateQueue = new MergingUpdateQueue("LIVE_PREVIEW_QUEUE", 1000, true, null, myProject);
    EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentListener() {

        @Override
        public void documentChanged(DocumentEvent e) {
            Document document = e.getDocument();
            VirtualFile file = FileDocumentManager.getInstance().getFile(document);
            if (file == null || file.getFileType() != OxyTemplateFileType.INSTANCE) {
                return;
            }
            updateQueue.cancelAllUpdates();
            updateQueue.queue(new CompiledPreviewUpdater(Boolean.TRUE, myProject));
        }
    }, myProject);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) DocumentListener(com.intellij.openapi.editor.event.DocumentListener) MergingUpdateQueue(com.intellij.util.ui.update.MergingUpdateQueue) DocumentEvent(com.intellij.openapi.editor.event.DocumentEvent) Document(com.intellij.openapi.editor.Document)

Aggregations

DocumentListener (com.intellij.openapi.editor.event.DocumentListener)22 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)13 Document (com.intellij.openapi.editor.Document)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Editor (com.intellij.openapi.editor.Editor)3 EditorTextField (com.intellij.ui.EditorTextField)3 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 PsiFile (com.intellij.psi.PsiFile)2 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)2 EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)2 EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)2 StringComboboxEditor (com.intellij.ui.StringComboboxEditor)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 Log (com.android.ddmlib.Log)1 CompletionParameters (com.intellij.codeInsight.completion.CompletionParameters)1 DocumentContent (com.intellij.diff.contents.DocumentContent)1 Language (com.intellij.lang.Language)1