}
@Override
public void init()
{
final Element element = getModelElement();
this.diagramEditor = (SapphireDiagramEditorPagePart)parent();
this.connectionDef = (IDiagramConnectionDef)super.definition();
this.propertyName = this.bindingDef.getProperty().content();
this.modelProperty = (ListProperty) element.property(this.propertyName).definition();
initConnPartListener();
this.templateListeners = new CopyOnWriteArraySet<DiagramConnectionTemplateListener>();
String endpt1PropStr = this.bindingDef.getEndpoint1().content().getProperty().content();
String endpt2PropStr = this.bindingDef.getEndpoint2().content().getProperty().content();
this.originalEndpoint2Path = new ModelPath(endpt2PropStr);
ElementType type = this.modelProperty.getType();
this.endpoint1Property = type.property(endpt1PropStr);
this.endpoint2Property = type.property(this.originalEndpoint2Path);
if (getConnectionType() == ConnectionType.OneToOne)
{
this.endpoint1Path = new ModelPath(endpt1PropStr);
this.endpoint2Path = new ModelPath(endpt2PropStr);
this.connListProperty = this.modelProperty;
}
else
{
ModelPath.PropertySegment head = (ModelPath.PropertySegment)this.originalEndpoint2Path.head();
PropertyDef prop = type.property(head.getPropertyName());
if (prop instanceof ListProperty)
{
this.endpoint1Path = new ModelPath("../" + endpt1PropStr);
this.endpoint2Path = this.originalEndpoint2Path.tail();
this.connListProperty = (ListProperty)prop;
}
else
{
throw new RuntimeException("Invaid Model Path:" + this.originalEndpoint2Path);
}
}
// initialize the connection parts
ElementList<?> list = element.property(this.modelProperty);
for( Element listEntryModelElement : list )
{
// check the type of connection: 1x1 connection versus 1xn connection
if (getConnectionType() == ConnectionType.OneToOne)
{