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]); }
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]); }
/** * 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); } } }); } }
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); }
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); } }); }
Formatter() { LocalFileSystem.getInstance().addVirtualFileListener(new VirtualFileAdapter() { @Override public void contentsChanged(@NotNull VirtualFileEvent event) { super.contentsChanged(event); } }); }
public GroovyDslFileIndex() { VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() { @Override public void contentsChanged(VirtualFileEvent event) { if (event.getFileName().endsWith(".gdsl")) { disableFile(event.getFile(), MODIFIED); } } }); }
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); }
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()); } }); }
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); }