refresh project view

This commit is contained in:
林万程
2023-11-27 18:49:34 +08:00
parent fdb4c7d6b5
commit b3c84d9590
5 changed files with 11 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
package io.github.linwancen.plugin.show.ext.conf;
import com.intellij.ide.projectView.ProjectView;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
@@ -127,12 +128,18 @@ public class ConfCache {
if (files.isEmpty()) {
return;
}
ProjectView.getInstance(project).refresh();
LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb);
});
}
static void loadFile(@NotNull VirtualFile file) {
ApplicationManager.getApplication().invokeLater(() -> ConfCache.load(file));
static void loadFile(@NotNull VirtualFile file, @Nullable Project project) {
ApplicationManager.getApplication().invokeLater(() -> {
ConfCache.load(file);
if (project != null) {
ProjectView.getInstance(project).refresh();
}
});
}
private static void load(@NotNull VirtualFile file) {

View File

@@ -23,7 +23,7 @@ public class ConfFileChangeListener implements FileEditorManagerListener {
}
if (file.exists()) {
try {
ConfCache.loadFile(file);
ConfCache.loadFile(file, event.getManager().getProject());
} catch (Throwable e) {
LOG.info("ConfFileChangeListener catch Throwable but log to record.", e);
}

View File

@@ -68,6 +68,6 @@ public class ConfFileListener implements BulkFileListener {
}
// VFileCreateEvent
// VFileContentChangeEvent
ConfCache.loadFile(file);
ConfCache.loadFile(file, null);
}
}

View File

@@ -31,8 +31,6 @@ public class ReloadExtDocAction extends DumbAwareAction {
return;
}
ConfCache.loadAll(project);
ApplicationManager.getApplication().invokeLater(() ->
ProjectView.getInstance(project).refresh());
} catch (Throwable t) {
LOG.info("ReloadExtDocAction catch Throwable but log to record.", t);
}

View File

@@ -32,8 +32,6 @@ public class ResetExtDocAction extends AnAction {
if (project == null) {
return;
}
ApplicationManager.getApplication().invokeLater(() ->
ProjectView.getInstance(project).refresh());
} catch (Throwable t) {
LOG.info("ConfFileChangeListener catch Throwable but log to record.", t);
}