Author Topic: Hide connectors from an Add-In  (Read 5074 times)

MeryemAdb

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Hide connectors from an Add-In
« on: November 06, 2014, 03:09:24 am »
Hello,

I am trying to create a new diagram with automatically generated connectors that are specific to the diagram.  So I'd like to do three things:
  • when I create the diagram, I want to show on it only the connectors that are relevant --> so I set the values of IsHidden to true for the other DiagramLinks. It works, the other connectors do not appear on my new diagram.
  • when I create the diagram, I do not want my new connectors to appear elsewhere --> at the end of the function to create the diagram, I do a SQL query to find all diagrams on which the connectors appear and set the IHidden attribute to true. Unfortunately, the query only returns my new diagram, while the classes on both ends of my new connector appears on another diagram and therefore the connector will at one point appear on it too.
  • I want to make sure that whenever a diagram is modified, my generated connectors do not appear --> I use EA_OnPostNewDiagramObject to check that no connector with the right combination of stereotype and tagged value is on the diagram, otherwise I hide it.  When I reload the current diagram, the connectors are indeed hidden but EA crashes.

I am sure all my problems come from the fact that my model is not correctly "refreshed" when I try to look for the diagrams with my connectors or when I try to reload the current diagram, but I have no idea how to refresh it properly.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hide connectors from an Add-In
« Reply #1 on: November 06, 2014, 04:32:57 am »
Such changes are only persistent if the according diagram has been saved. Else the changes dwell somewhere in memory.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hide connectors from an Add-In
« Reply #2 on: November 07, 2014, 06:01:19 pm »
There is an option somewhere to hide your relationship on all but the current diagram.
That is probably what you want to use.

The problem with your current approach is that the DiagramLink records are only stored in the database the moment something is changed. (e.g you hide the relationship)
DiagramLinks with the default settings are not persisted.
So you can't use an SQL query to find all DiagramLinks because they are not stored in the database.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hide connectors from an Add-In
« Reply #3 on: November 07, 2014, 06:38:18 pm »
Quote
There is an option somewhere to hide your relationship on all but the current diagram.
This is only available in the context of a single connector (Visibility/Hide in other....) and is executed just once. So that's not some kind of global option.

q.
« Last Edit: November 07, 2014, 06:38:33 pm by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hide connectors from an Add-In
« Reply #4 on: November 07, 2014, 07:40:45 pm »
Quote
Quote
There is an option somewhere to hide your relationship on all but the current diagram.
This is only available in the context of a single connector (Visibility/Hide in other....) and is executed just once. So that's not some kind of global option.

q.
Yes I know, but if he executes that for each relationship he creates then that would do the job wouldn't it?

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hide connectors from an Add-In
« Reply #5 on: November 07, 2014, 08:57:24 pm »
I know that you know ;D But eventually the OP doesn't.

q.

MeryemAdb

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Hide connectors from an Add-In
« Reply #6 on: November 07, 2014, 09:11:27 pm »
I suppose I would have guessed that  :) What I have not guessed (yet ?) is how to do it from my add-in.

If a query to find the diagram links does not work, will a query to find all diagrams on which the elements on both ends of the connector be a way to achieve what I want ?

By the way, that's "she".

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hide connectors from an Add-In
« Reply #7 on: November 07, 2014, 09:19:03 pm »
Quote
I suppose I would have guessed that  :) What I have not guessed (yet ?) is how to do it from my add-in.

If a query to find the diagram links does not work, will a query to find all diagrams on which the elements on both ends of the connector be a way to achieve what I want ?

By the way, that's "she".
I don't know exactly how to to it. If I were you I would try to figure out how EA does it.
In the best case it is some kind of indicator on the relation (look for stuff in Style, or StyleEx type of fields), worst case it creates all the diagramlinks for all diagrams and hides the relation on that diagram.

Geert

PS. Sorry for the he/she mixup  :D

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Hide connectors from an Add-In
« Reply #8 on: November 07, 2014, 11:23:29 pm »
It's quite tricky. If an element is added to an diagram EA automatically renders all connectors. If you add a new connector you can catch the OnPostNewConnector and find the diagrams where both end-elements appear (a not too difficult query can do). Now you need to add the suppression link to all those diagrams.

Honestly, I think that the idea is simply (how to say it polite?) nonsense. I remember someone else having asked for the same. There might be domains where this is useful, but if you add a new connector and don't see it in diagrams you're taking yourself a clear sight on what the element means (which connections it has). From my POV the hiding of connectors is something you should do as exception (as EA does), not as a rule.

q.

MeryemAdb

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Hide connectors from an Add-In
« Reply #9 on: November 07, 2014, 11:34:42 pm »
No problem, you could not guess.

I did what I suggested earlier, that is to say find all diagrams on which the classes on each side of the connector appear, then parse the diagramlinks and hide the one representing my connector. This is not an elegant or optimal solution, but at least it works.

Fo Qwerty, I understand your point of view, but I think my case is an exception. I have a method on how to model use cases, in particular restricting on which diagram(s) each information can appear. However, I want to create some more diagrams for communication purposes, and on those diagrams I want to show some relations that are only implicit with my method (for example, that an element is a sub-element of another). I only create new connectors so that the conceptual link between elements is displayed on the diagram, but they do not add any information, that is why they are hidden except on the diagram for which they were created.