Book a Demo

Author Topic: Adding Package/Diag. Frame to Diagram via Java  (Read 4891 times)

jpjp

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Adding Package/Diag. Frame to Diagram via Java
« on: August 03, 2012, 08:22:06 pm »
Hi,

I'm using Java and EA to automatically show dependencies in a large scale application (All dependencies already calculated, only need to display result).

I want to be able to add Packages, Diagrams or Diagram Frames to an existing Diagram via Java. At the moment I can add Elements to the Diagrams, but when trying to add a Package or Diagram, I get nothing, and I'm not sure if it's possible (or even less so than Package) to add a Diagram Frame.

The code i'm using is more or less the same as the example:

Code: [Select]
 
public static void addDiagramTo...(Diagram diagram, ... toAdd) {
        Collection<DiagramObject> diagramObjects = diagram.GetDiagramObjects();
        DiagramObject diag = diagramObjects.AddNew("", "");
        diag.Set...ID( toAdd...ID() );
        diag.Update();
        System.out.println( "Added ... '" + toAdd.GetName()
                + "' to diagram '" + diagram.GetName() + "'");
        
    }

PS the '...' in the code in just in place of Package or Diagram etc..

Does anyone know a solution to this problem? Or a workaround?

Thanks in advance,
Jack

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding Package/Diag. Frame to Diagram via Java
« Reply #1 on: August 03, 2012, 09:30:01 pm »
Jack,

I think I remember some code samples regarding diagram frames.
Try searching this forum using the top left search button.

Geert

jpjp

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Adding Package/Diag. Frame to Diagram via Java
« Reply #2 on: August 03, 2012, 09:56:44 pm »
Ahh..

You're right..

I searched in the Automation Interface, Add-Ins and Tools forum but found nothing so asked here.

Answer was in General!  :-[

Thanks for replying,
Jack

jpjp

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Adding Package/Diag. Frame to Diagram via Java
« Reply #3 on: August 03, 2012, 10:21:11 pm »
Slightly hasty on my reply, but if anyone else if interested in the code in the future it can be found here:
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1338905382/0#0

That does answer part of my question - I can now add Packages to the Diagrams.
I haven't had much luck with finding any information on adding Diagram Frames however.
I'm not sure if this is possible within the framework ..?

Any info is appreciated.

Thanks,
Jack

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding Package/Diag. Frame to Diagram via Java
« Reply #4 on: August 03, 2012, 10:24:12 pm »
Diagram frames are dedicated elements linked to diagrams. I haven't added that to my Scripting book but will do that soon.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding Package/Diag. Frame to Diagram via Java
« Reply #5 on: August 03, 2012, 10:38:29 pm »
So you'll need to add an element of type UMLDiagram to a package with the diagramID for the referenced diagram in Pdata1 (miscdata(0)), and then add a diagramObject referencing this object.

I'm not sure anymore whether you can edit the miscdata. You might need to fix that with a direct SQL update.

Geert

jpjp

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Adding Package/Diag. Frame to Diagram via Java
« Reply #6 on: August 03, 2012, 10:40:59 pm »
Ah, I see.
Thanks for your help, and quick responses!
I'll have a go.

Thanks again,
Jack