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);
}
}
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);
}
Aggregations