Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Hoefler1 on March 01, 2016, 09:53:26 pm
-
I created an Add-In which I want to use as a Validation.
The program shall only be called once when validating (that's why I can't use EA_OnRunPackageRule, EA_OnRunElementRule etc.)
So my thoughts were to call my main method in EA_OnStartValidation.
The problem I'm facing is, that that way the program is called each time I "Validate Current Package". Even if I disable the category in "Configure Validation Rules..."
Is there a way to find out if the category is ticked for the Validation?
-
My guess is that it is stored in the registry. The repository does not seem to hold this information.
q.
P.S. Hmm. The registry does not change?!
P.P.S. But there's this key: "Simple UML Views::ModelValidation::W"="MVR010000=1;MVR020000=1;MVR030000=1;MVR040000=1;MVR050000=1;MVR060000=1;MVR070000=1;MVR080000=1;MVR090000=1;MVR0A0000=1;MVR0B0000=1;MVR7F0001=1;"
-
I did now find that key. For me (EA Version 12) it is called "Basic UML 2 Technology::ModelValidation::W"="MVR010000=1;MVR020000=1....".
But it truly doesn't seem to change.
I manually changed the 1s to 0s, to see if this would disable the categories, but it had no effect at all...
-
I'll try to investigate a bit more later. Maybe some kind Sparx supporter can comment?
q.
-
I did now find that key. For me (EA Version 12) it is called "Basic UML 2 Technology::ModelValidation::W"="MVR010000=1;MVR020000=1....".
But it truly doesn't seem to change.
I manually changed the 1s to 0s, to see if this would disable the categories, but it had no effect at all...
Those are the settings if you set "Basic UML 2 Technology" to be the active technology.
-
Ok, but where are the validation rule settings stored?
q.
-
Global Resources::ModelValidation::W and Global Resources::ModelValidation::B
-
That leaves me as clueless as before. Those are not registry keys. And I would not know how to relate those to something else in EA.
q.
-
That leaves me as clueless as before. Those are not registry keys. And I would not know how to relate those to something else in EA.
q.
Go to the Default Tools toolbar (View|Toolbars|Default Tools) and you will notice a listbox with all the technologies listed. The value of that listbox (i.e. the active technology) determines which registry keys are used for the model validation configuration. If there is no active technology (i.e. that listbox shows '<default>') then Global Resources::ModelValidation::W and Global Resources::ModelValidation::B are used. They won't appear in your registry until you change the model validation configuration with <default> set active.
-
Now I see, the two Global Resources::ModelValidation registry keys were just created when selecting something else from the active technology list box, and then switching back to <default>. The "W-key" does now also hold the names of my self-defined categories.
But I'm afraid it does not change when I tick/untick any of the categories in EA. Am I just doing it wrong?
Back to my actual goal: I still want to find out the ticked and unticked categories to use this information in my Add-In.
This way I would be able to only run the program if a certain category is selected.
-
As I see it, you can't find it out. There's always the chance to ask for a new feature. But that might take a looong time. I have no idea how it could be accomplished.
q.
-
I'm getting closer! :)
- The ticked categories are stored in the W-Key of the active technology (<default> = Global Resources)
- The unticked categories are stored in the B-Key
So I do the following:
0. Technology is set to <default>, All the actegories are active (meaning Global Resources::ModelValidation::W contains all of them, ...::B is empty)
1. By "Configure..." I unselect whatever categories I don't want to run in the validation
Unfortunately (!!) after pressing OK the keys remain the same...
2. I Change the Technology to something else than <default>
Now the Global Recources-Keys are updated. (Ticked categories in W, unticked in B)
3. So I go back to <default>
-
If my keys were consistant with the current selection in EA all the time I could simply do this in my Add-In:
public bool Category_Active(string cat)
{
string reg_value = (string) Registry.GetValue("HKEY_CURRENT_USER\\Software\\Sparx Systems\\EA400\\EA\\OPTIONS",
"Global Resources::ModelValidation::W", "Key not found");
//MessageBox.Show(reg_value);
string catNoBlanks = cat.Replace(" ","");
return reg_value.Contains(catNoBlanks);
}
public void EA_OnStartValidation(EA.Repository Repository, Object Args)
{
if (Category_Active("My Validation Category"))
{
//Run my Validation
}
return;
}