Java 类com.intellij.openapi.vfs.VirtualFileAdapter 实例源码

项目:intellij-ce-playground    文件:MovePackageAsDirectoryTest.java   
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]);
}
项目:tools-idea    文件:MovePackageAsDirectoryTest.java   
public void testMultipleClassesInOneFile() throws Exception {
  final boolean [] fileWasDeleted = new boolean[]{false};
  final VirtualFileAdapter fileAdapter = new VirtualFileAdapter() {
    @Override
    public void fileDeleted(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]);
}
项目:consulo-java    文件:MovePackageAsDirectoryTest.java   
public void testMultipleClassesInOneFile() throws Exception {
  final boolean [] fileWasDeleted = new boolean[]{false};
  final VirtualFileAdapter fileAdapter = new VirtualFileAdapter() {
    @Override
    public void fileDeleted(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]);
}
项目:branch-window-title    文件:BranchNameFrameTitleBuilder.java   
/**
 * Maintain watch on gitHeadFile via {@link VirtualFileManager#addVirtualFileListener(VirtualFileListener)}.
 */
private void registerFileChangedListener(final String gitHeadFilePath) {
  if (!gitHeadFileWatchSet.contains(gitHeadFilePath)) {
    gitHeadFileWatchSet.add(gitHeadFilePath);
    VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
      @Override
      public void contentsChanged(@NotNull VirtualFileEvent event) {
        if (gitHeadFilePath.equals(event.getFile().getCanonicalPath())) {
          final String branchName = determineBranchName(event.getFile());
          updateFrameTitle(getProjectForFile(event.getFile()), branchName);
        }
      }
    });
  }
}
项目:intellij-ce-playground    文件:UserDeviceManager.java   
public UserDeviceManager() {
  myListener = new VirtualFileAdapter() {
    @Override
    public void contentsChanged(@NotNull VirtualFileEvent event) {
      final VirtualFile file = event.getFile();
      if (myUserDevicesFile != null && SdkConstants.FN_DEVICES_XML.equals(file.getName()) &&
          FileUtil.pathsEqual(FileUtil.toSystemIndependentName(myUserDevicesFile.getPath()),
                              file.getPath())) {
        userDevicesChanged();
      }
    }
  };
  LocalFileSystem.getInstance().addVirtualFileListener(myListener);
}
项目:intellij-ce-playground    文件:GroovyDslFileIndex.java   
public GroovyDslFileIndex() {
  VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
    @Override
    public void contentsChanged(@NotNull VirtualFileEvent event) {
      final VirtualFile file = event.getFile();
      if (event.isFromRefresh() || !GdslUtil.GDSL_FILTER.value(file) || getStatus(file) != Status.ACTIVE) return;
      disableFile(file, Status.MODIFIED, null);
    }
  });
}
项目:intellij-fmt    文件:FmtProjectPlugin.java   
Formatter()
{
    LocalFileSystem.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
        @Override
        public void contentsChanged(@NotNull VirtualFileEvent event) {
            super.contentsChanged(event);
        }
    });
}
项目:tools-idea    文件:GroovyDslFileIndex.java   
public GroovyDslFileIndex() {
  VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {

    @Override
    public void contentsChanged(VirtualFileEvent event) {
      if (event.getFileName().endsWith(".gdsl")) {
        disableFile(event.getFile(), MODIFIED);
      }
    }

  });
}
项目:floobits-intellij    文件:Listener.java   
public synchronized void start(final EditorEventHandler editorManager) {
    this.editorManager = editorManager;
    connection.subscribe(VirtualFileManager.VFS_CHANGES, this);
    connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, this);
    em.addDocumentListener(this);
    em.addSelectionListener(this);
    em.addCaretListener(this);
    em.addVisibleAreaListener(this);


    virtualFileAdapter = new VirtualFileAdapter() {
        public void beforePropertyChange(@NotNull final VirtualFilePropertyEvent event) {
            if (!event.getPropertyName().equals(VirtualFile.PROP_NAME)) {
                return;
            }
            VirtualFile parent = event.getParent();
            if (parent == null) {
                return;
            }
            String parentPath = parent.getPath();
            // XXX: pretty sure is this wrong.
            String newValue = parentPath + "/" + event.getNewValue().toString();
            String oldValue = parentPath + "/" + event.getOldValue().toString();
            editorManager.rename(oldValue, newValue);
        }
    };
    VirtualFileManager.getInstance().addVirtualFileListener(virtualFileAdapter);
}
项目:consulo    文件:NewFileTracker.java   
private NewFileTracker() {
  final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
  virtualFileManager.addVirtualFileListener(new VirtualFileAdapter() {
    @Override
    public void fileCreated(@Nonnull VirtualFileEvent event) {
      if (event.isFromRefresh()) return;
      newFiles.add(event.getFile());
    }
  });
}
项目:pomodoro-todo-comments    文件:PomodoroCommentVSFListener.java   
public void projectOpened() {
    TimerEventsSourceAppComponent timerEventsSource = ApplicationManager.getApplication().getComponent(TimerEventsSourceAppComponent.class);
    listener = new TimerEventsSourceAppComponent.Listener() {
        @Override
        public void onTimerEvent() {
            if (!status.equals(PomodoroStatus.IDLE)) {
                remainingSeconds--;
                if (remainingSeconds <= 0) {
                    switch (status) {
                        case RESTING:
                            remainingSeconds = POMODORO_LENGTH;
                            status = PomodoroStatus.IDLE;
                            //TODO show message
                            break;
                        case RUNNING:
                            remainingSeconds = REST_LENGTH;
                            status = PomodoroStatus.RESTING;
                            //TODO increase todo pomodoro # in comment, and remove *
                            break;
                    }
                }
                System.out.println(status + " " + formatTime(remainingSeconds));
            }
        }
    };
    timerEventsSource.addListener(listener);


    VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
        @Override
        public void contentsChanged(VirtualFileEvent event) {
            PsiTodoSearchHelper todoHelper = PsiTodoSearchHelper.SERVICE.getInstance(myProject);
            PsiFile psiFile = PsiManager.getInstance(myProject).findFile(event.getFile());

            TodoItem[] todoItems = getTodoItems(todoHelper, psiFile);
            String activePomodoroText = extractTodoTextOnly(getTodoItemText(activeTodoItem));
            for (TodoItem todoItem : todoItems) {
                String todoText = getTodoItemText(todoItem);
                String pomodoroText = extractTodoTextOnly(todoText);
                if (matchActivePattern(todoText)) {
                    if (!pomodoroText.equals(activePomodoroText)) {
                        setActivePomodoro(todoItem, myProject);
                    }
                    break;
                } else {
                    if (matchInactivePattern(todoText) && pomodoroText.equals(activePomodoroText)) {
                        setInactivePomodoro(todoText, myProject);
                    }
                }

            }
        }
    }, myProject);
}