Book a Demo

Author Topic: settings / configuration for plug-ins  (Read 3020 times)

Bokkie

  • EA User
  • **
  • Posts: 80
  • Karma: +0/-0
  • Lima Bravo!
    • View Profile
settings / configuration for plug-ins
« on: September 27, 2006, 12:46:35 am »
Hello gurus,

To speed up design/development I am writing some plug-ins that perform 'transformations'. One of these plug-ins transforms a class into other classes and some of the generated classes must inherit from a parent. This parent is also in the repository.

The best way I guess is to look up to parent by its GUID. I would like to configure the parent its GUID for the plug-in.

I have considered looking up the parent by its name but came to the conclusion that this is a rather weak method since anybody can add another class with the same name.

At the moment I am looking up the GUID in the registrykey of the plug-in (another plug-in allows the user to select the parent which causes the GUID  to be written in the registry). This solution works except when you are working with more than one repository/projects.

Instead of using the registry I would like to store these settings in the repository itself. Is this possible or should I look for another solution?

Thanks, M.
Lima Bravo!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: settings / configuration for plug-ins
« Reply #1 on: September 27, 2006, 04:57:31 am »
If I correctly understand what you are trying to do, you should be able to get elements from the repository via the GUID without too much trouble.

From the Repository object you can call several Get<elementType>ByGuid() functions. The usual problem is that sometimes finding the GUID of an element you have not previously 'encountered' can be a bit difficult.

I have been able to solve this by using the various Enum<elementType>() functions of the Project interface (which can be retrieved with the GetProjectInterface() function of the Project class. You have to traverse the project structure a bit, since these functions are scoped to individual collections. You also have to translate the GUID strings between the XML versions and 'stripped' strings, but the Project interface provides functions for this.

It took me a bit of programming to make it work, but the results far exceeded my expectations for performance.

In future I'd like to see a cleaner interface from Sparx that would allow this without the arcane manipulations. However, given the structure of the current COM automation interface I don't think this will appear until the next (very) major product revision. Perhaps they'll bite the bullet for version 7.0, since COM is getting a bit old and brittle...
No, you can't have it!

Bokkie

  • EA User
  • **
  • Posts: 80
  • Karma: +0/-0
  • Lima Bravo!
    • View Profile
Re: settings / configuration for plug-ins
« Reply #2 on: September 27, 2006, 05:11:45 am »
Lets assume the plugin creates classes that derives from the interface ISomeInterface. This interface is somewhere in your EA project (e.g. the origin is a toolkit) but its path/location can change.

Rember, in large projects there are allways people who come up with the same name for something else. Thus looking up an element just by its name and/or location isn't a very strong method.

Therefor the plug-in needs to be told (i.e. configured) where the interface can be found. IMHO this would be to store the interface's element GUID *somewhere* and read it from the plug-in.

At the moment I'm using the registry but I would prefer to store the information in the project itself which is easier to deploy and maintain. Unfortunally, custom settings or Tags are not available for Projects.

M.

Lima Bravo!