Java Code Examples for com.intellij.openapi.vfs.VirtualFileCopyEvent

The following examples show how to use com.intellij.openapi.vfs.VirtualFileCopyEvent. These examples are extracted from open source projects. 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
@Override
public void fileCopied(@NotNull VirtualFileCopyEvent event) {
  generateResourceCopyCreationActivity(event);
}
 
Example 2
/**
 * 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 Project: lsp4intellij   Source File: VFSListener.java    License: 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);
}