Refreshing the project pane

I am calling out to an external process which creates some files.  How can I have the project pane refresh to display the newly created files?

2 comments
Comment actions Permalink

You need to call VirtualFileManager.refresh() to refresh the virtual file system. This will cause the project view and all other parts of the IntelliJ IDEA model to refresh as well.

0
Comment actions Permalink

Works perfectly.  Here's how I'm using it.

VirtualFileManager.getInstance().asyncRefresh(new Runnable() {
    @Override
    public void run
() {
        String newFilePath = "path/to/file";
        
VirtualFile newFile = LocalFileSystem.getInstance().findFileByPath(newFilePath);
        if
(newFile == null) {
            throw RuntimeException("Could not find newly created file!");
        
} else {
            // Open the file in the editor.
            new
OpenFileDescriptor(project, newFile).navigate(true);
        
}
    }
});
0

Please sign in to leave a comment.