Creating custom connection bindings [message #1709277] |
Fri, 25 September 2015 10:39  |
Eclipse User |
|
|
|
I am attempting to create a connection binding for my diagram page and am having some trouble getting it to work. I am using the following code sample as my test case for now.
<application done='file_write'>
<instance component='file_read'>
<property name='filename' value='test.input'/>
<property name='granularity' value='4'/>
<property name='messageSize' value='16'/>
</instance>
<instance component='bias' connect='file_write'>
<property name='biasValue' value='0x01020304'/>
</instance>
<instance component='file_write'>
<property name='filename' value='test.outputwrong'/>
</instance>
<connection>
<port instance='file_read' name='out' xferrole='flowcontrol'/>
<port instance='bias' name='in'/>
</connection>
</application>
I have been able to create a custom DiagramConnectionPart and custom ConnectionService for the "connect" attribute of the instance elements following some guidance from this project - https://github.com/tomas-milata/jbosstools-javaee.
I am now trying to figure out how to make the connection element bindings. I know that the default connection bindings could work, but I'm not sure how to specify the endpoints because each endpoint ends up being its own port element in the list of ports associated with the connection. I have attempted to create custom parts like I did for the connect attribute, however connection elements and their ports know nothing about the instance nodes that I am attempting to connect.
Any suggestions would be greatly appreciated.
|
|
|
|
Re: Creating custom connection bindings [message #1709287 is a reply to message #1709283] |
Fri, 25 September 2015 11:58   |
Eclipse User |
|
|
|
I have been using the Map sample as a guide for developing my diagram editor and I did notice that the highway routes were very similar to what I was attempting to do. Where I get caught up is when I got to specify the endpoints because my Connection interface is
public interface Connection extends Element {
ElementType TYPE = new ElementType( Connection.class );
// *** Name ***
@XmlBinding(path = "@name")
@Label(standard = "Name")
ValueProperty PROP_NAME = new ValueProperty(TYPE, "Name");
Value<String> getName();
void setName(String value);
// *** Transport ***
@XmlBinding( path = "@transport" )
@Label( standard = "Transport" )
ValueProperty PROP_TRANSPORT = new ValueProperty( TYPE, "Transport" );
Value<String> getProperty();
void setProperty( String value );
// *** Ports ***
@Type( base = ConnectionPort.class )
@XmlListBinding( mappings = { @XmlListBinding.Mapping( element = "port", type = ConnectionPort.class ) } )
@Label( standard = "Ports" )
ListProperty PROP_PORTS = new ListProperty( TYPE, "Ports" );
ElementList<ConnectionPort> getPorts();
}
With the ConnectionPort interface as follows...
public interface ConnectionPort extends Element {
ElementType TYPE = new ElementType( ConnectionPort.class );
// *** Name ***
@XmlBinding(path = "@name")
@Label(standard = "Name")
@Required
ValueProperty PROP_NAME = new ValueProperty(TYPE, "Name");
Value<String> getName();
void setName(String value);
// *** Instance ***
@Reference( target = Instance.class )
@ElementReference(list = "/Instances", key = "Component")
@XmlBinding(path = "@instance")
@Label(standard = "Instance")
@Required
@MustExist
ValueProperty PROP_INSTANCE = new ValueProperty(TYPE, "Instance");
ReferenceValue<String, Instance> getInstance();
void setInstance(String value);
}
My connection binding looks like...
<connection-binding>
<connection-id>ConnectionElementConnection</connection-id>
<property>Connections</property>
<endpoint1>
<property>Ports</property>
<value>endpoint 1</value>
</endpoint1>
<endpoint2>
<property>Ports</property>
<value>endpoint2</value>
</endpoint2>
</connection-binding>
When I launch I get this exception...
java.lang.ClassCastException: org.eclipse.sapphire.ListProperty cannot be cast to org.eclipse.sapphire.ValueProperty. I am assuming this related to using the Port list property as the endpoint property. Is there a way I can restructure my interfaces or modify the property value inside the connection binding endpoints to allow this to work.
*** Update: No longer get the above exception because I was able to modify the connection binding endpoint property to be Ports/Instance, however now I get another exception - java.lang.IllegalArgumentException
at org.eclipse.sapphire.ElementImpl.property(ElementImpl.java:372).
[Updated on: Fri, 25 September 2015 12:14] by Moderator
|
|
|
|
|
|
|
Re: Creating custom connection bindings [message #1709634 is a reply to message #1709478] |
Tue, 29 September 2015 14:13  |
Eclipse User |
|
|
|
Thank you both for your responses. I ended up adding this connection type to my existing custom ConnectionService that I already had in place for the connect attribute. It is working as I expect and I was able to retain the schema, which is something I was not able to change.
|
|
|
Powered by
FUDForum. Page generated in 0.04239 seconds