setDataProperty for custom templates

i have different templates including tree in my diagram . I wanted to connect from red circle node ( this is tree) to black ( this is the custom template ). once the connection is made I needs to set a property to using setDataProperty to templates in my diagram like error:“red.” can you help me to achieve this?

Implement a “LinkDrawn” DiagramEvent listener. The e.subject will be the new Link, from which you can look at the Link.toNode and .toPort.