return project.getUserData(LIVE_PREVIEW_QUEUE);
}
private static final Key<MergingUpdateQueue> LIVE_PREVIEW_QUEUE = Key.create("LIVE_PREVIEW_QUEUE");
private static void installUpdateListener(final Project project) {
MergingUpdateQueue queue = project.getUserData(LIVE_PREVIEW_QUEUE);
if (queue == null) {
JComponent activationComponent = WindowManager.getInstance().getFrame(project).getRootPane();
project.putUserData(LIVE_PREVIEW_QUEUE, queue = new MergingUpdateQueue("LIVE_PREVIEW_QUEUE", 1000, true, null, project, activationComponent));
}
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
final MergingUpdateQueue finalQueue = queue;
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
Document document = e.getDocument();
final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
VirtualFile file = fileDocumentManager.getFile(document);
if (file == null || file.getFileType() != BnfFileType.INSTANCE) return;
finalQueue.cancelAllUpdates();
finalQueue.queue(new Update(Boolean.TRUE, true) {
@Override
public void run() {
FileManager fileManager = ((PsiManagerEx)PsiManager.getInstance(project)).getFileManager();
for (FileEditor fileEditor : fileEditorManager.getAllEditors()) {
if (!(fileEditor instanceof TextEditor)) continue;