Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Update semantic resource programmatically(Update model using a Recording Command)
icon1.gif  Update semantic resource programmatically [message #1715250] Fri, 20 November 2015 14:29 Go to next message
Giannis Kafousis is currently offline Giannis KafousisFriend
Messages: 3
Registered: November 2015
Junior Member
Hello community!

I have made an emf model and sirius diagram which I try to update programatically using a Recording Command. From what i have read this is the proper way of doing so. The rootObject of my model is an Analysis which has a name, an analyzer and some analysis params which are classes of my own defined in the emf model.

I have an xml file and when i save it an emf model instance is created programmatically. So I get the root element of my newly created model instance (updatedRootObject) and then I use a Recording Command to update the diagram like this:

String airdFilePath = "/my/aird/path";
URI airdFileURI = URI.createPlatformResourceURI(airdFilePath, true);
Session session = SessionManager.INSTANCE.getSession( airdFileURI, monitor);
session.open();

//get session root object
Analysis rootObj =  (Analysis) session.getSemanticResources().
				iterator().next().getContents().get(0);

//update root object
TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
CommandStack commandStack = editingDomain.getCommandStack();
		
RecordingCommand updateCommand = new RecordingCommand(editingDomain) {
			
     @Override
     protected void doExecute() {
             rootObj.setName(updatedRootObject.getName());
             rootObj.setAnalyzer(updatedRootObject.getAnalyzer());
           
             rootObj.getAnalysisParams.clear();
             rootObj.getAnalysisParams.AddAll(updatedRootObject.getAnalysisParams);
     }
};
commandStack.execute(updateCommand);


The semantic model gets updated BUT if my diagram is opened, my nodes overlap each other and I get the following exception.

java.lang.NullPointerException
	at org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand$1.run(DeferredLayoutCommand.java:153)
	at org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil.synchronizeRunnableToMainThread(EditPartUtil.java:111)
	at org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand.doExecuteWithResult(DeferredLayoutCommand.java:186)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy.execute(ICommandProxy.java:68)
	at org.eclipse.gef.commands.CompoundCommand.execute(CompoundCommand.java:111)
	at org.eclipse.sirius.diagram.ui.internal.refresh.layout.SiriusCanonicalLayoutCommand.executeLayoutDueToExternalChanges(SiriusCanonicalLayoutCommand.java:107)
	at org.eclipse.sirius.diagram.ui.internal.refresh.layout.SiriusCanonicalLayoutCommand.access$3(SiriusCanonicalLayoutCommand.java:104)
	at org.eclipse.sirius.diagram.ui.internal.refresh.layout.SiriusCanonicalLayoutCommand$1.run(SiriusCanonicalLayoutCommand.java:90)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	... 24 more


Thank you in advance.

[Updated on: Mon, 23 November 2015 15:44]

Report message to a moderator

Re: Update semantic resource programmatically [message #1715442 is a reply to message #1715250] Mon, 23 November 2015 15:37 Go to previous message
Giannis Kafousis is currently offline Giannis KafousisFriend
Messages: 3
Registered: November 2015
Junior Member
This seems to be a bug connected to Sirius version 1. I updated to Sirius version 3 and the problem was finally solved!

[Updated on: Mon, 23 November 2015 15:39]

Report message to a moderator

Previous Topic:relation Edge in a container ?!
Next Topic:Container/Compartment in Containers without Domain class
Goto Forum:
  


Current Time: Fri Sep 20 19:20:21 GMT 2024

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

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

Back to the top