本文整理匯總了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);
}
示例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);
}
}
}
}