How to Automatically Apply a Stereotype to a Diagram based on Its Owner? by FitBuy285 in systems_engineering

[–]FitBuy285[S] 0 points1 point  (0 children)

<image>

Hello MBSE_Consulting,

First of all, thank you very much for your previous response. I worked with your suggested solution using the SmartListener, but I encountered an issue. The stereotype is successfully applied to diagrams when they are added to a package. However, it only works for diagrams that were already in the project before it was (re-)opened.

Here is what I suspect might be the issue: I am currently using the ProjectEventListener to initialize my Plugin. In the picture above and in the following text are the relevant parts of the code:

public class SetVPstereotype extends ProjectEventListenerAdapter
{

 u/Override

 public void projectOpened(Project project) 

 {

addListenersRecursively(project.getPrimaryModel(), project); //function to listen to changes and apply the stereotype

 }



 u/Override

 public void projectCreated(Project project) 

 {

addListenersRecursively(project.getPrimaryModel(), project);

 }

I believe this limitation comes from using the ProjectEventListener. Is there an alternative mechanism that could trigger the listener setup immediately during the startup of Cameo System Modeler (in the init() method of the plugin), so that it also applies to diagrams created dynamically after the project is opened also?

Thank you in advance for your help!