tags:

views:

50

answers:

3

I have a TreeViewer where some nodes represent folders, so I wanted to show the icon of an open folder when the node is expanded and a closed folder when it is collapsed. Sounds easy, I just need to add a tree listener (the code is in Scala, but Java equivalent should be easy to imagine):

val tree = new TreeViewer(contents)
tree.addTreeListener(folderIconFixingListener)

private def folderIconFixingListener = new ITreeViewerListener {
  def treeCollapsed(event: TreeExpansionEvent) {
    tree.update(event.getElement, null)
  }

  def treeExpanded(event: TreeExpansionEvent) {
    tree.update(event.getElement, null)      
  }
}

Unfortunately, this gives an exception:

Ignored reentrant call while viewer is busy. This is only logged once per viewer instance, but similar calls will still be ignored.
java.lang.RuntimeException
    at org.eclipse.jface.viewers.ColumnViewer.checkBusy(ColumnViewer.java:763)
    at org.eclipse.jface.viewers.ColumnViewer.update(ColumnViewer.java:552)
    at scsadmin.NodesTreeScreen$$anon$1.treeExpanded(NodesTreeScreen.scala:64)
    at org.eclipse.jface.viewers.AbstractTreeViewer$3.run(AbstractTreeViewer.java:1101)
    at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.viewers.AbstractTreeViewer.fireTreeExpanded(AbstractTreeViewer.java:1099)
    at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand(AbstractTreeViewer.java:1444)
    at org.eclipse.jface.viewers.TreeViewer.handleTreeExpand(TreeViewer.java:937)
    at org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded(AbstractTreeViewer.java:1453)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Tree.gtk_test_expand_row(Unknown Source)
    at org.eclipse.swt.widgets.Widget.windowProc(Unknown Source)
    at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
    at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
    at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(Unknown Source)
    at org.eclipse.swt.widgets.Display.eventProc(Unknown Source)
    at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
    at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at scsadmin.BootStrapper$.main(BootStrapper.scala:64)
    at scsadmin.BootStrapper.main(BootStrapper.scala)

How can I fix this?

+1  A: 

You might try to put your code in your listener into a asyncExec, to postpone its execution a bit:

display.asyncExec(new Runnable(){
   public void run(){
      tree.update(.);
   }
});
the.duckman
A: 

The solution I eventually went with was to use a TreeListener on the Tree control itself instead, which worked fine.

Alexey Romanov
A: 

Apparently the very same problem: link text

MadH