1

I need to generate a Diagram for Papyrus (Eclipse neon) by Code, but on the networx I cant't find any explaination about creating diagrams by code except for BDD.

My actual situation is the following:

I receive a .csv file containing some information written like "Element A , Connection Type , Element B"

What I need to do is to generate a diagram representing them as following:

Diagram Example :

enter image description here

NOTE: I'm not interested in representing colours in the final product

So My questions are:

  1. Which diagram from Papyrus should I use to achieve this? (I must use Papyrus)

  2. Can someone provide me some documentation to generate it by code?

I found this post on Eclipse community: https://www.eclipse.org/forums/index.php/m/1708054/?srch=activity+diagram+programmatically#msg_1708054

But It seems there's no class "CreateActivityDiagramCommand" containing the command to generate the diagram.

Please don't try to understand the sense of representing information like that, just help me creating a diagram to do that.

1 Answers1

1

SOLVED:

I found a way to draw an Activity Diagram programmatically, since I need only rectangles containig a simple string and arrows it wasn't difficult to draw.

Navigating into Papyrus Source code I found a package org.eclipse.papyrus.uml.diagram.activity containing the CreateActivityDiagramCommand Class so I added that to dependancies and I started building my method to generate a Diagram

If anyone is interested I did as Following:

public static Diagram createActivityDiagram(EObject owner, String name) //owner is an UML Package
    {
        ModelSet modelSet = null;
        ResourceSet resourceSet = owner.eResource().getResourceSet();

        if (resourceSet instanceof ModelSet) 
            modelSet = (ModelSet) resourceSet;
        else 
            return null;

        Diagram diagram;
        CreateActivityDiagramCommand creatediagramCommand = new CreateActivityDiagramCommand();
        diagram = creatediagramCommand.createDiagram(modelSet, owner, name);
        return diagram;
    }