Creating diagram for transient EObject [message #1803462] |
Fri, 01 March 2019 06:22 |
Rakesh Nidavani Messages: 25 Registered: March 2018 |
Junior Member |
|
|
Hello ,
I have a use case where i need to create a diagram for the model which is not serialized.
Below is my implementation.
1) Create session using aird file.
URI uri = URI.createPlatformResourceURI(aird.getFullPath().toString(), true);
Session s = SessionManager.INSTANCE.getSession(uri, new NullProgressMonitor());
s.save(new NullProgressMonitor());
s.open(new NullProgressMonitor());
SessionManager.INSTANCE.add(this.session);
SessionUIManager.INSTANCE.getOrCreateUISession(this.session);
2) Add all viewpoints.
3) Get RepresentationDescription associated to that model element type
final Collection<RepresentationDescription> allRepresentationDescriptions = DialectManager.INSTANCE
.getAvailableRepresentationDescriptions(this.session.getSelectedViewpoints(false), this.diagramTarget);
// filter to find specific RepresentationDescription
4) Create representation
DRepresentation rep = DialectManager.INSTANCE.createRepresentation(diagramName + " : " + elementName,
this.diagramTarget, repDescForCurrentDiag, this.session, new NullProgressMonitor());
5) Open editor
IEditorPart openEditor =
DialectUIManager.INSTANCE.openEditor(OpenGraphicalEditorAction.this.session, representation, monitor);//
openEditor.doSave(monitor);
When i try to open the editor i am getting below exception:
Root exception:
java.lang.NullPointerException
at org.eclipse.sirius.diagram.ui.business.internal.dialect.DiagramDialectUIServices.openEditor(DiagramDialectUIServices.java:180)
at org.eclipse.sirius.ui.business.internal.dialect.DialectUIManagerImpl.openEditor(DialectUIManagerImpl.java:95)
The eResource of representation is null .
Null pointer exception is thrown in below line of DiagramDialectUIServices class.
if (URIQuery.CDO_URI_SCHEME.equals(diag.eResource().getURI().scheme())) {
viewpointsActivated = activateNeededViewpoints(session, diag, monitor);
}
Few details:
Representation is getting created properly.
When i want to fetch created representation using below code i am getting empty list.
final Collection<DRepresentation> representations =
DialectManager.INSTANCE.getRepresentations(this.diagramTarget, this.session);
I have also tried attaching session to eObject
this.eObject .add(new SessionTransientAttachment(checkSession));
Even this didn't work.
Please let me know how to resolve this issue and also
Is it possible to create a diagram for transient objects ?
Thank you.
Regards,
Rakesh
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03844 seconds