Java 类com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent 实例源码

项目:opencms-intellijplugin    文件:OpenCmsModuleFileChangeListener.java   
/**
 * Internal handler for file delete, move and rename events
 * @param event IntelliJ's file change event
 * @throws CmsConnectionException if the connection to OpenCms fails
 */
private void handleFileEvent(VFileEvent event) throws CmsConnectionException {
    // File is deleted
    if (event instanceof VFileDeleteEvent) {
        handleFileDeleteEvent(event);
    }
    // File is moved
    if (event instanceof VFileMoveEvent) {
        handleFileMoveEvent(event);
    }

    // File is renamed
    if (event instanceof VFilePropertyChangeEvent) {
        String propertyName = ((VFilePropertyChangeEvent)event).getPropertyName();
        if ("name".equals(propertyName)) {
            handleFileRenameEvent(event);
        }
    }
}
项目:intellij    文件:BulkSymbolTableBuildingChangeListener.java   
@Override
public void after(List<? extends VFileEvent> events) {
  if (!enabled) {
    return;
  }
  for (VFileEvent event : events) {
    VirtualFile modifiedFile = null;
    // Skip delete events.
    if (event instanceof VFileContentChangeEvent || event instanceof VFileCreateEvent) {
      modifiedFile = event.getFile();
    } else if (event instanceof VFileCopyEvent) {
      VFileCopyEvent copyEvent = (VFileCopyEvent) event;
      modifiedFile = copyEvent.getNewParent();
    } else if (event instanceof VFileMoveEvent) {
      VFileMoveEvent moveEvent = (VFileMoveEvent) event;
      modifiedFile = moveEvent.getNewParent();
    } else if (event instanceof VFilePropertyChangeEvent) {
      VFilePropertyChangeEvent propEvent = (VFilePropertyChangeEvent) event;
      // Check for file renames (sometimes we get property change events without the name
      // actually changing though)
      if (propEvent.getPropertyName().equals(VirtualFile.PROP_NAME)
          && !propEvent.getOldValue().equals(propEvent.getNewValue())) {
        modifiedFile = propEvent.getFile();
      }
    }
    if (SymbolTableProvider.isSourceFile(modifiedFile)) {
      queueChange(modifiedFile);
    }
  }
}
项目:manifold-ij    文件:FileModificationManager.java   
private boolean isMoveOrRename( VFileEvent event )
{
  return event instanceof VFilePropertyChangeEvent && ((VFilePropertyChangeEvent)event).getPropertyName().equals( VirtualFile.PROP_NAME ) ||
         event instanceof VFileMoveEvent;
}
项目:intellij-ce-playground    文件:VfsImplUtil.java   
private static void checkSubscription() {
  if (ourSubscribed.getAndSet(true)) return;

  Application app = ApplicationManager.getApplication();
  app.getMessageBus().connect(app).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
    @Override
    public void after(@NotNull List<? extends VFileEvent> events) {
      InvalidationState state = null;

      synchronized (ourLock) {
        for (VFileEvent event : events) {
          if (!(event.getFileSystem() instanceof LocalFileSystem)) continue;

          if (event instanceof VFileCreateEvent) continue; // created file should not invalidate + getFile is costly

          if (event instanceof VFilePropertyChangeEvent &&
              !VirtualFile.PROP_NAME.equals(((VFilePropertyChangeEvent)event).getPropertyName())) {
            continue;
          }

          String path = event.getPath();
          if (event instanceof VFilePropertyChangeEvent) {
            path = ((VFilePropertyChangeEvent)event).getOldPath();
          }
          else if (event instanceof VFileMoveEvent) {
            path = ((VFileMoveEvent)event).getOldPath();
          }

          VirtualFile file = event.getFile();
          if (file == null || !file.isDirectory()) {
            state = InvalidationState.invalidate(state, path);
          }
          else {
            Collection<String> affectedPaths = ourDominatorsMap.get(path);
            if (affectedPaths != null) {
              affectedPaths = ContainerUtil.newArrayList(affectedPaths);  // defensive copying; original may be updated on invalidation
              for (String affectedPath : affectedPaths) {
                state = InvalidationState.invalidate(state, affectedPath);
              }
            }
          }
        }
      }

      if (state != null) state.scheduleRefresh();
    }
  });
}
项目:intellij-ce-playground    文件:PushedFilePropertiesUpdaterImpl.java   
public void processAfterVfsChanges(@NotNull List<? extends VFileEvent> events) {
  boolean pushedSomething = false;
  List<Runnable> delayedTasks = ContainerUtil.newArrayList();
  for (VFileEvent event : events) {
    final VirtualFile file = event.getFile();
    if (file == null) continue;

    final FilePropertyPusher[] pushers = file.isDirectory() ? myPushers : myFilePushers;
    if (pushers.length == 0) continue;

    if (event instanceof VFileCreateEvent) {
      if (!event.isFromRefresh() || !file.isDirectory()) {
        // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
        // avoid dumb mode for just one file
        doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
        pushedSomething = true;
      }
      else if (!ProjectCoreUtil.isProjectOrWorkspaceFile(file)) {
        ContainerUtil.addIfNotNull(delayedTasks, createRecursivePushTask(file, pushers));
      }
    } else if (event instanceof VFileMoveEvent) {
      for (FilePropertyPusher pusher : pushers) {
        file.putUserData(pusher.getFileDataKey(), null);
      }
      // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
      doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
      pushedSomething = true;
    }
  }
  if (!delayedTasks.isEmpty()) {
    queueTasks(delayedTasks);
  }
  if (pushedSomething) {
    Application application = ApplicationManager.getApplication();
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        scheduleDumbModeReindexingIfNeeded();
      }
    };
    if (application.isUnitTestMode()) {
      runnable.run();
    } else {
      application.invokeLater(runnable);
    }
  }
}
项目:consulo    文件:VfsImplUtil.java   
private static void checkSubscription() {
  if (ourSubscribed.getAndSet(true)) return;

  Application app = ApplicationManager.getApplication();
  app.getMessageBus().connect(app).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
    @Override
    public void after(@Nonnull List<? extends VFileEvent> events) {
      InvalidationState state = null;

      synchronized (ourLock) {
        for (VFileEvent event : events) {
          if (!(event.getFileSystem() instanceof LocalFileSystem)) continue;

          if (event instanceof VFileCreateEvent) continue; // created file should not invalidate + getFile is costly

          if (event instanceof VFilePropertyChangeEvent && !VirtualFile.PROP_NAME.equals(((VFilePropertyChangeEvent)event).getPropertyName())) {
            continue;
          }

          String path = event.getPath();
          if (event instanceof VFilePropertyChangeEvent) {
            path = ((VFilePropertyChangeEvent)event).getOldPath();
          }
          else if (event instanceof VFileMoveEvent) {
            path = ((VFileMoveEvent)event).getOldPath();
          }

          VirtualFile file = event.getFile();
          if (file == null || !file.isDirectory()) {
            state = InvalidationState.invalidate(state, path);
          }
          else {
            Collection<String> affectedPaths = ourDominatorsMap.get(path);
            if (affectedPaths != null) {
              affectedPaths = ContainerUtil.newArrayList(affectedPaths);  // defensive copying; original may be updated on invalidation
              for (String affectedPath : affectedPaths) {
                state = InvalidationState.invalidate(state, affectedPath);
              }
            }
          }
        }
      }

      if (state != null) state.scheduleRefresh();
    }
  });
}
项目:consulo    文件:PushedFilePropertiesUpdaterImpl.java   
public void processAfterVfsChanges(@Nonnull List<? extends VFileEvent> events) {
  boolean pushedSomething = false;
  List<Runnable> delayedTasks = ContainerUtil.newArrayList();
  for (VFileEvent event : events) {
    final VirtualFile file = event.getFile();
    if (file == null) continue;

    final FilePropertyPusher[] pushers = file.isDirectory() ? myPushers : myFilePushers;
    if (pushers.length == 0) continue;

    if (event instanceof VFileCreateEvent) {
      if (!event.isFromRefresh() || !file.isDirectory()) {
        // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
        // avoid dumb mode for just one file
        doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
        pushedSomething = true;
      }
      else if (!ProjectCoreUtil.isProjectOrWorkspaceFile(file)) {
        ContainerUtil.addIfNotNull(delayedTasks, createRecursivePushTask(file, pushers));
      }
    } else if (event instanceof VFileMoveEvent) {
      for (FilePropertyPusher pusher : pushers) {
        file.putUserData(pusher.getFileDataKey(), null);
      }
      // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
      doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
      pushedSomething = true;
    }
  }
  if (!delayedTasks.isEmpty()) {
    queueTasks(delayedTasks);
  }
  if (pushedSomething) {
    GuiUtils.invokeLaterIfNeeded(new Runnable() {
      @Override
      public void run() {
        PushedFilePropertiesUpdaterImpl.this.scheduleDumbModeReindexingIfNeeded();
      }
    }, ModalityState.defaultModalityState());
  }
}