assertNotNull(peShape);
assertNotNull(linked.eContainer());
//Find Literal
Shape literalShape = null;
for (Shape s : d.getChildren()) {
linked = ls.getBusinessObjectForLinkedPictogramElement(s);
if (linked instanceof ConnectionInitialization) {
ConnectionInitialization ci = (ConnectionInitialization) linked;
EObject e = Utility.getChildLiteral(ci);
if (Utility.getLiteralValue(
Utility.getChildLiteral(ci)).equals("\"Connection\"")) {
literalShape = s;
break;
}
}
}
assertNotNull(literalShape);
assertNotNull(linked.eContainer());
assertTrue(literalShape.getAnchors().size() > 0);
ProcessingElementParameter param = null;
Shape paramShape = null;
for (Shape s :peShape.getChildren()) {
linked = ls.getBusinessObjectForLinkedPictogramElement(s);
if (linked instanceof ProcessingElementParameter) {
ProcessingElementParameter paramTmp =
(ProcessingElementParameter) linked;
if (paramTmp.getName().equals("input")) {
param = paramTmp;
paramShape = s;
break;
}
}
}
assertNotNull(param);
assertNotNull(paramShape);
assertTrue(paramShape.getAnchors().size() > 0);
final Shape fLiteralShape = literalShape;
final Shape fParamShape = paramShape;
syncExec((new VoidResult() {
@Override
public void run() {
de.getEditingDomain().getCommandStack().execute(
new RecordingCommand(de.getEditingDomain()) {
@Override
protected void doExecute() {
IDiagramTypeProvider dtp =
de.getDiagramTypeProvider();
IFeatureProvider fp = dtp.getFeatureProvider();
ICreateConnectionFeature cf =
fp.getCreateConnectionFeatures()[0];
CreateConnectionContext cc =
new CreateConnectionContext();
cc.setSourceAnchor(
fLiteralShape.getAnchors().get(0));
cc.setSourcePictogramElement(fLiteralShape);
cc.setTargetAnchor(
fParamShape.getAnchors().get(0));
cc.setTargetPictogramElement(fParamShape);
assertTrue(cf.canCreate(cc));
cf.execute(cc);
}
});