use of org.eclipse.sirius.diagram.DNodeList in project Palladio-Editors-Sirius by PalladioSimulator.
the class ReconnectSourceOfContainsRelation method execute.
@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
CompositeDataType oldSource = (CompositeDataType) parameters.get("source");
CompositeDataType newSource = (CompositeDataType) parameters.get("target");
DNodeList otherEnd = (DNodeList) parameters.get("otherEnd");
DataType target = (DataType) otherEnd.getTarget();
InnerDeclaration innerDeclaration = (InnerDeclaration) parameters.get("instance");
EList<InnerDeclaration> newInnerDeclarations = newSource.getInnerDeclaration_CompositeDataType();
boolean found = false;
Iterator<InnerDeclaration> it = newInnerDeclarations.iterator();
while (it.hasNext()) {
InnerDeclaration current = (InnerDeclaration) it.next();
if (current.getDatatype_InnerDeclaration() != null && current.getDatatype_InnerDeclaration().equals(target))
found = true;
}
if (found) {
newInnerDeclarations.remove(innerDeclaration);
} else {
innerDeclaration.setDatatype_InnerDeclaration(target);
}
EList<InnerDeclaration> oldInnerDeclarations = oldSource.getInnerDeclaration_CompositeDataType();
it = oldInnerDeclarations.iterator();
while (it.hasNext()) {
InnerDeclaration current = (InnerDeclaration) it.next();
if (current.getDatatype_InnerDeclaration().equals(target))
it.remove();
}
}
Aggregations