Search in sources :

Example 1 with DNodeList

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();
    }
}
Also used : DNodeList(org.eclipse.sirius.diagram.DNodeList) CompositeDataType(org.palladiosimulator.pcm.repository.CompositeDataType) DataType(org.palladiosimulator.pcm.repository.DataType) CompositeDataType(org.palladiosimulator.pcm.repository.CompositeDataType) InnerDeclaration(org.palladiosimulator.pcm.repository.InnerDeclaration)

Aggregations

DNodeList (org.eclipse.sirius.diagram.DNodeList)1 CompositeDataType (org.palladiosimulator.pcm.repository.CompositeDataType)1 DataType (org.palladiosimulator.pcm.repository.DataType)1 InnerDeclaration (org.palladiosimulator.pcm.repository.InnerDeclaration)1