Check if app is loaded
Answered
Hi,
I'm creating a ToolWindow which requires parsing PsiFile and looking into idicies.
This I solved by moving that logic into ReadAction:
ReadAction.nonBlocking<JComponent> { ...parsePsi }
.finishOnUiThread(ModalityState.defaultModalityState()) {
val content = ContentFactory.getInstance().createContent(it, null, false)
contentManager.addContent(content)
}
.submit(AppExecutorUtil.getAppExecutorService())
Which works fine, problem is that at start-up I get an Exception
SEVERE - #c.i.d.LoadingState - Should be called at least in the state COMPONENTS_LOADED, the current state is: CONFIGURATION_STORE_INITIALIZED
But I don't know how to check if app is already loaded and I can run this code… LoadingState by itself is marked as ApiInternal so I cannot use that.
I tried something like
if (!ApplicationManager.getApplication().isActive) return@withContext
but that doesn't work is app is likely active before IDEA is fully loaded?
Please sign in to leave a comment.
Where exactly do you execute this code? Please don't do it in CTOR.
Not sure what CTOR is, it's initially called from ToolWindowFactory
TscnScenePreviewWindow
Handle rendering of ToolWindow content depending on currently selected file.Getting current virtual file I've copy-paste more or less from StructureViewWindow (but some parts are marked as InternalApi so can't do it 1:1), but initial call is inside contructor:
where
rebuildImpl
is the one calling code in initial post