Activity diagram control flow

Hi,

I’m developing a plugin for Visual-Paradigm UML, which generates activity diagrams.

So far, I am only able to create the activity diagrams activities programmatically (via open api).
When I try to create the control flow between the activities something weird occurs: the control flow is added to the diagram, its properties are correct (such as Source and target), but it is missing in the Diagram navigator, and only its label is visible (the arrow itself is missing). I show the exact problem in the image attached.

I’ve already read several tutorials but I was not able to find any help for my issue. What am I doing wrong?
Also, I left below my code:


//...
//get diagram manager singleton
DiagramManager diagramManager = ApplicationManager.instance().getDiagramManager();
//create activity diagram
IActivityDiagramUIModel diagram = (IActivityDiagramUIModel)diagramManager.createDiagram(DiagramManager.DIAGRAM_TYPE_ACTIVITY_DIAGRAM);
//Create the first activity				
IActivity act = IModelElementFactory.instance().createActivity();
act.setName("My activity 1");
//create the second activity
IActivity act2 = IModelElementFactory.instance().createActivity();
act2.setName("My activity 2");
		
//Add the activities to the diagram
diagramManager.createDiagramElement(diagram, act);
diagramManager.createDiagramElement(diagram, act2);
				
//create the control flow
IControlFlow c = IModelElementFactory.instance().createControlFlow();
c.setName("My connection");
//set from/to
c.setFrom(act);
c.setTo(act2);
//Add control flow to the diagram
diagramManager.createDiagramElement(diagram, c);

Any help would be appreciated.


ad.png

Just found the solution to my problem. The connections (as the control flow) must be created by the diagramManager as a connector, and not as a diagram element.

So, in the line 24:


diagramManager.createDiagramElement(diagram, c);  

the correct code is:


diagramManager.createConnector(diagram, c, act.getMasterView(), act2.getMasterView(), null);

Best regards.