Menu

Programmatically add package member

Anonymous
2014-10-21
2014-11-28
  • Anonymous

    Anonymous - 2014-10-21

    Hi!
    I'm working on a plugin and need to create packages due to namespaces. I've managed to create the package and the classes, but i cant figure out how to either move the class to the package, or better, to create it as a child directly.
    Tips and tricks?

    regards
    /Albert

     
  • Janusz Szpilewski

    I think you may find the exact details looking at the source of the plugins doing reverse engineering.

    Generally when you call

    CreateClass(AOwner: UMLNamespace): IUMLClass

    on the ClassFactory you need to specify the parent namespace as the parameter.

     
  • Anonymous

    Anonymous - 2014-11-14

    I think i tried linking the package as the class owner but got a data type error.
    Is the code for the C reverse engineering plugin available as reference?
    It's ofc. another step to translate that into LabVIEW as my plugin is intended for, but anything helps. :)
    /Albert

     
  • Janusz Szpilewski

    Here is a tested sample code in C# that adds a class to the second package owned by the project (usually "Logical View")

    IStarUMLApplication m_StarUMLApp = new WhiteStarUMLApplicationClass();    
    // ...
    IUMLProject prj = m_StarUMLApp.ProjectManager.Project;
    IUMLNamespace owner = prj.GetOwnedElementAt(1) as IUMLNamespace;
    IUMLFactory facto = m_StarUMLApp.UMLFactory;
    facto.CreateClass(owner);
    
     
  • Anonymous

    Anonymous - 2014-11-18

    Thanks, i'll give that a try!

     
  • Anonymous

    Anonymous - 2014-11-28

    I got it to work with your code as reference, thanks!
    /Albert

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.