public Connection create(ICreateConnectionContext context) { Connection newConnection = null; A a1 = getAClass(context.getSourceAnchor()); B b1 = getBClass(context.getTargetAnchor()); if (a1 != null && b1 != null) { // create new business object a1.getBList.add(b1); // add connection for business object AddConnectionContext addContext = new AddConnectionContext(context.getSourceAnchor(), context .getTargetAnchor()); newConnection = (Connection) getFeatureProvider().addIfPossible(addContext); } return newConnection; }
public IAddFeature getAddFeature(IAddContext context){ if(context instanceof AddConnectionContext){ Object sourceObj = getBusinessObjectForPictogramElement(((AddConnectionContext) context).getSourceAnchor().getParent()); Object targetObj = getBusinessObjectForPictogramElement(((AddConnectionContext) context).getTargetAnchor().getParent()); if( //A <-> B connection (sourceObj instanceof A && targetObj instanceof B) || (targetObj instanceof B && sourceObj instanceof A) ){ return new Connection_AB_AddFeature(this); } } else { .... //Add shapes } }
interface IConnectionDefaultObject{ void onDelete(IDeleteConext); void onAdd(IAddContext); }