Sparx Systems Forum

Discussion => Automation Interface, Add-Ins and Tools => Topic started by: George..Brennan on November 25, 2017, 12:54:17 am

Title: Linked to Element Feature
Post by: George..Brennan on November 25, 2017, 12:54:17 am
VBScripting ( ugh )

Well It looks like I can add a connector between Elements but when I try to use StyleEx to add an atttribute level link such..

   newStyleEx = "LFEP=" & oAttributeSource.AttributeGUID & "L;LFSP=" & oAttributeTarget.AttributeGUID & "R;"               
   'Session.Output("+:" & newStyleEx )
   set oConnector = oSource.Connectors.AddNew ("","Association")
   oConnector.StyleEx = newStyleEx
   oConnector.SupplierID = oTarget.ElementID
   oConnector.update()


everthing looks fine in the database tables but it's not rendering the attribute linkage ends only the relation ship to the element.

Can anyone please tell me what am I missing ?

G.
Title: Re: Linked to Element Feature
Post by: Geert Bellekens on November 25, 2017, 05:49:21 pm
Hi George,

This is the code I have from in ConnectorWrapper (https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/EAWrappers/ConnectorWrapper.cs)
I don't see immediately what is wrong in your code.

Code: [Select]
    private void setLinkedFeature(UML.Classes.Kernel.Element linkedFeature, bool isSource)
    {
//check if attribute
Element actualEnd = linkedFeature as Attribute;
//or maybe operation
if (actualEnd == null) actualEnd = linkedFeature as Operation;
if (actualEnd != null)
{

//set the client id to the id of the owner
if (isSource)
{
_source = linkedFeature;
this.wrappedConnector.ClientID = ((ElementWrapper)actualEnd.owner).id;
}
else
{
_target = linkedFeature;
this.wrappedConnector.SupplierID = ((ElementWrapper)actualEnd.owner).id;
}
//set the linked feature
string key = isSource ? "LFSP" : "LFEP";
string suffix = isSource ? "R":"L";
string styleEx = KeyValuePairsHelper.setValueForKey(key,linkedFeature.uniqueID + suffix,this.wrappedConnector.StyleEx);
this.wrappedConnector.StyleEx = styleEx;
}
    }

Geert
Title: Re: Linked to Element Feature
Post by: qwerty on November 27, 2017, 03:49:43 am
You could cross check by simply creating another connector manually and looking the the t_connector to see if both are looking identically.

q.
Title: Re: Linked to Element Feature
Post by: Guillaume on November 27, 2017, 06:27:00 pm
Hi George,

I think the LFSP & LFEP are not associated with the right attribute.
Have you tried switching them to:

   newStyleEx = "LFEP=" & oAttributeTarget.AttributeGUID & "L;LFSP=" & oAttributeSource.AttributeGUID & "R;"     

Guillaume
Title: Re: Linked to Element Feature
Post by: George..Brennan on November 27, 2017, 08:43:54 pm
Hi Guillaume,

Many thanks, working fine now.

George