Book a Demo

Author Topic: Automating EA wireframes  (Read 3550 times)

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
Automating EA wireframes
« on: June 28, 2007, 02:37:28 am »
Hi all,

I'm creating a screen in EA using automation with several associated UI controls.  That works fine.

Now I want to create a new diagram and add both the screen and associated UI controls.  The screen is added just fine.  However, the controls are visible UNDER the screen until I either move or resize the screen.  As soon as I do that, the controls disappear.  However, they are still "on" the diagram because if I try to drag them back on from the project browser in EA, I get an error message that they are already on the diagram.

Any thoughts on why the controls are disappearing once the screen is touched?  Here's a code snippet:

Code: [Select]

private void CreateEADiagram(EA.Repository rep, EA.Package pack, UIForm form, List<UIControl> controls)
{
   StringBuilder pos = new StringBuilder();

   EA.Diagram diagram = (EA.Diagram)pack.Diagrams.AddNew(form.Name, "Logical");
   diagram.Update();

   // Format for AddNew first parameter: "l=200;r=400;t=200;b=600;"
   pos.AppendFormat("l={0};r={1};t={2};b={3}", new object[] { 0, form.Size.X, 0, form.Size.Y });
   EA.DiagramObject diagObj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(pos.ToString(), "");
   diagObj.ElementID = rep.GetElementByGuid(form.EaGuid).ElementID;
   diagObj.Update();

   diagram.Update();

   foreach (UIControl ctl in controls)
   {
       if (ctl.EaGuid != null)
       {
           int l = ctl.Position.Left;
           int r = l + ctl.Position.Width;
           int t = ctl.Position.Top;
           int b = t + ctl.Position.Height;

           pos = new StringBuilder();
           pos.AppendFormat("l={0};r={1};t={2};b={3}", new object[] { l, r, t, b });
           diagObj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(pos.ToString(), "");
           diagObj.ElementID = rep.GetElementByGuid(ctl.EaGuid).ElementID;
           diagObj.Update();
       }
       diagram.Update();
   }

   rep.OpenDiagram(diagram.DiagramID);
}

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Automating EA wireframes
« Reply #1 on: June 28, 2007, 02:51:49 am »
Sounds like EA has decided to trash your desired z-order.

You could probably write something to iterate through the elements and push the screen to the bottom of the z-order. EA does not handle sequencing of all the other DiagramObjects when you change the sequence of one. You'll have to pull them into some kind of structure, figure out the new order of everything, then write them back to the model with the new positions.

Look up the Sequence property of DiagramObject.

David
No, you can't have it!

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
Re: Automating EA wireframes
« Reply #2 on: June 28, 2007, 07:38:08 am »
Thanks, that did it.

I actually just set the sequence while creating the controls (in the above code), starting with a large number and working down toward 1 for the screen itself.


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Automating EA wireframes
« Reply #3 on: June 28, 2007, 09:27:54 am »
Sounds right to me. You've got the correct approach, since EA considers this to be a 1-based list with lower numbers at the bottom.

Where EA perceives a container relationship, the lower number also indicates the (potential) parent. This works well with screens and UI controls.

David
No, you can't have it!