当前位置: 首页>>代码示例>>Java>>正文


Java VirtualFile.refresh方法代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.refresh方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.refresh方法的具体用法?Java VirtualFile.refresh怎么用?Java VirtualFile.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vfs.VirtualFile的用法示例。


在下文中一共展示了VirtualFile.refresh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateFromStudentCourse

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void generateFromStudentCourse(Project project, Course course) {
  StudyTaskManager.getInstance(project).setCourse(course);
  course.setCourseMode(CCUtils.COURSE_MODE);
  final VirtualFile baseDir = project.getBaseDir();
  final Application application = ApplicationManager.getApplication();

  application.invokeAndWait(() -> application.runWriteAction(() -> {
    final VirtualFile[] children = baseDir.getChildren();
    for (VirtualFile child : children) {
      StudyUtils.deleteFile(child);
    }
    StudyGenerator.createCourse(course, baseDir);
  }));
  baseDir.refresh(false, true);

  int index = 1;
  int taskIndex = 1;
  for (Lesson lesson : course.getLessons()) {
    final VirtualFile lessonDir = project.getBaseDir().findChild(EduNames.LESSON + String.valueOf(index));
    lesson.setIndex(index);
    if (lessonDir == null) continue;
    for (Task task : lesson.getTaskList()) {
      final VirtualFile taskDir = lessonDir.findChild(EduNames.TASK + String.valueOf(taskIndex));
      task.setIndex(taskIndex);
      task.setLesson(lesson);
      if (taskDir == null) continue;
      for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
        application.invokeAndWait(() -> application.runWriteAction(() -> createAnswerFile(project, taskDir, entry)));
      }
      taskIndex += 1;
    }
    index += 1;
    taskIndex = 1;
  }
  course.initCourse(true);
  application.invokeAndWait(() -> StudyUtils.registerStudyToolWindow(course, project));
  synchronize(project);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:39,代码来源:CCFromCourseArchive.java

示例2: openFirstTask

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static void openFirstTask(@NotNull final Course course, @NotNull final Project project) {
  LocalFileSystem.getInstance().refresh(false);
  final Lesson firstLesson = getFirst(course.getLessons());
  if (firstLesson == null) return;
  final Task firstTask = getFirst(firstLesson.getTaskList());
  if (firstTask == null) return;
  final VirtualFile taskDir = firstTask.getTaskDir(project);
  if (taskDir == null) return;
  final Map<String, TaskFile> taskFiles = firstTask.getTaskFiles();
  VirtualFile activeVirtualFile = null;
  for (Map.Entry<String, TaskFile> entry : taskFiles.entrySet()) {
    final String relativePath = entry.getKey();
    final TaskFile taskFile = entry.getValue();
    taskDir.refresh(false, true);
    final VirtualFile virtualFile = taskDir.findFileByRelativePath(relativePath);
    if (virtualFile != null) {
      if (!taskFile.getActivePlaceholders().isEmpty()) {
        activeVirtualFile = virtualFile;
      }
    }
  }
  if (activeVirtualFile != null) {
    final PsiFile file = PsiManager.getInstance(project).findFile(activeVirtualFile);
    ProjectView.getInstance(project).select(file, activeVirtualFile, false);
    final FileEditor[] editors = FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
    if (editors.length == 0) {
      return;
    }
    final FileEditor studyEditor = editors[0];
    if (studyEditor instanceof StudyEditor) {
      selectFirstAnswerPlaceholder((StudyEditor)studyEditor, project);
    }
    FileEditorManager.getInstance(project).openFile(activeVirtualFile, true);
  }
  else {
    String first = getFirst(taskFiles.keySet());
    if (first != null) {
      NewVirtualFile firstFile = ((VirtualDirectoryImpl)taskDir).refreshAndFindChild(first);
      if (firstFile != null) {
        FileEditorManager.getInstance(project).openFile(firstFile, true);
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:45,代码来源:StudyUtils.java


注:本文中的com.intellij.openapi.vfs.VirtualFile.refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。