FileAnnotation.reload problem.

Answered

I developed a plugin of cloud comment.

Previously I use JavaFX webview and JavaInterop to communicate with the plugin.

But the JavaFX webview has cross domain bug.

So I change it to BrowserUtil.browse and local http server to communicate with the plugin.

 

Then, the problem comes.

I previously update the comment count by fileAnnotation.reload(fileAnnotation) when the webview dialog is disposed.

It's working. The dialog is modal. I update the comment count when I close the dialog.

When I use the local http server, it's working for some cases and not working for some cases.To use with local http server. I have to use the line below. Or it will fail on read action assert.

ApplicationManager.getApplication().runReadAction(()->annotation.reload(annotation));

Here's a screen recording of the cases working and the cases not working. 

https://www31.zippyshare.com/v/dFuzO2Nk/file.html

Can you please help? How can I call the fileAnnotation.reload(fileAnnotation) to be working 100%?

0
2 comments

I finally get it working by using the method below.

ApplicationManager.getApplication().invokeLater

But I don't know why. Application.runReadAction, Application.runWriteAction, ProgressManager.run are all not working.

Could you please tell me why? Thank you.

0

Application.runReadAction provides read access to the data in the current thread:

Runs the specified read action. Can be called from any thread. The action is executed immediately
if no write action is currently running, or blocked until the currently running write action completes.

Application.invokeLater makes your Runnable to be run in AWS thread also with write access:

Causes {@code runnable.run()} to be executed asynchronously on the
AWT event dispatching thread under Write Intent lock, with {@link ModalityState#defaultModalityState()} modality state.
This will happen after all pending AWT events have been processed.

I assume that in your case, the significant part was to run your code in the Event Dispatching Thread.

0

Please sign in to leave a comment.