Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Soulimane KAMNI is currently offline Soulimane KAMNIFriend
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)index.php/fa/37570/0/

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 #1822781 is a reply to message #1822728] Fri, 13 March 2020 12:09 Go to previous messageGo to next message
Aurelien Pinsonneau is currently offline Aurelien PinsonneauFriend
Messages: 15
Registered: February 2020
Junior Member
Hello,

This kind of name "PAB_Actor" can be find in the definition of the PAB diagram itself.
You can find it in the odesign files of the org.polarsys.capella.core.sirius.analysis plugins of Capella.

Please also know that Sirius supports different kind of diagrams:
- diagrams filled automatically with the content of the model: this is the case in Capella for breakdown diagrams for example
- diagrams to be filled manually by the user: this is the case of PAB diagrams in Capella

The kind of diagram is defined by an attribute in the odesign file: "Synchronization" (actually this attribute is on each definition of content for the diagram)
By simply changing this attribute in the odesign file, you can modify the behavior of the diagram
Re: Add a created component to the diagram editor programatically [message #1823351 is a reply to message #1822781] Wed, 25 March 2020 11:02 Go to previous messageGo to next message
Philippe Dul is currently offline Philippe DulFriend
Messages: 25
Registered: November 2013
Junior Member
Hi,
The mapping is the 'style description' of a shape in a diagram.
By opening odesign files located in org.polarsys.capella.core.sirius.analysis plugin, you will find how all diagrams of capella are made.
(File / Import / Plugin and fragment, check 'Project with source folder' / Next / Lookup for org.polarsys.capella.core.sirius.analysis)

You can use "Windows > Show View > Interpreter"

write in the expression section : "aql:self.actualMapping"
then, when you will click on an element in the diagram, then the mapping will appear below.

PAB_Actor has indeed being merged into PAB_PC in 1.4.0.

Its a bit technical, but you can look at substitution here.
https://github.com/eclipse/capella/blob/b05bc20ce8fc38b98ac7789c16c0f347d10d050b/core/plugins/org.polarsys.capella.core.data.migration/src/org/polarsys/capella/core/data/migration/capella/ActorRefactoringMigrationContribution.java#L308

Constants are defined here:
https://github.com/eclipse/capella/blob/master/core/plugins/org.polarsys.capella.core.sirius.analysis/src/org/polarsys/capella/core/sirius/analysis/IMappingNameConstants.java

Regards
Philippe
Re: Add a created component to the diagram editor programatically [message #1826412 is a reply to message #1823351] Fri, 24 April 2020 14:32 Go to previous message
Soulimane KAMNI is currently offline Soulimane KAMNIFriend
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.
index.php/fa/37939/0/
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 604 times)

[Updated on: Fri, 24 April 2020 14:33]

Report message to a moderator

Previous Topic:How to package viewpoint after adjustments?
Next Topic:Custom style for capella diagram elements
Goto Forum:
  


Current Time: Fri Apr 19 23:36:52 GMT 2024

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

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

Back to the top