com.intellij.openapi.vfs.VirtualFileCopyEvent Java Examples

The following examples show how to use com.intellij.openapi.vfs.VirtualFileCopyEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalFilesystemModificationHandler.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void fileCopied(@NotNull VirtualFileCopyEvent event) {
  generateResourceCopyCreationActivity(event);
}
 
Example #2
Source File: LocalFilesystemModificationHandler.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates and dispatches creation activities for copied files. Copied directories are handled
 * by {@link #generateResourceCreationActivity(VirtualFileEvent)} (VirtualFileEvent)} and
 * contained files are subsequently handled by this listener.
 *
 * @param virtualFileCopyEvent event to react to
 * @see VirtualFileListener#fileCopied(VirtualFileCopyEvent)
 */
private void generateResourceCopyCreationActivity(
    @NotNull VirtualFileCopyEvent virtualFileCopyEvent) {

  assert enabled : "the file copied listener was triggered while it was disabled";

  VirtualFile copy = virtualFileCopyEvent.getFile();

  assert !copy.isDirectory()
      : "Unexpected copying event for directory. This should have been handled by the creation listener.";

  if (log.isTraceEnabled()) {
    log.trace(
        "Reacting to resource copying - original: "
            + virtualFileCopyEvent.getOriginalFile()
            + ", copy: "
            + copy);
  }

  Set<IReferencePoint> sharedReferencePoints = session.getReferencePoints();

  IFile copyWrapper = (IFile) VirtualFileConverter.convertToResource(sharedReferencePoints, copy);

  if (copyWrapper == null || !session.isShared(copyWrapper)) {
    if (log.isTraceEnabled()) {
      log.trace("Ignoring non-shared resource copy: " + copy);
    }

    return;
  }

  User user = session.getLocalUser();
  String charset = copy.getCharset().name();

  byte[] content = getContent(copy);

  IActivity activity =
      new FileActivity(
          user, Type.CREATED, FileActivity.Purpose.ACTIVITY, copyWrapper, null, content, charset);

  dispatchActivity(activity);
}
 
Example #3
Source File: VFSListener.java    From lsp4intellij with Apache License 2.0 2 votes vote down vote up
/**
 * Fired when a virtual file is copied from within IDEA.
 *
 * @param event the event object containing information about the change.
 */
@Override
public void fileCopied(@NotNull VirtualFileCopyEvent event) {
    fileCreated(event);
}