use of com.intellij.openapi.vfs.VirtualFileEvent in project intellij-community by JetBrains.
the class MovePackageAsDirectoryTest method testMultipleClassesInOneFile.
public void testMultipleClassesInOneFile() throws Exception {
final boolean[] fileWasDeleted = new boolean[] { false };
final VirtualFileAdapter fileAdapter = new VirtualFileAdapter() {
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
fileWasDeleted[0] = !event.getFile().isDirectory();
}
};
VirtualFileManager.getInstance().addVirtualFileListener(fileAdapter);
try {
doTest(createAction("pack1", "target"));
} finally {
VirtualFileManager.getInstance().removeVirtualFileListener(fileAdapter);
}
Assert.assertFalse("Deleted instead of moved", fileWasDeleted[0]);
}
use of com.intellij.openapi.vfs.VirtualFileEvent in project intellij-community by JetBrains.
the class ConfigProjectComponent method runActivity.
@Override
public void runActivity(@NotNull Project project) {
// Register project-level config managers
final EditorFactory editorFactory = EditorFactory.getInstance();
MessageBus bus = project.getMessageBus();
EditorSettingsManager editorSettingsManager = new EditorSettingsManager(project);
EncodingManager encodingManager = new EncodingManager(project);
LineEndingsManager lineEndingsManager = new LineEndingsManager(project);
bus.connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, encodingManager);
bus.connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, editorSettingsManager);
bus.connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, lineEndingsManager);
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
updateOpenEditors(event);
}
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
updateOpenEditors(event);
}
@Override
public void contentsChanged(@NotNull VirtualFileEvent event) {
updateOpenEditors(event);
}
private void updateOpenEditors(VirtualFileEvent event) {
final VirtualFile file = event.getFile();
if (".editorconfig".equals(file.getName())) {
if (ProjectRootManager.getInstance(project).getFileIndex().isInContent(file) || !Registry.is("editor.config.stop.at.project.root")) {
for (Editor editor : editorFactory.getAllEditors()) {
if (editor.isDisposed())
continue;
;
((EditorEx) editor).reinitSettings();
}
}
}
}
}, project);
}
use of com.intellij.openapi.vfs.VirtualFileEvent in project intellij-plugins by JetBrains.
the class PhoneGapStartupActivity method runActivity.
@Override
public void runActivity(@NotNull Project project) {
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {
if (PhoneGapUtil.isPhoneGapProject(project)) {
if (PhoneGapSettings.getInstance().isExcludePlatformFolder()) {
excludeWorkingDirectories(project);
}
PhoneGapExecutableChecker.check(project);
}
});
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileListener() {
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
if (!isProcess(event)) {
return;
}
updateModuleExcludeByFSEvent(project, event, ContainerUtil.newHashSet(), ContainerUtil.newHashSet(getExcludedFolderNames(event)));
}
@Override
public void beforeFileDeletion(@NotNull VirtualFileEvent event) {
if (!isProcess(event)) {
return;
}
updateModuleExcludeByFSEvent(project, event, getExcludedFolderNames(event), ContainerUtil.newHashSet());
}
private boolean isProcess(@NotNull VirtualFileEvent event) {
return shouldExcludeDirectory(event) && PhoneGapUtil.isPhoneGapProject(project) && PhoneGapSettings.getInstance().isExcludePlatformFolder();
}
}, project);
}
Aggregations