Model Search scripts - how to pass 'search term'?

698 views
Skip to first unread message

volenin

unread,
Apr 19, 2013, 10:47:00 AM4/19/13
to sparx-enterprise-archite...@googlegroups.com
Hi. I've created two Model Search scripts: one under group 'Search', another one under the group 'Find in Project'.

Q1: in the 'Find in Project' dialog (Edit->Find in Project) I only see the script under the 'Search' group. The one under the 'Find in Project' group can't be found in that list of predefined searches. Based on the group name, I assumed I should be able to find it there. Where this search is available? From the Context menu? (similar to 'Element', 'Connector' and other search types?) If so, what element should I right click on to see that search?

Q2: for the 'Search' group script that I see in the dialog, is it possible to pass 'Search Term' to the script? I tried to add parameter to the OnSearchScript function (ie, 'function OnSearchScript(searchTerm)'), but when i try to printout this value from within the screen, I see that it is 'undefined'.

Thanks,

Vlad

[original message]

Bellekens@localhost Geert Bellekens

unread,
Apr 22, 2013, 2:52:00 AM4/22/13
to sparx-enterprise-archite...@googlegroups.com
Vlad,

I think that is not how it is supposed to work.
There are two examples of search scripts here:
C:\Program Files (x86)\Sparx Systems\EA\Scripts\JScript
and it looks to me like they are only using the search window to show the result of the search.

I think that you need a real add-in to be able to add searches that use code.

PS. Are you sure you need code to do the search for you? Until now I've been able to define all the searches I needed using SQL.

[original message]

rayt

unread,
Apr 25, 2013, 5:09:00 AM4/25/13
to sparx-enterprise-archite...@googlegroups.com
Hi
I wrote to support about a year ago, they wrote search term access for search scripts will be added in a later version.

Paulrus suggested a workaround (in this thread) (http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1338893185) using a keyword entry dialog that I used .

[original message]

volenin

unread,
Apr 30, 2013, 10:23:00 AM4/30/13
to sparx-enterprise-archite...@googlegroups.com
Thanks for the responses. Using the Input dialog is the only option I found as well. I thought there might be some hidden object made available in the global context...

RE: the need to use the scripts, the answer is yes - I need to traverse the model to the arbitrary depth - most searches are recursive. It's probable that you can write the same thing in SQL, but I think the statement will be over a page long :) and completely unmaintainable. Plus I'm using JS to compliment EA sparx functionality where it's missing (for autogeneration of the connectors, etc).

On the same note, does anyone use JavaScript extensively within EA Sparx? Any 'gotchas' with memory management etc when traversing a complex model? Does anyone have a set of utility / helper classes they use to simplify major tasks? (I've 'imported' an XML and SQL builder so far to make creating queries and generating XML easier).

Vlad

[original message]

Bellekens@localhost Geert Bellekens

unread,
May 2, 2013, 2:18:00 AM5/2/13
to sparx-enterprise-archite...@googlegroups.com
Vlad,

Have you considered using C# or the likes and create a real add-in/program to do what you need.

I have an open source C# library to deal with EA:
Enterprise Architect Add-in Framework (https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework)
Which depens on
UML Tooling Framework (https://github.com/GeertBellekens/UML-Tooling-Framework)

My add-in EA Navigator (http://geertbellekens.wordpress.com/ea-navigator/) uses this framework. You can find its code in the Enterprise Architect Toolpack (https://github.com/GeertBellekens/Enterprise-Architect-Toolpack)

Geert

[original message]

volenin

unread,
May 6, 2013, 3:41:00 PM5/6/13
to sparx-enterprise-archite...@googlegroups.com
My C# is not very good to say the least :) . Also, from my past experience, JavaScript is generally a bit faster to develop with than any 'enterprise' level languages, but your mileage can vary. If I could write add-ins in Java, I would. But from what I understand, Java API is 'read-only' and can't be used to modify the model.

Vlad

[original message]

Bellekens@localhost Geert Bellekens

unread,
May 7, 2013, 4:19:00 AM5/7/13
to sparx-enterprise-archite...@googlegroups.com
Vlad,

If you can write Java then you can write C# too.
I often refer to C# as the Microsoft knockoff of Java ;D

The Java api is not readonly, but you can't develop add-ins using Java.

I'm pretty sure using C# i.s.o. Javascript won't be too much overhead, and in the long run using C# would most certainly be more time efficient.

Try it, you might be surprised: Tutorial: Create your first C# Enterprise Architect addin in 10 minutes (http://geertbellekens.wordpress.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/)

Geert

[original message]

M@localhost Simon M

unread,
May 7, 2013, 6:31:00 PM5/7/13
to sparx-enterprise-archite...@googlegroups.com

253C3F363D3A3D530 wrote:
But from what I understand, Java API is 'read-only' and can't be used to modify the model.

Not true. You can modify the model, but the Java API wrapper only allows EA functions to be called from Java. It does not allow EA to call Java code, which means that you can't have a Java add-in as it couldn't get any broadcasts.
[original message]

volenin

unread,
May 13, 2013, 3:59:00 PM5/13/13
to sparx-enterprise-archite...@googlegroups.com
Well, yes. I do need it to work as an 'add-in' (ie, from within Sparx, rather than standalone app)...

Re: the trick with 'input' dialog box, I just realized there might be no way to do that in JavaScript, only in VBScript. Is that true? Or am I missing the way to display a popup with a textfield input through JavaScript?

Thx. Vlad

[original message]
Reply all
Reply to author
Forward
0 new messages