eclipse rcp - automatic update of graphiti diagrams in case of changes in the datamodel -


i have emf datamodel , represent framework "graphiti". in case of changes in datamodel method "updateneeded()" in updatefeature randomly called or not. therefor have listener. listener calls method "update()" in case of changes. in method update can define differences between datamodel , diagram. if want add or change diagram exception thrown.

has idea how autoupdate diagram?

here examplecode in listener:

updatecontext updatecontext = new updatecontext(getdiagram().getchildren().get(0).getgraphicsalgorithm().getpictogramelement()); iupdatefeature updatefeature = getfeatureprovider().getupdatefeature(updatecontext); updatefeature.update(updatecontext); 

and 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 execute runnable (java.lang.illegalstateexception: cannot modify resource set without write transaction)

caused by: java.lang.illegalstateexception: cannot modify resource set without write transaction @ org.eclipse.emf.transaction.impl.transactionchangerecorder.assertwriting

regards, juliane

in graphiti need execute changes diagram within emf transaction. can executing code follows:

transactionaleditingdomain domain = transactionutils.geteditingdomain(diagram); domain.getcommandstack().execute(new recordingcommand(domain) {    public void doexecute() {       updatecontext updatecontext = new updatecontext(getdiagram().getchildren().get(0).getgraphicsalgorithm().getpictogramelement());       iupdatefeature updatefeature = getfeatureprovider().getupdatefeature(updatecontext);       updatefeature.update(updatecontext);    } }); 

hope helps


Comments