This service is archived, please use www.eclipse.org/forums


Home » Capella » Capella Studio » Create diagram programmatically (How to create diagram programmatically)
Create diagram programmatically [message #3562] Tue, 01 October 2019 08:09 Go to next message
jpclavery.gmail.com is currently offline  jpclavery.gmail.com
Messages: 37
Registered: April 2019
Member
Hi,

I try to create a "Physical Architecture Blank" diagram programmatically but I don't find topic to help me.

Who can help me ?

Thanks
Re: Create diagram programmatically [message #3574 is a reply to message #3562] Thu, 10 October 2019 04:01 Go to previous message
jpclavery.gmail.com is currently offline  jpclavery.gmail.com
Messages: 37
Registered: April 2019
Member
Hi,

I finally find how to do and want to share it we all :



public void createDiagram(String pathName, String representationName, EObject sementic, String representationDescriptionName) {

URI representationsFileURI = URI.createPlatformResourceURI(pathName, true);

Session session = SessionManager.INSTANCE.getSession(
representationsFileURI, new NullProgressMonitor());

Collection<DRepresentation> representations= getRepresentations(session, representationDescriptionName);

Map<String, DRepresentation> map = new HashMap<>();

Iterator<DRepresentation> it =representations.iterator();
DRepresentation representation = null;

while(it.hasNext()) {
representation = it.next();
map.put("0", representation);
}


createDRepresentation(representationName, sementic, getDescription(representation), session, new NullProgressMonitor());


}

public Collection<DRepresentation> getRepresentations(final Session session, final String representationDescriptionName) {
final Collection<DRepresentation> allRepresentations = DialectManager.INSTANCE.getAllRepresentations(session);

final Collection<DRepresentation> representations = new HashSet<DRepresentation>();

for (final DRepresentation representation : allRepresentations) {
final RepresentationDescription desc = DialectManager.INSTANCE.getDescription(representation);
if (desc != null && representationDescriptionName.equals(desc.getName())) {
representations.add(representation);
}
}
return representations;
}

public DRepresentation createDRepresentation(String name, EObject semantic, RepresentationDescription description,
Session session, IProgressMonitor monitor) {
return DialectManager.INSTANCE.createRepresentation(name, semantic, description, session, monitor);
}
Previous Topic: Import Component from excel
Next Topic: XText grammar generation issue in Capella Studio
Goto Forum:
  


Current Time: Sat Mar 28 04:00:11 EST 2020

Total time taken to generate the page: 0.00952 seconds