Changing JTree in Task.Backgroudable

Hi,

I would like to change JTree tree model in Task.Backgroundable. The problem is when I execute the task the exeption like this is thrown:
"WARN - tellij.ide.HackyRepaintManager - Access to realized (ever shown) UI components should be done only from the AWT event dispatch thread, revalidate(), invalidate() & repaint() is ok from any thread
java.lang.Exception" (full dump in attached file)

This is how I execute task:

     Project project = anActionEvent.getData(PlatformDataKeys.PROJECT);
     ProgressManager.getInstance().run(new RunActionTask(project));



Task class look like this:

    class RunActionTask extends Task.Backgroundable {


        public RunActionTask(@org.jetbrains.annotations.Nullable Project project) {
            super(project, "Running PHP CodeSniffer");
        }


        public void run(@NotNull ProgressIndicator progressIndicator) {
            try {
                VirtualFile[] virtualFiles = getVirtualFiles();
                String command = phpCodeSniffer.getPreparedCommand(virtualFiles);


                if (!command.isEmpty()) {
                    String xmlString = getCommandExecutionOutput(command);


                    DefaultMutableTreeNode root = getTreeFromXml(xmlString);


                    PhpCodeSnifferToolWindow toolWindow = phpCodeSniffer.getToolWindow();


                    ResultsTree resultsTree = toolWindow.getResultsTree();
                    resultsTree.setRoot(root);
                    resultsTree.expandAll();


                    toolWindow.showToolWindow();
                }
            } catch (IOException e1) {
                Messages.showMessageDialog("Error while running PHP CodeSniffer", "PHP CodeSniffer", Messages.getErrorIcon());
            } catch (Exception e1) {
                Messages.showMessageDialog("Something is wrong...", "PHP CodeSniffer", Messages.getErrorIcon());
            }
        }
    }


In this code ResultsTree extends JTree class.


Attachment(s):
task.backgroundable.dump.zip
3 comments
Comment actions Permalink

Hello Wojtek,

All operations with Swing components must be performed in the event dispatch
thread. This is a limitation of Swing itself.

I would like to change JTree tree model in Task.Backgroundable. The
problem is when I execute the task the exeption like this is thrown:

"WARN - tellij.ide.HackyRepaintManager - Access to realized (ever
shown) UI components should be done only from the AWT event dispatch
thread, revalidate(), invalidate() & repaint() is ok from any thread

java.lang.Exception" (full dump in attached file)

This is how I execute task:
Project project =
anActionEvent.getData(PlatformDataKeys.PROJECT);
ProgressManager.getInstance().run(new RunActionTask(project));
Task class look like this:

class RunActionTask extends Task.Backgroundable {

public RunActionTask(@org.jetbrains.annotations.Nullable
Project project) {
super(project, "Running PHP CodeSniffer");
}
public void run(@NotNull ProgressIndicator progressIndicator)
{
try {
��   VirtualFile[] virtualFiles = getVirtualFiles();
��   String command =
phpCodeSniffer.getPreparedCommand(virtualFiles);
��   if (!command.isEmpty()) {
��       String xmlString =
getCommandExecutionOutput(command);
��       DefaultMutableTreeNode root =
getTreeFromXml(xmlString);

��       PhpCodeSnifferToolWindow toolWindow =
phpCodeSniffer.getToolWindow();

��       ResultsTree resultsTree =
toolWindow.getResultsTree();
��       resultsTree.setRoot(root);
��       resultsTree.expandAll();
��       toolWindow.showToolWindow();
��   }
} catch (IOException e1) {
��   Messages.showMessageDialog("Error while running PHP
CodeSniffer", "PHP CodeSniffer", Messages.getErrorIcon());
} catch (Exception e1) {
��   Messages.showMessageDialog("Something is wrong...",
"PHP CodeSniffer", Messages.getErrorIcon());
}
}
}
In this code ResultsTree extends JTree class.

---
Original message URL:
http://devnet.jetbrains.net/message/5303368#5303368


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


0
Comment actions Permalink

Dmitry, ok, but how should we do this?


0
Comment actions Permalink

Application.invokeLater()

0

Please sign in to leave a comment.