Book a Demo

Author Topic: Connectors-limit endpoints to defined stereotypes  (Read 3488 times)

harvinder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Connectors-limit endpoints to defined stereotypes
« on: December 29, 2010, 09:02:22 am »
I have created [using shape script and stereotype in profile] a custom connector.

I am wondering if I can limit the end point to certain stereotypes only, i.e it should not be possible to draw connection between two unsupported stereotypes.

cheers
harvinder

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Connectors-limit endpoints to defined stereoty
« Reply #1 on: December 29, 2010, 10:08:27 am »
Currently not possible. The closest you can get is to write a model validation add-in that will validate your model after you have created it.
The Sparx Team
[email protected]

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Connectors-limit endpoints to defined stereoty
« Reply #2 on: December 29, 2010, 12:02:16 pm »
Another "trick" I use is to set up the QuickLinker for the profile to draw a VERY obviously badly drawn connector between two invalid stereotypes.  Mine draws a thick red line with red ovals at either end with the stereotype «INVALID».

Sure stands out and people soon learn not to join the two invalid stereotypes.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

harvinder

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Connectors-limit endpoints to defined stereoty
« Reply #3 on: December 29, 2010, 04:41:31 pm »
I have got another, but not a perfect solution...

the only problem is, that, I can create a valid connection and later drag one end to the not supported stereotype element...

        bool EA_OnPreNewConnector(Repository repository, EventProperties info)
        {
            bool foundMyConnector = false;
            bool foundValidEnds = true;
            foreach (EA.EventProperty eventproperty in info)
            {
                //
                if ("Stereotype" == eventproperty.Name && "MyConnector" == eventproperty.Value.ToString())
                {
                    foundMyConnector = true;
                }

                if ("SupplierID" == eventproperty.Name || "ClientID" == eventproperty.Name)
                {
                    int supplierID = System.Convert.ToInt32(eventproperty.Value);
                    Element supplier = repository.GetElementByID(supplierID);
                    if (!supplier.Stereotype.Contains("MyStereotypEnd"))
                        foundValidEnds= false;
                }
            }
            if (foundMyConnector)
            {
                return foundValidEnds;
            }
            else
                return true;
        }