FileChooser and Slow Operation in EDT

Hi, I have a JButton that triggers a file selection by invoking a com.intellij.openapi.fileChooser.FileChooser.
Basically, it looks like

myButton.addActionListener(al -> {
    FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(...);
    VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, null, null); // <- error here
    ...
});

This triggers a Slow operations are prohibited on EDT exception.

If I move FileChooser.chooseFile outside from the EDT, it says I need to run in EDT…

A workaround is to replace com.intellij.openapi.fileChooser.FileChooser by a good old javax.swing.JFileChooser, but its UI is ugly.

Do you know how to integrate a FileChooser? Thanks.

1 Like

@jonathanlermitage.1 have you succeeded on that one?

Unfortunately, no :disappointed_face:.
BTW, users may see these warnings when the Internal mode is activated. If so, they can hide them by setting ide.slow.operations.assertion=false in IDE’s properties.

Sorry folks, there is no solution unfortunately yet. But this diagnostic is not shown to users in releases, please do not worry, only during development and internal mode.

It looks so the slow operations may be bypassed if the not null initial value for FileChoser is provided. For me the following approach works

VirtualFile initLocation = defaultLocation; // should not be null
VirtualFile virtualFile = FileChooser.chooseFile(fileChooserDescriptor, null, defaultLocation);