diff --git a/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java b/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java index e757f61..de260b1 100644 --- a/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java +++ b/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java @@ -2,6 +2,8 @@ package io.github.linwancen.plugin.show.ext.conf; import com.intellij.ide.projectView.ProjectView; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; @@ -118,21 +120,29 @@ public class ConfCache { } public static void loadAll(@NotNull Project project) { - DumbService.getInstance(project).smartInvokeLater(() -> { - @NotNull Collection files = FilenameIndex.getAllFilesByExt(project, TsvLoader.EXT); - @NotNull StringBuilder sb = new StringBuilder(); - for (@NotNull VirtualFile file : files) { - load(file); - sb.append(file.getName()).append("\n"); + new Task.Backgroundable(project, "Show Load xxx.tree/key/doc/json.tsv") { + @Override + public void run(@NotNull ProgressIndicator indicator) { + ApplicationManager.getApplication().runReadAction(() -> { + @NotNull Collection files = FilenameIndex.getAllFilesByExt(project, TsvLoader.EXT); + @NotNull StringBuilder sb = new StringBuilder(); + int i = 0; + for (@NotNull VirtualFile file : files) { + indicator.setText(file.getName()); + load(file); + indicator.setFraction((double) ++i /files.size()); + sb.append(file.getName()).append("\n"); + } + if (files.isEmpty()) { + return; + } + if (!project.isDisposed()) { + ProjectView.getInstance(project).refresh(); + } + LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb); + }); } - if (files.isEmpty()) { - return; - } - if (!project.isDisposed()) { - ProjectView.getInstance(project).refresh(); - } - LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb); - }); + }.queue(); } public static void loadFile(@NotNull VirtualFile file, @Nullable Project project) {