本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFileEvent类的典型用法代码示例。如果您正苦于以下问题:Java VirtualFileEvent类的具体用法?Java VirtualFileEvent怎么用?Java VirtualFileEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualFileEvent类属于com.intellij.openapi.vfs包,在下文中一共展示了VirtualFileEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fileCreated
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
//process only for files inside the language directory
if (event.getFile().getParent().isDirectory() && event.getFile().getParent().getNameWithoutExtension().compareTo("languages") == 0) {
if (GravYamlFiles.getLanguageFileType(event.getFile()) == GravYamlFiles.LangFileEditorType.LANGUAGE_FOLDER) {
boolean present = false;
for (VirtualFile each : getFileMap().values()) {
if (each.getName().compareTo(event.getFile().getName()) == 0) {
present = true;
break;
}
}
if (!present) {
getFileMap().put(event.getFile().getNameWithoutExtension(), event.getFile());
model.addLanguage(event.getFile().getNameWithoutExtension());
editor.initTabs();
}
} else {
NotificationHelper.showBaloon("Not a valid language resource name", MessageType.WARNING, project);
}
}
}
示例2: testMultipleClassesInOneFile
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
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]);
}
示例3: _testContentChanged_reloadChangedDocumentOnSave
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public void _testContentChanged_reloadChangedDocumentOnSave() throws Exception {
final MockVirtualFile file = new MockVirtualFile("test.txt", "test\rtest") {
@Override
public void refresh(boolean asynchronous, boolean recursive, Runnable postRunnable) {
long oldStamp = getModificationStamp();
setModificationStamp(LocalTimeCounter.currentTime());
myDocumentManager.contentsChanged(new VirtualFileEvent(null, this, null, oldStamp, getModificationStamp()));
}
};
Document document = myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
document.insertString(0, "zzz");
file.setContent(null, "xxx", false);
myReloadFromDisk = Boolean.TRUE;
myDocumentManager.saveAllDocuments();
long fileStamp = file.getModificationStamp();
assertEquals("xxx", document.getText());
assertEquals(file.getModificationStamp(), document.getModificationStamp());
assertEquals(file.getModificationStamp(), fileStamp);
assertEquals(0, myDocumentManager.getUnsavedDocuments().length);
}
示例4: fileDeleted
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
if (myProject.isDisposed() || !myProject.isOpen()) {
return;
}
VirtualFile removedFile = event.getFile();
final TaskFile taskFile = CCProjectService.getInstance(myProject).getTaskFile(removedFile);
if (taskFile != null) {
deleteAnswerFile(removedFile, taskFile);
return;
}
Course course = CCProjectService.getInstance(myProject).getCourse();
if (course == null) {
return;
}
if (removedFile.getName().contains(EduNames.TASK)) {
deleteTask(course, removedFile, myProject);
}
if (removedFile.getName().contains(EduNames.LESSON)) {
deleteLesson(course, removedFile);
}
}
示例5: shouldIgnore
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
private static boolean shouldIgnore(VirtualFileEvent event) {
String fileName = event.getFileName();
if (NAVIGATION_FILE_NAME.equals(fileName)) {
return true;
}
String pathName = event.getFile().getCanonicalPath();
if (pathName == null) {
return false;
}
for (String segment : EXCLUDED_PATH_SEGMENTS) {
if (pathName.contains(segment)) {
return true;
}
}
return false;
}
示例6: executeMake
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
private void executeMake(final VirtualFileEvent event) {
if(
(pluginConfiguration == null || pluginConfiguration.isIncrementalBuilds())
// If no Configuration Selected which can happen when the project is not AEM / Sling based then do nothing
&& serverConnectionManager.isConfigurationSelected()
) {
// Check if the file is a Java Class and if os build it
VirtualFile file = event.getFile();
if("java".equalsIgnoreCase(file.getExtension())) {
//AS TODO: In order to use the Code Snell Detector this needs to be invoked in a Read Only Thread but part of the Dispatcher Thread
ApplicationManager.getApplication().invokeLater(
new Runnable() {
@Override
public void run() {
executeMakeInUIThread(event);
}
}
);
}
}
}
示例7: testMultipleClassesInOneFile
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
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]);
}
示例8: testContentChanged_ignoreEventsFromSelfOnSave
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
public void testContentChanged_ignoreEventsFromSelfOnSave() throws Exception {
final VirtualFile file = new MockVirtualFile("test.txt", "test\rtest") {
@NotNull
@Override
public OutputStream getOutputStream(final Object requestor, final long newModificationStamp, long newTimeStamp) throws IOException {
final VirtualFile self = this;
return new ByteArrayOutputStream() {
@Override
public void close() throws IOException {
super.close();
long oldStamp = getModificationStamp();
setModificationStamp(newModificationStamp);
setText(toString());
myDocumentManager.contentsChanged(new VirtualFileEvent(requestor, self, null, oldStamp, getModificationStamp()));
}
};
}
};
Document document = myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
document.insertString(0, "xxx");
final long stamp = document.getModificationStamp();
myDocumentManager.saveAllDocuments();
assertEquals(stamp, document.getModificationStamp());
}
示例9: beforeContentChange
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
void beforeContentChange(@Nonnull VirtualFileEvent event) {
if (event.isFromSave()) return;
VirtualFile file = event.getFile();
if (!file.isValid() || hasConflict(file)) return;
Document document = FileDocumentManager.getInstance().getCachedDocument(file);
if (document == null || !FileDocumentManager.getInstance().isDocumentUnsaved(document)) return;
long documentStamp = document.getModificationStamp();
long oldFileStamp = event.getOldModificationStamp();
if (documentStamp != oldFileStamp) {
LOG.info("reload " + file.getName() + " from disk?");
LOG.info(" documentStamp:" + documentStamp);
LOG.info(" oldFileStamp:" + oldFileStamp);
if (myConflicts.isEmpty()) {
ApplicationManager.getApplication().invokeLater(this::processConflicts);
}
myConflicts.add(file);
}
}
示例10: fileCreated
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
if (myProject.isDisposed()) return;
final VirtualFile createdFile = event.getFile();
final VirtualFile taskDir = StudyUtils.getTaskDir(createdFile);
final Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null || !EduNames.STUDY.equals(course.getCourseMode())) {
return;
}
if (taskDir != null && taskDir.getName().contains(EduNames.TASK)) {
int taskIndex = EduUtils.getIndex(taskDir.getName(), EduNames.TASK);
final VirtualFile lessonDir = taskDir.getParent();
if (lessonDir != null && lessonDir.getName().contains(EduNames.LESSON)) {
int lessonIndex = EduUtils.getIndex(lessonDir.getName(), EduNames.LESSON);
List<Lesson> lessons = course.getLessons();
if (StudyUtils.indexIsValid(lessonIndex, lessons)) {
final Lesson lesson = lessons.get(lessonIndex);
final List<Task> tasks = lesson.getTaskList();
if (StudyUtils.indexIsValid(taskIndex, tasks)) {
final Task task = tasks.get(taskIndex);
final TaskFile taskFile = new TaskFile();
taskFile.initTaskFile(task, false);
taskFile.setUserCreated(true);
final String name = FileUtil.getRelativePath(taskDir.getPath(), createdFile.getPath(), '/');
taskFile.name = name;
//TODO: put to other steps as well
task.getTaskFiles().put(name, taskFile);
}
}
}
}
}
示例11: fileDeleted
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
VirtualFile removedFile = event.getFile();
String path = removedFile.getPath();
if (path.contains(CCUtils.GENERATED_FILES_FOLDER)) {
return;
}
if (myProject == null) {
return;
}
if (myProject.getBasePath() !=null && !FileUtil.isAncestor(myProject.getBasePath(), removedFile.getPath(), true)) {
return;
}
Course course = StudyTaskManager.getInstance(myProject).getCourse();
if (course == null) {
return;
}
final TaskFile taskFile = StudyUtils.getTaskFile(myProject, removedFile);
if (taskFile != null) {
deleteTaskFile(removedFile, taskFile);
return;
}
if (removedFile.getName().contains(EduNames.TASK)) {
deleteTask(course, removedFile);
}
if (removedFile.getName().contains(EduNames.LESSON)) {
deleteLesson(course, removedFile, myProject);
}
}
示例12: registerFileChangedListener
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
/**
* 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);
}
}
});
}
}
示例13: contentsChanged
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void contentsChanged(@NotNull VirtualFileEvent event) {
if (event.getFile().getParent().isDirectory() && event.getFile().getParent().getNameWithoutExtension().compareTo("languages") == 0) {
if (GravYamlFiles.getLanguageFileType(event.getFile()) != GravYamlFiles.LangFileEditorType.NONE) {
for (VirtualFile each : getFileMap().values()) {
if (each.getName().compareTo(event.getFile().getName()) == 0) {
//TODO make changes to model according to file changes
}
}
}
}
}
示例14: fileDeleted
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void fileDeleted(@NotNull VirtualFileEvent event) {
for (VirtualFile each : getFileMap().values()) {
if (each.getName().compareTo(event.getFile().getName()) == 0) {
getFileMap().remove(each.getNameWithoutExtension());
model.removeLanguage(each.getNameWithoutExtension());
editor.initTabs();
}
}
}
示例15: contentsChanged
import com.intellij.openapi.vfs.VirtualFileEvent; //导入依赖的package包/类
@Override
public void contentsChanged(@NotNull VirtualFileEvent event){
if (event.isFromSave()){ // commit
assertThread();
VirtualFile file = event.getFile();
LOG.assertTrue(file.isValid());
if(myFile.equals(file)){
updateModifiedProperty();
}
}
}