Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: zalbina on June 03, 2013, 06:38:23 pm

Title: EA Project Browser in regular windows form
Post by: zalbina on June 03, 2013, 06:38:23 pm
Hello,

Yes, is it possible to built it in a simple way?

Thanks.
Title: Re: EA Project Browser in regular windows form
Post by: zalbina on June 03, 2013, 07:13:34 pm
Forgot to mention "using API and C#"
Title: Re: EA Project Browser in regular windows form
Post by: qwerty on June 03, 2013, 07:36:36 pm
Could you be a bit more specific?

q.
Title: Re: EA Project Browser in regular windows form
Post by: zalbina on June 03, 2013, 08:01:19 pm
Sure. I need to show dialog box which contains EA Project Browser (like C# treeview control) and user selects any package he wants to work with. I began to write the code using treeview control which works fine in my case, but my concern is recursion. It takes too much time to find all those packages and subpackages and so on. Is it clear enough?

Thanks.
Title: Re: EA Project Browser in regular windows form
Post by: qwerty on June 03, 2013, 08:10:11 pm
Not that I could help with Cxx programming (other might, though), but am I right that you have an EA-Add-in that wan't to take control (highjack) EA's project browser so the user can select a package (or whatever) and you get control back?

I doubt that would work.

Can't you use one of the OnContex... events to find out what had been selected to trigger whatever needs to be done?

q.
Title: Re: EA Project Browser in regular windows form
Post by: zalbina on June 03, 2013, 08:20:54 pm
You are right, but I could not use the "click" in the EA Project Browser directly since I have separated window which called from my ea add-in. BUT you gave me some idea, thanks.
Title: Re: EA Project Browser in regular windows form
Post by: Aaron B on June 04, 2013, 09:57:10 am
Try using Repository.InvokeConstructPicker.

See:
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/repository3.html

Code: [Select]
int selectedID;
selectedID = repository.InvokeConstructPicker("IncludedTypes=Package;");
if (selectedID != 0)
{
    EA.Element e = repository.GetElementByID(selectedID);
    EA.Package selectedPackage = repository.GetPackageByGuid(e.ElementGUID);
}
Title: Re: EA Project Browser in regular windows form
Post by: qwerty on June 04, 2013, 10:19:01 am
A new one that is. Attention draw to it, I must.

q.
Title: Re: EA Project Browser in regular windows form
Post by: Aaron B on June 04, 2013, 10:52:27 am
Added sometime around EA 9.0, I think.
Title: Re: EA Project Browser in regular windows form
Post by: qwerty on June 04, 2013, 08:25:29 pm
I wrote my Scripting book based on 9.3 (build 930). But that method did not exist at that time. So either it was just missing in the help that time or it was introduced with 10.0.

q.
Title: Re: EA Project Browser in regular windows form
Post by: zalbina on June 05, 2013, 12:23:34 am
Oh, it's good to know.

Thanks a lot.
Title: Re: EA Project Browser in regular windows form
Post by: Aaron B on June 05, 2013, 10:34:36 am
Quote
I wrote my Scripting book based on 9.3 (build 930). But that method did not exist at that time. So either it was just missing in the help that time or it was introduced with 10.0.
Correct.  Looks like the method itself was introduced around EA 9, but only first appeared in the help documentation for EA 10.
Title: Re: EA Project Browser in regular windows form
Post by: Geert Bellekens on June 06, 2013, 05:10:33 pm
2 remarks:
1) Yes indeed, if you need to select something, use the construct picker.
2) If you are building a treeview you shouldn't try to fetch the whole tree at the initialisation. I would suggest to only get the first level of packages, and then get the second level when a user actually opens a package. See the principle of "lazy loading".

Geert
Title: Re: EA Project Browser in regular windows form
Post by: zalbina on June 06, 2013, 10:33:23 pm
You are right. This is effective way to build the tree. Thanks.