Book a Demo

Author Topic: Hide connector labels through automation  (Read 6238 times)

MichaelHanson

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
  • EA is the best
    • View Profile
Hide connector labels through automation
« on: September 25, 2007, 02:42:53 am »
How do I hide labels on DiagramLinks or Connectors in the EA automation model?

I was half expecting a Labels collection on a DiagramLink or Connector, but can't find one, and nothing else obvious appears to do the job.
Mike Hanson
Microsoft Technology Specialist

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Hide connector labels through automation
« Reply #1 on: September 25, 2007, 03:00:08 am »
Michael,

You'll need to look through the properties of the Connector object behind the diagram link.

This is not very intuitive. I suggest you open a copy of your project in MS Access (or transfer the project to your local DBMS and open the copy there) and browse through the fields and values in the t_connector table. When you're comfortable with these you should be OK.

There might also be a tie-in with the (somewhat cryptic) fields in t_diagramlinks, that help you figure out whether a label is shown on any particular diagram. You'll have to decode these for yourself.

Sparx: If anyone is listening, this is an area where the SDK section of the documentation could use improvement.

David
No, you can't have it!

MichaelHanson

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
  • EA is the best
    • View Profile
Re: Hide connector labels through automation
« Reply #2 on: September 25, 2007, 03:05:53 am »
Thanks for the prompt response David, I literally just found the solution.

Each DiagramLink has a Geometry property which looks like similar to a JSON string.  It is a semicolon delimited string with fields for the actual connector geometry followed by the geometry and visibility state of each label.

I am about to go assign one of my team to the most menial task I can find, he requested a feature for my add-in to hide all labels on selected links, so now I have to go write the code to deserialise this string into some Label objects then write them back to the string property.  ;)
Mike Hanson
Microsoft Technology Specialist

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Hide connector labels through automation
« Reply #3 on: September 25, 2007, 03:09:46 am »
Yep, that's it.

Just remember that a lot of the tokens in the string just tell you where the property text will be displayed. You still have to look up the actual property from the connector.

David
No, you can't have it!

MichaelHanson

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
  • EA is the best
    • View Profile
Re: Hide connector labels through automation
« Reply #4 on: September 25, 2007, 03:11:59 am »
At this point I am only interested in hiding the labels, but I understand what you mean.
Mike Hanson
Microsoft Technology Specialist

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Hide connector labels through automation
« Reply #5 on: September 25, 2007, 03:20:30 am »
...;Lxx=;...

That should do it.
No, you can't have it!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Hide connector labels through automation
« Reply #6 on: September 25, 2007, 03:26:26 am »
Michael,

BTW, there is an undocumented trap here.

[NB: This is based on behavior I noticed and addressed some time ago; I cannot confirm if EA has changed in this area.]

EA does not always create a record in t_diagramlinks, even if the connector is displayed. Sometimes when elements on both (or all, depending on the connector geometry) ends of the connector  are on the diagram, EA just adds the label on its own. Generally, if you've explicitly shaped the connector geometry or something the record is created, but otherwise it could go either way. Links created through automation are particularly vulnerable to this. When this happens you'll find that the label visibility is not under your control.

So...

Sometimes you need to explicitly create a DiagramLink object. They you'll have to tweak the record in t_diagramlinks yourself. Only after that will the labels act the way you want.

David
No, you can't have it!

MichaelHanson

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
  • EA is the best
    • View Profile
Re: Hide connector labels through automation
« Reply #7 on: September 25, 2007, 03:29:42 am »
Thanks for that last pointer.
Mike Hanson
Microsoft Technology Specialist

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Hide connector labels through automation
« Reply #8 on: September 25, 2007, 04:56:43 am »
Hi Michael,

Further to what David said, we also noted that EA didn't always create t_diagramlinks entries correctly and that caused problems with round-tripping and rendering of links in diagrams.

I think since at least v7 and probably a little before, EA now correctly creates those entries - that is, for each link in the diagram there will now be a t_diagramlinks entry.  However, you'll need Sparx to confirm that for sure.

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

MichaelHanson

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
  • EA is the best
    • View Profile
Re: Hide connector labels through automation
« Reply #9 on: September 25, 2007, 04:58:26 am »
Thanks Paolo
Mike Hanson
Microsoft Technology Specialist