Book a Demo

Author Topic: link to diagram note programmatically  (Read 5606 times)

E.Eckstein

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
link to diagram note programmatically
« on: August 05, 2015, 11:30:32 pm »
Hey dudes and dudines  ::)

In EA you have in the context menu of an note which you place in an diagram the option "Advanced -> Link to diagram note".

First thing I like to know: Is it possible to create this link in an addin?

Second thing: Did somebody notice the synconisation will only work if you edit the diagram note in the properties window? If i change the note with the note-window in EA (Ctrl + Shift + 1) it will be changed in the diagram-properties window, when I open it, but the note won't be updated.

Regards,
Eric

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: link to diagram note programmatically
« Reply #1 on: August 06, 2015, 12:08:57 am »
a) Yes, you can. I posted the answer here: http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1438276146/1#1

b) You might wish to report a bug (link bottom right of this page). But EA is full of those inconsistencies.

q.
« Last Edit: August 06, 2015, 12:10:31 am by qwerty »

E.Eckstein

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: link to diagram note programmatically
« Reply #2 on: August 06, 2015, 04:46:08 pm »
Quote
The note element has PDATA4 set to idref<n>=<m>; where <n> is a consecutive number starting at 1 and <m> is the Connector_ID of the linked connector.
I guess this is what you mean - I am not sure if I understand this as an answer.

In EA User Guide I found the attribute "MiscData" which is described like this:
Quote
This low-level property provides information about the contents of the PDatax fields.
These database fields are not documented, and developers must gain understanding of these fields through their own endeavors to use this property.
MiscData is zero based, therefore:
· MiscData(0) corresponds to PData1
· MiscData(1) to PData2
and so on.

So if i set PData4 by MiscData(4)  to the value "idref<1>=<Diagram_ID>; the link will be established?
Code: [Select]
Diagram d;
Element note;
note.MiscData[4] = String.Format("idref<1>=<{0}>", d.DiagramID);

Regards,
Eric

Edit: Because I have issues doing so, (MiscData[4] is readonly)  :-/
« Last Edit: August 06, 2015, 04:57:19 pm by ericeckstein »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: link to diagram note programmatically
« Reply #3 on: August 06, 2015, 04:53:55 pm »
Quote
So if i set PData4 by MiscData(4)  to the value "idref<1>=<Diagram_ID>; the link will be established?
Code: [Select]
Diagram d;
MiscData(4) = String.Format("idref<1>=<{0}>", d.DiagramID);

Except MiscData is read-only. Which is why qwerty suggests (but Sparx don't officially support) that you use direct database manipulation. At your own risk (take backups!)
The Sparx Team
[email protected]

E.Eckstein

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: link to diagram note programmatically
« Reply #4 on: August 06, 2015, 05:02:29 pm »
Hi KP,

okay. Thanks for your answer. Well I did some internal logic which provides locks onto the note element and updates it, if the diagram gets changed (diagram note is written to the note element and this one is locked afterwards again).

I refuse to do direct writing to the db, since we use a oracle db which is used by quite many people and I preffer not to mess things up in there.

However, thanks for your both replies.
Eric

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: link to diagram note programmatically
« Reply #5 on: August 06, 2015, 05:35:41 pm »
Quote
Hi KP,

okay. Thanks for your answer. Well I did some internal logic which provides locks onto the note element and updates it, if the diagram gets changed (diagram note is written to the note element and this one is locked afterwards again).

I refuse to do direct writing to the db, since we use a oracle db which is used by quite many people and I preffer not to mess things up in there.

However, thanks for your both replies.
Eric
Well you can use the API to mess things up almost as easily as direct DB manipulation...

I've found you sometimes can't get away with just the API since it isn't "covering".

I'm led to believe that the Sparxians don't use the API for their internal stuff - they have their own interfaces.

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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: link to diagram note programmatically
« Reply #6 on: August 06, 2015, 05:56:26 pm »
In case you change your mind
Code: [Select]
Respository.Execute("UPDATE t_object SET PDATA4='idref1=" + connector.ConnectorID + ";' WHERE Object_ID=" + note.ElementID) would be an example to set a link.

q.
« Last Edit: August 06, 2015, 05:59:50 pm by qwerty »

E.Eckstein

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: link to diagram note programmatically
« Reply #7 on: August 06, 2015, 08:56:28 pm »
Hi qwerty,

thank you for the sample code. I'll keep this in mind if other request are going to be made.

Thanks a lot you guys,

Regards,
Eric