|
|
Re: Attach EObject to Sirius Session [message #1700902 is a reply to message #1700854] |
Wed, 08 July 2015 05:13 |
Axel Niklasson Messages: 11 Registered: June 2015 |
Junior Member |
|
|
Francois Cabrol wrote on Tue, 07 July 2015 15:41 From my understanding, you have to:
- either get the EObject from the semantic model (ie the set of EObjects) referenced by your .aird file
- or if the EObject has been initialized manually and is not already referenced in your .aird file, attach the resource containing your EObject (ie the file where your EObject is serialized) to the session
- or if the EObject is not intended to be serialized at all, use Sirius's transient attachment mechanism
Get the EObject from a resource referenced by an .aird file
Collection<Resource> resources = session.getSemanticResources();
/* Iterate through resources */
for (Resource resource : resources) {
/* Iterate through EObjects */
for (EObject eObject : resource.getContents()) {
...
}
}
Attach the resource containing an EObject to a session
session.getTransactionalEditingDomain().getCommandStack().execute(
new RecordingCommand(session.getTransactionalEditingDomain()) {
@Override
protected void doExecute() {
/* The eObject must be contained in an XMI resource */
/* See § "Data Management" here => http://eclipsesource.com/blogs/tutorials/emf-tutorial/ */
session.addSemanticResource(eObject.eResource().getURI(), monitor);
}
}
Attach a transient EObject to a session
eObject.eAdapters().add(new SessionTransientAttachment(session));
Hope it helps,
François
The third alternative was exactly what I was looking for. Now the session can be loaded in the diagram creation and I can finally continue working.
Thank you, good sir!
[Updated on: Wed, 08 July 2015 06:54] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03141 seconds