Community
Participate
Working Groups
Build Identifier: 20110218-0911 I am trying to create an import function as a Custom Feature (more details in Forum message #659779 and followup). The straightforward code works when placed directly in the Custom Feature's execute(), but shows no feedback during the lengthy operation. When I add a Progress Monitor and move the logic into a org.eclipse.ui.progress.Job, each call to addGraphicalRepresentation now results in a Null Pointer Exception in org.eclipse.graphiti.ui.internal.editor.DomainModelChangeListener.resourceSetChanged(DomainModelChangeListener.java:109) - it seems SWT has no Display.getCurrent() value available, when executing in a separate thread. However, the progress monitor works, the elements show up along the way, and the end result - apart from tons of stacktraces and a popup warning - seems correct. I also tried changing the Job to a UIJob, that made the stacktraces and popup go away, but also the progress monitor, and after 30 seconds of nothing, the display started to chase around like mad, to catch up on all the UI updates that had build up. Very entertaining, but not what I had hoped for :-) [Forum comment (#660282) from Michael Wenz] Short answer to this: this appears to be a bug. Display.getCurrent() returns null when called from the non-UI thread. We should instead use Display.getDefault(). Small related problem: addGraphicalRepresentation is declared protected in AbstractFeature, so I have to create a callback method in my Custom Feature? Any particular reason why this cannot be public? Reproducible: Always Steps to Reproduce: 1. Create Custom Feature and tie to a Context Menu as in the tutorial 2. Do this a lot of times in a loop: 3. Create a business object 3. Create an AddContext 4. Call addGraphicalRepresentation on those
Created attachment 191488 [details] full stacktrace
I have changed the async exec call to use Display.getDefault() instead of Display.getCurrent; now this should work in all threads. To the related problem: instead of calling addGraphicalRepresentation from AbstractFeature, you should call addIfPossible in your feature provider; this method is public and addGraphicalRepresentation simply delegates to it. Michael
Part of Graphiti Indigo 0.8.0