Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Updating a diagram after saving its business model to database
Updating a diagram after saving its business model to database [message #900208] Sun, 05 August 2012 15:19 Go to next message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
Registered: July 2012
In my case, each business object (Task) associated with a node in a diagram have unique "ID" and "Name".

When a diagram is created "Name" of a node is given by the user. For example nodes A - E in the diagram shown below.


When the diagram is saved (using save toolbar button), business objects (Tasks) will be saved into a database. "ID" of all the saved nodes will be generated at database and will be returned by the "save" operation.

My question is now, How to update the "ID" of the curresponding business objects in the diagram?.

Any pointers will be highly appreciated.

I use the following code in "doSave" method of editor and got the following exceptions.

public void doSave(IProgressMonitor monitor) {
try {
   for (int i = 0; i < diag.getLink().getBusinessObjects().size(); i++) {
	EObject eobj =  diag.getLink().getBusinessObjects().get(i);
	if(eobj instanceof Task){
	   Task task = (Task) eobj;
	   if(task.getMcTaskId() == null){
	     task.setMcTaskId(/*ID received from database*/);
} catch (RuntimeException e) {

Following exception occurs!!!

java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(
at org.eclipse.ui.internal.SaveableHelper$
at org.eclipse.ui.internal.SaveableHelper$
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(
at org.eclipse.jface.window.ApplicationWindow$
at org.eclipse.swt.custom.BusyIndicator.showWhile(
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(
at org.eclipse.ui.internal.SaveableHelper.savePart(
at org.eclipse.ui.internal.EditorManager.savePart(
at org.eclipse.ui.internal.WorkbenchPage.savePart(
at org.eclipse.ui.internal.WorkbenchPage.saveEditor(
at org.eclipse.ui.internal.handlers.SaveHandler.execute(
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(
at org.eclipse.core.commands.Command.executeWithChecks(
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(
at org.eclipse.ui.menus.CommandContributionItem.access$19(
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(
at org.eclipse.swt.widgets.EventTable.sendEvent(
at org.eclipse.swt.widgets.Widget.sendEvent(
at org.eclipse.swt.widgets.Display.runDeferredEvents(
at org.eclipse.swt.widgets.Display.readAndDispatch(
at org.eclipse.ui.internal.Workbench.runEventLoop(
at org.eclipse.ui.internal.Workbench.runUI(
at org.eclipse.ui.internal.Workbench.access$4(
at org.eclipse.ui.internal.Workbench$
at org.eclipse.core.databinding.observable.Realm.runWithDefault(
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(
at org.eclipse.equinox.launcher.Main.basicRun(
at org.eclipse.equinox.launcher.Main.main(

Re: Updating a diagram after saving its business model to database [message #900257 is a reply to message #900208] Mon, 06 August 2012 08:38 Go to previous messageGo to next message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
Registered: July 2012
Solved by using a RecordingCommand.

Re: Updating a diagram after saving its business model to database [message #900774 is a reply to message #900208] Wed, 08 August 2012 12:52 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1898
Registered: July 2009
Location: Walldorf, Germany
Senior Member
You will need to wrap any model modification code into a command running on
the command stack of the editor's TransactionalEditingDomain, because
Graphiti uses EMF Transactions under the hoods.

Previous Topic:Diagram editor for Non-emf model
Next Topic:[Solved] MultiPageEditor with multiple Diagrams from same Resource
Goto Forum:

Current Time: Wed Sep 26 02:26:34 GMT 2018

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

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

Back to the top