AWT events are not allowed inside write action error when setting up a framework

I have a custom framework detector, and when the framework is detected, I need to display a dialog so that user can select the framework version. The code looks like this:

public void setupFramework(@NotNull ModifiableModelsProvider modifiableModelsProvider, @NotNull ModulesProvider modulesProvider)
final Module moduleForFile = ProjectRootManager.getInstance(context.getProject()).getFileIndex().getModuleForFile(collection.iterator().next());
final AddSupportForSingleFrameworkDialog dialog = AddSupportForSingleFrameworkDialog.createDialog(moduleForFile, new MyFrameworkSupportProvider());


I'm getting this "AWT Events are not allowed" error, and looking at the stack trace I understand that it is originated in the com.intellij.framework.detection.impl.FrameworkDetectionUtil class:

at com.intellij.openapi.ui.DialogWrapper.showAndGet(
at org.mule.tooling.esb.framework.MuleFrameworkDetector$MyFrameworkDetected.setupFramework(
at com.intellij.framework.detection.impl.FrameworkDetectionUtil.lambda$setupFrameworks$0(
at com.intellij.framework.detection.impl.FrameworkDetectionUtil.setupFrameworks(
at com.intellij.framework.detection.impl.FrameworkDetectionManager.showSetupFrameworksDialog(

Is there any way around it? 




Official comment

It seems that the only way out if to show your dialog in application.invokeLater() call

Yes, looks like it fixed the problem, thank you!



Please sign in to leave a comment.