I have an EMF Datamodel and represent it with the framework "Graphiti". In case of changes in the datamodel the method "updateNeeded()" in my UpdateFeature is randomly called or not. Therefor I have a listener. This listener calls the method "update()" in case of changes. In the method update I can define the differences between datamodel and diagram. But if I want to add or change anything to the diagram an exception is thrown.
Has anyone an idea how I could autoupdate the diagram?
Here is my examplecode in the listener:
UpdateContext updateContext = new UpdateContext(getDiagram().getChildren().get(0).getGraphicsAlgorithm().getPictogramElement());
IUpdateFeature updateFeature = getFeatureProvider().getUpdateFeature(updateContext);
updateFeature.update(updateContext);
and the exception:
!ENTRY org.eclipse.ui 4 0 2013-07-11 13:36:43.886 !MESSAGE Unhandled event loop exception !STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalStateException: Cannot modify resource set without a write transaction)
Caused by: java.lang.IllegalStateException: Cannot modify resource set without a write transaction at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting
Regards, Juliane