Activity diagram simlane/partitions


I’m finding it hard to work with the open api. (Some more examples and tutorials on the visual paradigm site would be very helpful…)

At the moment, I’m creating an activity diagram programatically. I’ve already added activity nodes and control flow connections between them.

Now, I’m trying to create swimlanes/partitions for the activities. Intuitively, I created the swimlane, and with the “addVerticalPartition” method (since “addchild” is deprecated), tried to add a new partition to it.
The result is not what I expected. The swimlane is created without partitions, and the partition is not added to the swimlane.
Furthermore, I expected the method “addContainedElement” to add an activity to the partition, but that’s not the case.

Here is the code I have:

//create the swimlane
IActivitySwimlane2 sl = IModelElementFactory.instance().createActivitySwimlane2();
sl.setName("My Swimlane");
//create the partition
IActivityPartition p = (IActivityPartition) sl.createChild(IModelElementFactory.MODEL_TYPE_ACTIVITY_PARTITION);
//add an element
//add the vertical partition to the swimlane
//create the diagram elements

The results are not what I expected…Can anyone help me?

Best regards