can not save connection Feature [message #1721860] |
Mon, 01 February 2016 06:24 |
Kailas Patil Messages: 5 Registered: January 2016 |
Junior Member |
|
|
I create my new EMF model to save pictorial element, and connection, the pictorial element is save but connection is not save
this is my code for connection feature.
public class CreateConditionalFlowFeature extends AbstractCreateConnectionFeature {
String type;
public CreateConditionalFlowFeature(IFeatureProvider fp, String name, String description, String type) {
super(fp, name, description);
this.type = type;
}
public boolean canCreate(ICreateConnectionContext context) {
ComplianceModel source = getComplianceModel(context.getSourceAnchor());
ComplianceModel target = getComplianceModel(context.getTargetAnchor());
if (source == null || target == null) {
return false;
}
ActivityInfo sourceActivityInfo = (ActivityInfo) source.getActivityInfo();
ActivityInfo targetActivityInfo = (ActivityInfo) target.getActivityInfo();
int sourceOutboundLimit = sourceActivityInfo.getOutboundConnectionLimit();
int targetInboundLimit = targetActivityInfo.getInboundConnectionLimit();
if (source != null && target != null && source != target) {
if (sourceOutboundLimit == -1 && targetInboundLimit == -1) {
return true;
} else if (sourceOutboundLimit == -1 && targetInboundLimit == 0) {
return false;
} else if (sourceOutboundLimit == 0) {
return false;
}
}
return false;
}
public String getCreateImageId() {
return ImageProvider.CONDITIONALFLOW;
}
public boolean canStartConnection(ICreateConnectionContext context) {
ComplianceModel source = getComplianceModel(context.getSourceAnchor());
if (source != null) {
ActivityInfo sourceActivityInfo = (ActivityInfo) source.getActivityInfo();
if (sourceActivityInfo.getOutboundConnectionLimit() == 0) {
return false;
}
return true;
}
return false;
}
public Connection create(ICreateConnectionContext context) {
Connection newConnection = null;
ComplianceModel source = getComplianceModel(context.getSourceAnchor());
ComplianceModel target = getComplianceModel(context.getTargetAnchor());
if (source != null && target != null) {
ComplianceLink eReference = createLink(source, target);
AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(),
context.getTargetAnchor());
addContext.setNewObject(eReference);
newConnection = (Connection) getFeatureProvider().addIfPossible(addContext);
}
return newConnection;
}
private ComplianceModel getComplianceModel(Anchor anchor) {
if (anchor != null) {
Object obj = getBusinessObjectForPictogramElement(anchor.getParent());
if (obj instanceof ComplianceModel) {
return (ComplianceModel) obj;
}
}
return null;
}
private ComplianceLink createLink(ComplianceModel source, ComplianceModel target) {
ComplianceLink link = ComplianceWorkflowModelFactory.eINSTANCE.createComplianceLink();
link.setName("Conditional"); //$NON-NLS-1$
link.setSource(source);
link.setTarget(target);
link.setType("ConditionalFlow");
//source.setEStructuralFeatures().add(link);
return link;
}
}
so how could i save that connection,
[Updated on: Mon, 01 February 2016 06:25] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03111 seconds