Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Changing labels in TreeViewer on node expansion/collapse
icon5.gif  Changing labels in TreeViewer on node expansion/collapse [message #543682] Wed, 30 June 2010 09:45
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
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 me 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?

Asked on StackOverflow as well.

[Updated on: Wed, 30 June 2010 09:52]

Report message to a moderator

Previous Topic:multiple selection widget ("FilteredCheckBoxTreeViewer")
Next Topic:Getting TreeViewer object from a CTabItem
Goto Forum:
  


Current Time: Wed Oct 01 08:20:16 GMT 2014

Powered by FUDForum. Page generated in 0.07232 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software