Need guidance in polling within Intellij plugin

Answered

Hi,

We are working on a plugin in which we are constantly calling our web API and based on the response of the API we are forming a tree view in the tool window, we are making the api call on pooledThread and then forming the UI. Whenever the UI gets recreated [Polling] there as slight freeze of 1 sec in the IDE. We are not able to solve this issue, could you please tell us the right approach of doing this or let us know if there is any mechanism in Intellij which we can reuse. 

Note: we are forming the UI using .invokeLater Method because it gives the below error otherwise

polling = executorService.scheduleWithFixedDelay(() -> {
if (!activeApiCall) {
Runnable runnable = this::runCallApi;
application.executeOnPooledThread(runnable);
}
}, 0, POLLING_INTERVAL_SECONDS, TimeUnit.SECONDS);


ApplicationManager.getApplication().invokeLater(Window.formUI(apiResponse));

 

Thanks

Vikram

0
3 comments

> Whenever the UI gets recreated [Polling] there as slight freeze of 1 sec in the IDE. 

How do you "recreate" the UI? Did you try and measure what happens here?

0

We are just forming the tree view/re rendering  in the tool window via repaint mechanism.. Is there a better way to do this. Can invokeLater or repaint be the one that's causing the issue? 

0

What does this method do exactly:


Window
.formUI(apiResponse)

? How do you update the tree exactly? updating its model should be enough usually. did you take CPU snapshot to find reason of freeze?

0

Please sign in to leave a comment.