Author Topic: Create EA UI Screen  (Read 14300 times)

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Create EA UI Screen
« on: August 05, 2009, 06:01:08 pm »
I'm having issues creating a UI Window in EA through C#.

I create a new Element of type Screen (which results in a new Window object in the UI Model.
Then I'm adding the controls on the Screen with MyNewWindow.Elements.AddNew.

I can see MyNewWindow in the Project browser, with a bunch of controls attached to it... but when I drag the Screen onto a diagram... I'm not seeing the controls at all.

I know with a DiagramObject you have to position the object in a Diagram... but how do you position a control in a screen??

Any help is appreciated!!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Create EA UI Screen
« Reply #1 on: August 06, 2009, 12:03:09 pm »
Quote
I can see MyNewWindow in the Project browser, with a bunch of controls attached to it... but when I drag the Screen onto a diagram... I'm not seeing the controls at all.
Ctrl+Drag the screen onto the diagram and a dialog will appear. Tick the "include Embedded Elements" option to add the embedded elements to the diagram. Tick the "Based on Instance" option to name a diagram which has the element and its embedded elements arranged in the formation you want to copy.

Quote
I know with a DiagramObject you have to position the object in a Diagram... but how do you position a control in a screen??
You position the embedded elements on the diagram too, you just need to make sure that the embedded elements are positioned within the parent. EA normally takes care of this - if you get it wrong, say placing a port nowhere near its parent class, EA will sort it out the first chance it gets (either when you select or move one or other element).
« Last Edit: August 06, 2009, 01:03:50 pm by KP »
The Sparx Team
[email protected]

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #2 on: August 06, 2009, 08:24:27 pm »
Is there any way I can do this programmatically?
The reason why is because I have an XML file that describes a particular screen... I would like to read this XML file and create the Screen in EA.

Basically the XML contains the size of the screen, the components on the screen (textbox, checkbox,...) and their position (+ a lot of other specifications of that screen).

I want to create a new EA.Element per XML Screen node. Attach other EA.Elements to that screen with EA.Element.Elements.AddNew("","").
Then position these new elements on the EA Screen.
When all is done, create a diagram per screen so the user can view his screen in EA.

Maybe this extra bit of information will help in understanding in what I would like to do.

Again...any help would be greatly appriciated!

gilles2

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #3 on: August 08, 2009, 01:39:37 am »
yes you can do that :

attach an addin of your own to EA :
a sample scenario would be :

1 : a winform opens with an "input file" field to select your xml file from your hard disk
2 : while reading your xml file
     you create elements
                     diagrams
                    and diagram objets that are representations of elements on diagrams with layout properties and so on ...

Gilles
« Last Edit: August 08, 2009, 02:04:25 am by gilles2 »

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #4 on: August 10, 2009, 03:47:03 pm »
Yup! That's what I want to do... but for some reason it doesn't work.
Do you perhaps have some sample code on how to create a "Screen" element type?
How to position elements on a Screen?

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Create EA UI Screen
« Reply #5 on: August 10, 2009, 04:34:16 pm »
If I understand Neil (KP) correctly, you do in the AI pretty much what you do through the User Interface - define a screen diagramobject on the diagram, with its position coordinates, then separately define each UI Control diagramobject on the diagram, each with its own position coordinates. The UI Control coordinates overlap with the screen coordinates, so that the end result is each UI Control object is sitting over the required portion of the screen.

Did Neil's explanation of the second problem work? Once you have the screen in the Project Browser, you use Ctrl + drag and select the Embedded Objects checkbox to show all the UI elements. Otherwise you get a simple instance or copy of the screen element only.

Does any of this solve the problem?  I might not have understood Neil correctly....!
« Last Edit: August 10, 2009, 04:56:03 pm by RoyC »
Best Regards, Roy

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #6 on: August 10, 2009, 05:09:08 pm »
So you position elements on a "Screen" by adding that screen to a diagram and positioning the elements inside the diagram?

I've got it to add the screen widgets (textbox, checkbox...) to a EA.Element of type "Screen".
But when I drag that Screen to a diagram (with or without Ctrl) the elements are not shown inside the screen.

I'll try to position through a diagram & diagramobjects... I'll see from there!

Thanks for the help though!

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Create EA UI Screen
« Reply #7 on: August 11, 2009, 04:36:38 pm »
>> But when I drag that Screen to a diagram (with or without Ctrl) the elements are not shown inside the screen.

The dialog is the crucial bit, offering the option to include embedded elements. If you don't select that checkbox, you don't see the user interface elements on the screen.
Best Regards, Roy

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #8 on: August 14, 2009, 06:55:55 pm »
Okay... this isn't working.
- I'm creating a new Screen element in the package. (Package.Elements.Add)
- I'm adding the Elements to the Screen. (Screen.Elements.Add)
- I'm adding them to a Diagram also (so they can be positioned on the Screen)
- I'm draging the Screen on the Diagram with Ctrl and selecting "Include embedded elements", but the screen still does not contain any UI Elements.

How are the "UI Control" type objects connected to a "Screen" type? Screen.Elements? Screen.EmbeddedElements?

Why is this so difficult to do? :-/

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #9 on: August 17, 2009, 10:50:00 pm »
Okay... I'm getting frustrated... it turns out that the Elements ARE on the diagram... you just can't see them. All the elements are behind the screen...so I need to change the Z-order of the Screen vs its Elements.
Can I do this programatically? Or do I need to add the DiagramObjects in a specific order??

PS: What a pain!!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13083
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create EA UI Screen
« Reply #10 on: August 17, 2009, 11:11:25 pm »
try DiagramObject.Sequence
According to the documentation that should do the trick.

Geert

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #11 on: August 18, 2009, 12:33:45 am »
Thanks... just figured it out...
Now I've got that working ... but the elements on the screen do not display correctly... height, width, X, Y are messed up...

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Create EA UI Screen
« Reply #12 on: August 18, 2009, 02:12:31 am »
EA interprets the size and shape parameters somewhat differently from most applications.

Try creating a simple diagram by hand, then querying the database (i.e. the EA file or repository) to see the values EA uses. You may need to open the database with an external tool (even MS Access) to browse the fields. Note the values in text and memo fields as some of the parameters are stored in text strings.
No, you can't have it!

alext

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Create EA UI Screen
« Reply #13 on: August 19, 2009, 05:39:28 pm »
I finally got it to work! More difficult than I've thought... but now I have an AxureRP-EA bridge!

Thanks for the help!