Skip to main content



      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 11:19 Go to next message
Eclipse UserFriend
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.

index.php/fa/11035/0/

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) {
   e.printStackTrace();
}



Following exception occurs!!!

java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processObjectNotification(TransactionChangeRecorder.java:284)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:240)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
at com.sap.idm.ic.rcp.idmmodel.impl.TaskImpl.setMcTaskId(TaskImpl.java:1363)
at com.sap.idm.ic.rcp.graphiti.editor.IdmTaskFlowEditor.doSave(IdmTaskFlowEditor.java:99)
at org.eclipse.ui.internal.SaveableHelper$2.run(SaveableHelper.java:151)
at org.eclipse.ui.internal.SaveableHelper$5.run(SaveableHelper.java:277)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2649)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:285)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:264)
at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelper.java:156)
at org.eclipse.ui.internal.EditorManager.savePart(EditorManager.java:1399)
at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage.java:3416)
at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:3429)
at org.eclipse.ui.internal.handlers.SaveHandler.execute(SaveHandler.java:54)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.sap.idm.ic.rcp.Application.start(Application.java:22)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)


Re: Updating a diagram after saving its business model to database [message #900257 is a reply to message #900208] Mon, 06 August 2012 04:38 Go to previous messageGo to next message
Eclipse UserFriend
Solved by using a RecordingCommand.


BR
Surya
Re: Updating a diagram after saving its business model to database [message #900774 is a reply to message #900208] Wed, 08 August 2012 08:52 Go to previous message
Eclipse UserFriend
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.

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


Current Time: Tue Jul 08 21:26:07 EDT 2025

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

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

Back to the top