Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to have a NodeLink which 'knows' what it is associated with (application data) (Read 3129 times)
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
How to have a NodeLink which 'knows' what it is associated with (application data)
Feb 18th, 2015 at 10:59am
Print Post  
When creating NodeLinks between (custom) Nodes on the diagram I associate some application data with the link (by catching the 'LinkCreated' event and running some custom code).

I can store this data via the (custom) Nodes being linked - but my problem is, if there are multiple links between the same two nodes, with different application data associated with them, how do I determine which link has which data associated with it.

I tried NodeLink.getId() but this always seems to return null.

Is there some 'id' type information on a node link that I can associate with the application data to allow me to match the links reliably with their associated application data?

Alternatively can I create a 'custom' NodeLink which would automatically be created (or I could set up to be created) when I link my nodes, which I could then store the application data?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to have a NodeLink which 'knows' what it is associated with (application data)
Reply #1 - Feb 18th, 2015 at 11:16am
Print Post  
You could associate the information with links instead of nodes, by setting links' Tag or Id properties. The control won't automatically set Id, both Tag and Id are used for storing custom data.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: How to have a NodeLink which 'knows' what it is associated with (application data)
Reply #2 - Feb 19th, 2015 at 12:10pm
Print Post  
Thanks - using the 'Tag' property works beautifully and is easy to serialize/deserialize to XML Smiley

(In the JavaDoc the detailed description for setId() on DiagramItem appears to be an exact copy of that for setTag() - is this correct?)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to have a NodeLink which 'knows' what it is associated with (application data)
Reply #3 - Feb 19th, 2015 at 12:32pm
Print Post  
Yes, the only difference between Id and Tag properties is the name. You could use them like custom-data-1 and custom-data-2 objects, but might prefer one over the other if it makes more sense for your application to treat the data as identifier or additional description semantically.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint