Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Manually creating and firing events from inside another listener
Manually creating and firing events from inside another listener [message #999268] Fri, 11 January 2013 17:36 Go to next message
Maya L. is currently offline Maya L.Friend
Messages: 2
Registered: January 2013
Junior Member
Hi all,

I have an object with a TreeViewer wrapped inside it, which has a modified TreeListener that resolves EMF proxies using a ComposedAdapterFactory when a TreeExpansionEvent is handled. I would like the same modified expansion to take place when a selection in the TreeViewer is double-clicked on. I have manually created a TreeExpansionEvent and called the modified TreeListener's treeExpanded() from inside the DoubleClickListener; I also tried to add the event to the the Display and system EventQueues. In both cases, the debugger goes through the TreeListener's code, calls on the ComposedAdapterFactory's getChildren() and resolves the proxies, but unlike when the twistie is opened on the tree, double clicking and firing an event does not eventually lead to any OS calls and so the tree doesn't actually expand.

Does anyone have any idea on what I could do to make the double click trigger the tree expansion? The TreeViewer is in an inner class.

Here is the doubleClickListener; There's also a variation I tried without the runnable and simply calls the TreeListener, mtvl

public void doubleClick(DoubleClickEvent event) {
   Object selectedFirstElement = (EObject) ((TreeSelection) workloadViewer.getSelection()).getFirstElement();
   Display.getCurrent().syncExec(new Runnable() {
      public void run() {
         final TreeExpansionEvent te = new TreeExpansionEvent(treeViewer.getTreeViewer(), treeViewer.getSelection().getFirstElement());

Re: Manually creating and firing events from inside another listener [message #1000193 is a reply to message #999268] Mon, 14 January 2013 08:30 Go to previous message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 480
Registered: December 2010
Location: Germany
Senior Member
Hi Maya

I handle the expansion and collapse on double click like this:

viewer.addOpenListener(new IOpenListener() {
	public void open(OpenEvent event) {
		IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
		if (!selection.isEmpty()) {
			Object element = selection.getFirstElement();
			if (viewer.getExpandedState(element))
				viewer.collapseToLevel(element, AbstractTreeViewer.ALL_LEVELS);
				viewer.expandToLevel(element, 1);

Hope this helps.

Previous Topic:Events not passed up to Shell?
Next Topic:Changing PrinterData's paper size.
Goto Forum:

Current Time: Fri Jun 22 02:14:24 GMT 2018

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

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

Back to the top