| Manually creating and firing events from inside another listener [message #1000450] |
Mon, 14 January 2013 14:55  |
Maya L. 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. One thing I thought of, after a suggestion from the SWT forum, is to write my own Tree extension that overrides the expand methods to resolve proxies so that I don't need specialized listeners. Is this a good approach?
Here is the doubleClickListener; There's also a variation I tried without the runnable and simply calls the TreeListener, mtvl
@Override
public void doubleClick(DoubleClickEvent event) {
treeViewer.getDisplay();
Object selectedFirstElement = (EObject) ((TreeSelection) workloadViewer.getSelection()).getFirstElement();
Display.getCurrent().syncExec(new Runnable() {
@Override
public void run() {
final TreeExpansionEvent te = new TreeExpansionEvent(treeViewer.getTreeViewer(), treeViewer.getSelection().getFirstElement());
mtvl.treeExpanded(te);
}});
Thanks!
(Cross-posted from SWT, since this is really a question that involves both SWT and EMF: http://www.eclipse.org/forums/index.php/t/447691/)
|
|
|