Author Topic: Re-connection of a Connector  (Read 3196 times)

philchudley

  • EA User
  • **
  • Posts: 744
  • Karma: +21/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re-connection of a Connector
« on: November 27, 2008, 03:10:21 am »
Hi All

I am working on an add-in that deals with connectors and I need to detect if a connector is being re-connected using the dragging to a new element method.

My add-in is registered to receive the event EA_OnNotifyContextItemModified and at the momment, I simply display a simple dialog capturing the connector GUID, names of the elements using clientId and supplierID as shown in the code below:

public void EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType type)
        {

            if (type.ToString() == "otConnector")
            {
                EA.IDualConnector theConnector = Repository.GetConnectorByGuid(GUID);
                string[] details = new string[3];
                int clientID = theConnector.ClientID;
                int supplierID = theConnector.SupplierID;
                details[0] = "client : " + Repository.GetElementByID(clientID).Name;
                details[1] = "supplier : " + Repository.GetElementByID(supplierID).Name;
                details[2] = "connector GUID : " + GUID;
                debugForm = new DebugForm(details);
                debugForm.Text += " : Modified";
                debugForm.ShowDialog();
            }
        }

All works well, when I move a connector which starts at Element A (the client) from its supplier (Element B) to a new supplier (Element C), the event is captured twice.

This I would expect since the connector is being disconnected and re-connected (two changes), but the client and supplier info is the same in both events. Specifically, only the new supplier info is shown.

Is there any method of detecting the original supplierID and the new supplierID when a connector is moved in this manner?

Hope what I seeking to do is clear in the above

Cheers
Models are great!
Correct models are even greater!

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Re-connection of a Connector
« Reply #1 on: November 27, 2008, 05:04:47 am »
Sounds like a bug to me. If there are two events at all (which is weird enough because there is only one modification, cause connectors with null suppliers don't exist), then in the first event one should see the old supplier.

All this would be much clearer if they had a Pre- and a Post-event for it, like with NewElemenet a.s.o.

Offhand I wouldn't know how to get the old supplier, unless you read all connectors at EA_FileOpen and cache it all. Which would be like reinventing EA, of course.