Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » can not save connection Feature
can not save connection Feature [message #1721860] Mon, 01 February 2016 06:24 Go to next message
Kailas Patil is currently offline Kailas PatilFriend
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

Re: can not save connection Feature [message #1721907 is a reply to message #1721860] Mon, 01 February 2016 16:00 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1894
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Kailas,

saving the connection instance can be done indirectly by adding it to the diagram and so to an EMF resource and saving the editor holding the resource. I see that you create the connection instance by delegating to the add feature, which should be fine. You should make sure that the new connection is added as child to your diagram inside the add feature.

HTH,
Michael
Previous Topic:Move diagram along with text
Next Topic:Integration of the KIELER Framework
Goto Forum:
  


Current Time: Fri Jun 22 23:14:56 GMT 2018

Powered by FUDForum. Page generated in 0.01186 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top