Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Polarsys » Capella Studio » Programatically create LogicalComponent usable in Diagram(Cannot find documentation on this)
Programatically create LogicalComponent usable in Diagram [message #1828983] Tue, 23 June 2020 15:35 Go to next message
Rémi GAUTHIER is currently offline Rémi GAUTHIERFriend
Messages: 5
Registered: April 2020
Junior Member
Hello, I am trying from a csv to generate multiple LogicalComponent as tree (parent/children).

Right now it is working I do have my tree of LogicalComponent.

I am using this code (inside a transaction) :

// create lc
LogicalComponent lc = ComponentExt.createLogicalComponent();
lc.setName(object.getId());
if (object.getDescription() != null)
    lc.eSet(lc.eClass().getEStructuralFeature("description"), object.getDescription());

// add to parent
lcParent.getOwnedLogicalComponents().add(lc);


But the created component is not usable in a diagram, let's say a [LAB] diagram for instance.

I tried to add the lc to the subComponents of the parent but it is not authorised (changeable: false).

What is the strategy to create the GraphicalComponent associated to this LogicalComponent to mimic what I have when I create a LogicalComponent manually in Capella Studio?

Thanks in advance for your answer,
Rémi
Re: Programatically create LogicalComponent usable in Diagram [message #1829057 is a reply to message #1828983] Wed, 24 June 2020 12:20 Go to previous message
Rémi GAUTHIER is currently offline Rémi GAUTHIERFriend
Messages: 5
Registered: April 2020
Junior Member
For those wondering the same question.
I did a bit of searching watching what was created and how it was linked for a LogicalComponent created by clicking direclty in Capella.
I realized I also need to create a Part object.

// get parent
LogicalComponent parent = getParent();

// create logical component
LogicalComponent lc = ComponentExt.createLogicalComponent();
lc.setName(object.getId());
if (object.getDescription() != null)
	lc.eSet(lc.eClass().getEStructuralFeature("description"), object.getDescription());

// create part
Part part = CsFactoryImpl.eINSTANCE.createPart(object.getId());
part.setAbstractType(lc);

// associate lc to parent
parent.getOwnedLogicalComponents().add(lc);
// associate part to parent
parent.getOwnedFeatures().add(part);


An it is working now I can add my LogicalComponent to Diagram!
Previous Topic:Activity explorer page content doesn't show up
Next Topic:Documentation to create viewpoints
Goto Forum:
  


Current Time: Thu Mar 28 20:27:16 GMT 2024

Powered by FUDForum. Page generated in 0.03722 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top