本文整理汇总了Java中com.intellij.openapi.vfs.newvfs.BulkFileListener类的典型用法代码示例。如果您正苦于以下问题:Java BulkFileListener类的具体用法?Java BulkFileListener怎么用?Java BulkFileListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BulkFileListener类属于com.intellij.openapi.vfs.newvfs包,在下文中一共展示了BulkFileListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reparseFiles
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
/**
* Forces a reparse of the specified collection of files.
*
* @param files the files to reparse.
*/
public static void reparseFiles(@NotNull final Collection<VirtualFile> files) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// files must be processed under one write action to prevent firing event for invalid files.
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
for (VirtualFile file : files) {
saveOrReload(file, events);
}
BulkFileListener publisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
List<VFileEvent> eventList = new ArrayList<VFileEvent>(events);
publisher.before(eventList);
publisher.after(eventList);
}
});
}
示例2: notifyPropertyChanged
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
@Override
public void notifyPropertyChanged(@NotNull final VirtualFile virtualFile, @NotNull final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例3: AndroidProjectTreeBuilder
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public AndroidProjectTreeBuilder(@NotNull Project project,
@NotNull JTree tree,
@NotNull DefaultTreeModel treeModel,
@Nullable Comparator<NodeDescriptor> comparator,
@NotNull ProjectAbstractTreeStructureBase treeStructure) {
super(project, tree, treeModel, comparator, treeStructure);
MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent e : events) {
if (e instanceof VFileDeleteEvent) {
removeMapping(e.getFile());
}
}
}
});
}
示例4: activate
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public void activate() {
if (messageBusConnection != null) {
return;
}
messageBusConnection = project.getMessageBus().connect();
messageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
if (event instanceof VFileDeleteEvent) {
synchronized (changedFiles) {
changedFiles.remove(event.getFile());
}
}
}
}
});
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(listener, project);
}
示例5: notifyPropertyChanged
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
@Override
public void notifyPropertyChanged(final VirtualFile virtualFile, final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例6: reparseFiles
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
@RequiredDispatchThread
public static void reparseFiles(@Nonnull final Collection<VirtualFile> files) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// files must be processed under one write action to prevent firing event for invalid files.
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
for (VirtualFile file : files) {
saveOrReload(file, events);
}
BulkFileListener publisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
List<VFileEvent> eventList = new ArrayList<VFileEvent>(events);
publisher.before(eventList);
publisher.after(eventList);
}
});
}
示例7: notifyPropertyChanged
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
@Override
public void notifyPropertyChanged(@Nonnull final VirtualFile virtualFile, @Nonnull final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例8: GistManagerImpl
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public GistManagerImpl() {
ApplicationManager.getApplication().getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@Nonnull List<? extends VFileEvent> events) {
if (events.stream().anyMatch(this::shouldDropCache)) {
invalidateData();
}
}
private boolean shouldDropCache(VFileEvent e) {
if (!(e instanceof VFilePropertyChangeEvent)) return false;
String propertyName = ((VFilePropertyChangeEvent)e).getPropertyName();
return propertyName.equals(VirtualFile.PROP_NAME) || propertyName.equals(VirtualFile.PROP_ENCODING);
}
});
}
示例9: NonClasspathClassFinder
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public NonClasspathClassFinder(@NotNull Project project, @NotNull String... fileExtensions)
{
myProject = project;
myPackageManager = PsiPackageManager.getInstance(myProject);
myManager = PsiManager.getInstance(myProject);
myFileExtensions = ArrayUtil.append(fileExtensions, "class");
final MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener()
{
@Override
public void after(@NotNull List<? extends VFileEvent> events)
{
clearCache();
}
});
LowMemoryWatcher.register(this::clearCache, project);
}
示例10: NonClasspathClassFinder
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public NonClasspathClassFinder(Project project, String... fileExtensions) {
myProject = project;
myManager = PsiManager.getInstance(myProject);
myFileExtensions = ArrayUtil.append(fileExtensions, "class");
final MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
clearCache();
}
});
}
示例11: testJarRefresh
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public void testJarRefresh() throws IOException {
File jar = IoTestUtil.createTestJar();
assertTrue(jar.setLastModified(jar.lastModified() - 1000));
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jar);
assertNotNull(vFile);
VirtualFile jarRoot = findByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR);
assertEquals(1, jarRoot.getChildren().length);
final VirtualFile entry = findByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR + JarFile.MANIFEST_NAME);
assertContent(entry, "");
final Ref<Boolean> updated = Ref.create(false);
ApplicationManager.getApplication().getMessageBus().connect(myTestRootDisposable).subscribe(
VirtualFileManager.VFS_CHANGES,
new BulkFileListener.Adapter() {
@Override
public void before(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
if (event instanceof VFileContentChangeEvent && entry.equals(event.getFile())) {
updated.set(true);
break;
}
}
}
}
);
IoTestUtil.createTestJar(jar, JarFile.MANIFEST_NAME, "update", "some.txt", "some text");
vFile.refresh(false, false);
assertTrue(updated.get());
assertTrue(entry.isValid());
assertContent(entry, "update");
assertEquals(2, jarRoot.getChildren().length);
VirtualFile newEntry = findByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR + "some.txt");
assertContent(newEntry, "some text");
}
示例12: VFSTestFrameworkListener
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public VFSTestFrameworkListener() {
myService = PyTestFrameworkService.getInstance();
MessageBus messageBus = ApplicationManager.getApplication().getMessageBus();
messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
if (!(event.getFileSystem() instanceof LocalFileSystem) || event instanceof VFileContentChangeEvent)
continue;
final String path = event.getPath();
boolean containsNose = path.contains(PyNames.NOSE_TEST);
boolean containsPy = path.contains("py-1") || path.contains(PyNames.PY_TEST);
boolean containsAt = path.contains(PyNames.AT_TEST);
if (!containsAt && !containsNose && !containsPy) continue;
for (Sdk sdk : PythonSdkType.getAllSdks()) {
if (PySdkUtil.isRemote(sdk)) {
continue;
}
for (VirtualFile virtualFile : sdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
String root = virtualFile.getCanonicalPath();
if (root != null && path.contains(root)) {
if (containsNose) {
updateTestFrameworks(sdk, PyNames.NOSE_TEST);
return;
}
else if (containsPy) {
updateTestFrameworks(sdk, PyNames.PY_TEST);
return;
}
else {
updateTestFrameworks(sdk, PyNames.AT_TEST);
return;
}
}
}
}
}
}
});
}
示例13: imitateEvent
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public static void imitateEvent(VirtualFile dir) {
final VirtualFile child = dir.findChild(".svn");
assertNotNull(child);
final VirtualFile wcdb = child.findChild("wc.db");
assertNotNull(wcdb);
final BulkFileListener listener = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
final VFileContentChangeEvent event =
new VFileContentChangeEvent(null, wcdb, wcdb.getModificationStamp() - 1, wcdb.getModificationStamp(), true);
final List<VFileContentChangeEvent> events = Collections.singletonList(event);
listener.before(events);
listener.after(events);
}
示例14: setUp
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
LOG.debug("================== setting up " + getName() + " ==================");
super.setUp();
myFileSystem = LocalFileSystem.getInstance();
assertNotNull(myFileSystem);
myWatcher = ((LocalFileSystemImpl)myFileSystem).getFileWatcher();
assertNotNull(myWatcher);
assertFalse(myWatcher.isOperational());
myWatcher.startup(myNotifier);
assertTrue(myWatcher.isOperational());
myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, getProject());
myTimeout = NATIVE_PROCESS_DELAY;
myConnection = ApplicationManager.getApplication().getMessageBus().connect();
myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
synchronized (myEvents) {
myEvents.addAll(events);
}
}
});
((LocalFileSystemImpl)myFileSystem).cleanupForNextTest();
LOG = FileWatcher.getLog();
LOG.debug("================== setting up " + getName() + " ==================");
}
示例15: IgnoredFilesComponent
import com.intellij.openapi.vfs.newvfs.BulkFileListener; //导入依赖的package包/类
public IgnoredFilesComponent(final Project project, final boolean registerListener) {
myFilesToIgnore = new LinkedHashSet<IgnoredFileBean>();
myFilesMap = new HashMap<String, IgnoredFileBean>();
if (registerListener) {
project.getMessageBus().connect(project).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
resetCaches();
}
});
}
}