use of com.intellij.openapi.vfs.VirtualFilePropertyEvent in project intellij-community by JetBrains.
the class EncodingPanel method install.
@Override
public void install(@NotNull StatusBar statusBar) {
super.install(statusBar);
// should update to reflect encoding-from-content
EncodingManager.getInstance().addPropertyChangeListener(evt -> {
if (evt.getPropertyName().equals(EncodingManagerImpl.PROP_CACHED_ENCODING_CHANGED)) {
Document document = evt.getSource() instanceof Document ? (Document) evt.getSource() : null;
updateForDocument(document);
}
}, this);
ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileAdapter() {
@Override
public void propertyChanged(@NotNull VirtualFilePropertyEvent event) {
if (VirtualFile.PROP_ENCODING.equals(event.getPropertyName())) {
updateForFile(event.getFile());
}
}
}));
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
Document document = e.getDocument();
updateForDocument(document);
}
}, this);
}
Aggregations