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:

@Override
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());
dialog.showAndGet();
}

 

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(DialogWrapper.java:1660)
at org.mule.tooling.esb.framework.MuleFrameworkDetector$MyFrameworkDetected.setupFramework(MyFrameworkDetector.java:124)
at com.intellij.framework.detection.impl.FrameworkDetectionUtil.lambda$setupFrameworks$0(FrameworkDetectionUtil.java:102)
at com.intellij.openapi.application.WriteAction.run(WriteAction.java:91)
at com.intellij.framework.detection.impl.FrameworkDetectionUtil.setupFrameworks(FrameworkDetectionUtil.java:88)
at com.intellij.framework.detection.impl.FrameworkDetectionManager.showSetupFrameworksDialog(FrameworkDetectionManager.java:255)

Is there any way around it? 

 

 

 

0
2 comments
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!

 

0

Please sign in to leave a comment.