Retreiving panel problem

Hello,
I've got one problem:
Access is allowed from event dispatch thread only.
Details: Current thread: Thread[ApplicationImpl pooled thread,6,Idea Thread Group] 10179716
Our dispatch thread:Thread[AWT-EventQueue-1,6,Idea Thread Group] 30506753
SystemEventQueueThread: Thread[AWT-EventQueue-1,6,Idea Thread Group] 30506753

java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:52)
at com.intellij.openapi.application.impl.ApplicationImpl.a(ApplicationImpl.java:296)
at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:9)
at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.getToolWindow(ToolWindowManagerImpl.java:109)

I have such exception, while trying to retreive panel with such method:

new Task.Backgroundable(project, getTitle(), false) {
public boolean shouldStartInBackground() {
return false;
}

public void run(final ProgressIndicator indicator) {
indicator.setIndeterminate(true);
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
ToolWindow vcsWindow = toolWindowManager.getToolWindow(ToolWindowId.VCS);
}
});
To fix that I can write:
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
ToolWindow vcsWindow = toolWindowManager.getToolWindow(ToolWindowId.VCS);

}});

But still is there any way to invoke that not in Event Dispatch thread? Does anybody know something about that? Please, help.

Thanks, AL.

Edited by: ALincoln on Jul 25, 2008 11:03 PM

Edited by: ALincoln on Jul 25, 2008 11:13 PM

1 comment
Comment actions Permalink

Hello ALincoln,

It's not true that all kinds of refresh operations are performed in EDT.
However, refreshing the project view updates the model for the Swing JTree
component displaying the project view, so the Swing architecture requires
to perform this operation in the EDT.

We are evaluating the possibility to make it possible to perform part of
the refresh operation in background in Diana, but in Selena there is no way
to avoid this requirement.

I see that refreshes in IntelliJ are performed in Event Dispatch
thread, that make IntelliJ to wait until they are finished. For.e.g.
if I have:
new Task.Backgroundable(project, getTitle(), false) {
public boolean shouldStartInBackground() {
return false;
}
public void run(final ProgressIndicator indicator) {
indicator.setIndeterminate(true);
ProjectView.getInstance(project).refresh();
}
});
I have a message that this refresh should be done in Event Dispatch
thread and I have to make the following fix:
ApplicationManager.getApplication().invokeLater(new Runnable()
{
public void run() {

ProjectView.getInstance(project).refresh();
}
});
Is there any way to invoke such refresh not in Event Dispatch thread?
Does anybody know something about that? Please, help.

Thanks, AL.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.