Book a Demo

Author Topic: How to hide connectors of an element?  (Read 3805 times)

Thiyagaraj A

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
How to hide connectors of an element?
« on: March 19, 2008, 08:25:09 pm »
I need to hide the particular element connectors from an AddIn. Is there a way in AddIn API. (It can be hiding connector by connector.)
« Last Edit: March 19, 2008, 08:25:59 pm by thiyagaraj_a »
Regards,
Thiyagaraj A.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to hide connectors of an element?
« Reply #1 on: March 19, 2008, 10:13:08 pm »
Yes, but there's a catch.

Remember that connectors show up on diagrams. Yes, I know that's obvious, but without thinking of it this way you won't have anything to hide.

What you want to hide is the DiagramLink that represents the connector. DiagramLink objects are specific to each diagram - just like DiagramObjects - and each has a ConnectorID attribute to link it back to the connector it represents.

Just set the IsHidden attribute of a DiagramLink to false (it is boolean) to hide that connector instance on the diagram that shows the link.

Now the catch:

EA is really great at automatically adding connectors when you have 'connected' elements on a diagram. In fact, EA is so good at this that it does not even have to store all these connectors as part of the diagram, it actually can add them on the fly each time it renders the diagram. This means that you don't necessarily have a DiagramLink object for every connector that EA will render.

The catch above is likely to occur when you add a connector to your model after you've created a diagram. EA does not traverse all your diagrams looking to see if it needs to add the connector. It just waits until you open one of these diagrams and then draws the connector. But it does not add a DiagramLink object to the the diagram definition, nor does this get stored in the database.

So you also need to parse the elements on the diagram looking for additional connectors that are not in the DiagramLinks collection, add them to the collection, and set the IsHidden attribute.

Note that you can do this at the time you create new connectors, which saves you hunting around the diagrams later.

I keep thinking there should be - and perhaps is - some attribute of a connector that would tell EA not to add it on the fly, but if so I don't know what it is.

HTH, David
No, you can't have it!