Sparx Systems Forum
Enterprise Architect => Suggestions and Requests => Topic started by: Smartrek on August 26, 2010, 07:28:17 pm
-
It would be convenient to have the option to copy the class Notes field to the instance when making an instance of a class.
Tanks
Marc
-
Sorry Marc, but I don't agree.
The class and the instance are two different things, which should have their own notes.
If someone is interested in the documentation of the class then they should look there. Having multiple copies of the same note is redundant, and will only lead to confusion because those copies are bound to go out of synch.
Geert
-
Maybe a new optional compartment for instance rendering to show the classifier's notes?
-
That would be a better idea
Geert
-
How lovely it would be if there were a really programmable rendering machine.
b.
-
How lovely it would be if there were a really programmable rendering machine.
b.
Seconded!
-
Absolutely! +++++ as many votes as I can get in. The number of times I have had to alt-squish-ctl-shift-tab-stop-pick-up-mouse-find-wanted-item-stop-thinking-start-copying-whatwasIdoinganyway!!! is uncountable!
Between you and I though, I think it might be a useability feature, so :'(
b
-
EA already provides the ability to define your own custom compartments via an Add-In. See:
http://www.sparxsystems.com/enterprise_architect_user_guide/automation_and_scripts/compartments_2.html
Just as a quick proof-of-concept I was able to implement these broadcast events to create my own custom compartment showing the notes of the element classifier (if one was set). If anybody wants the C# code from my brief experiment, let me know.
-
Aaron, please see the latest news from Sparx. You could publish it on the Community site.
b.
-
Aaron, please see the latest news from Sparx. You could publish it on the Community site.
b.
Mmm.. you beat me to it ;D
Geert
-
I'll forward it on to the guys here who actually write the articles on the Community Site and see if they can organize something. Until then, here is the code I used. The CS_AddinFramework (http://www.sparxsystems.com/bin/CS_AddinFramework.zip) project can be used as the basis and then just paste this code into it.
Added a clause that requires a ShowClassifierNotes=True tagged value on the object to show the Classifier Notes - just so that you have some basic level of control over where it is displayed and it doesn't accidientally ruin existing diagrams.
I'm sure this code could do with a lot of improvement, but at least it should help provide a starting point if you want to work with custom compartments.
public object EA_QueryAvailableCompartments(EA.Repository repository)
{
//Just define one additional Compartment named "Classifier Notes"
return "Classifier Notes";
}
public object EA_GetCompartmentData(EA.Repository repository, string sCompartment, string sGUID, EA.ObjectType oType) {
StringWriter data = new StringWriter();
string compartmentName = sCompartment;
//Handle the custom "Classifier Notes" compartment
if (sCompartment.CompareTo("Classifier Notes") == 0)
{
//Get the current element
EA.Element e = repository.GetElementByGuid(sGUID);
//Does the current element have a classifier?
if (e.ClassifierID != 0)
{
//Only show compartment where element has tagged value ShowClassifierNotes=True
//This simply prevents any existing diagrams from being accidentally broken by the
//addition of this new compartment.
EA.TaggedValue tag = (EA.TaggedValue)e.TaggedValues.GetByName("ShowClassifierNotes");
if (tag != null)
{
if (tag.Value.CompareTo("True") == 0)
{
//Get a reference to the classifier element
EA.Element classifier = repository.GetElementByID(e.ClassifierID);
//Does the classifier actually have any notes?
if (classifier.Notes.Length > 0)
{
//Get the notes from the classifier in basic Text format
data.Write("Data&_eq_^" + repository.GetFormatFromField("TXT", classifier.Notes) + "&_sc_^");
//Use the classifier GUID as a reference for this compartment
data.Write("GUID&_eq_^" + classifier.ElementGUID + "&_sc_^,");
//Optional: Put the classifier element's name in the compartment name (E.g. "Class1 Notes")
compartmentName = classifier.Name + " Notes";
}
}
}
}
}
//If data has been defined for this Compartment, return it to EA to be rendered.
if (data.ToString().Length > 0)
{
StringWriter s = new StringWriter();
s.Write("Name=" + compartmentName + ";");
s.Write("OwnerGUID=" + sGUID + ";");
s.Write("Options=SkipIfOnDiagram&_eq_^1&_sc_^");
s.Write("CompartmentData=" + data.ToString() + ";");
return s.ToString();
}
return null;
}
-
For anybody interested, this example of how to define a custom compartment via an add-in has now been posted on the EA Community web site.
http://community.sparxsystems.com/resources/scripts/showing-classifier-notes-custom-compartment