Home » Polarsys » Capella Studio » Add a created component to the diagram editor programatically
Add a created component to the diagram editor programatically [message #1822728] |
Thu, 12 March 2020 10:04  |
Soulimane KAMNI Messages: 20 Registered: February 2020 |
Junior Member |
|
|
Hi,
I am working on the synthesis of my customized Physical Architecture Blank diagram programmatically by creating a view point using Capella studio.
Until now, I can create components and add them to the physical system and I can see them by expanding the .aird file using the project explorer. (see screen capture)
What I want to do now is to add them to the diagram editor view automatically without dragging and dropping them there.
I think to do so, we use the Diagramservices class as follows:
public class addComponentTodiagram extends AbstractReadWriteCommand{
protected String mappingName;
protected PhysicalComponent component;
protected DDiagram diagram;
public addComponentTodiagram (String mappingName, PhysicalComponent component, DDiagram diagram ){
this.mappingName = mappingName;
this.component = component;
this.diagram = diagram ;
}
@Override
public void run() {
System.out.println("inside the addComponentTodiagram " + diagram);
DiagramServices diagramServices = new DiagramServices();
ContainerMapping mapping = diagramServices.getContainerMapping(diagram, mappingName);
System.err.println(mapping);
if(mapping != null )
diagramServices .createContainer(mapping, component, diagram, diagram);
}
}
After the creation of the command that allow us to add the component to the diagram, We should execute it by giving the right parameters as follows:
TransactionHelper.getExecutionManager(session).execute(new addComponentTodiagram ("Name of the mapping", component, physicalDiagram));
Here I am bit confused because I need the right mappingName because this argument is used inside the method .getContainerMapping(diagram, mappingName) of the diagramservices class as follows:
public ContainerMapping getContainerMapping(final DDiagram diagram, String mappingName) {
final DiagramDescription description = diagram.getDescription();
for (ContainerMapping aContainerMapping : ContentHelper.getAllContainerMappings(description, false)) {
for (ContainerMapping aSubContainerMapping : getAllContainerMappings(aContainerMapping)) {
if (aSubContainerMapping.getName().equals(mappingName)) {
return aSubContainerMapping;
}
}
}
return null;
}
which means that the mapping names are well known and must be respected in order to get the mapping.
So my question is : how can I get every component the exact name like "PAB_Actor" and where can I find them. For example the names of the component like Node PC, Physical Actor, Physical Function and exchanges between different component.
And for the "PAB_actor" actor component doesn't exist any more in the capella new meta-model? What is the substitution?
[Updated on: Thu, 12 March 2020 10:05] Report message to a moderator
|
|
| | |
Re: Add a created component to the diagram editor programatically [message #1826412 is a reply to message #1823351] |
Fri, 24 April 2020 14:32  |
Soulimane KAMNI Messages: 20 Registered: February 2020 |
Junior Member |
|
|
Hi,
Thank you guys for your answers, that what I was looking for.
However I do have another problem. When I map a function which is allocated to a physcial actor. They are displayed separetly instead of the encapsulation of the physical actor to the physical function.

command to create the function
public void run() {
DiagramServices diagramServices = new DiagramServices();
NodeMapping mapping = diagramServices.getNodeMapping(diagram, mappingName);
System.err.println(mapping.getDocumentation() + "\n" +mapping.getName());
if(mapping != null )
diagramServices.createNode( mapping, component, diagram, diagram);
}
command to create the physical actor
@Override
public void run() {
DiagramServices diagramServices = new DiagramServices();
ContainerMapping mapping = diagramServices.getContainerMapping(diagram, mappingName);
System.err.println(mapping.getDocumentation() + "\n" +mapping.getName());
if(mapping != null ) {
diagramServices.createContainer(mapping, component, diagram, diagram);
}
execute the two commands
TransactionHelper.getExecutionManager(session).execute(new AddNodeToDiagram("PAB_PC", part, physicalDiagram));
// display the function on the diagram
TransactionHelper.getExecutionManager(session).execute(new AddFunctionToDiagram("PAB_PhysicalFunction", function, physicalDiagram));
Attachment: mapping.PNG
(Size: 4.12KB, Downloaded 389 times)
[Updated on: Fri, 24 April 2020 14:33] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Sat Jun 10 23:56:53 GMT 2023
Powered by FUDForum. Page generated in 0.01812 seconds
|