Search in sources :

Example 1 with BoundableElement

use of org.obeonetwork.dsl.environment.BoundableElement in project InformationSystem by ObeoNetwork.

the class CreateMappingCommand method getGlobalPath.

private List<BoundableElement> getGlobalPath(DBoundElement boundElement) {
    List<BoundableElement> globalPath = new ArrayList<BoundableElement>();
    DBoundElement current = boundElement;
    while (current != null) {
        if (current.getTarget() instanceof BoundableElement) {
            globalPath.add((BoundableElement) current.getTarget());
        }
        current = current.getParent();
    }
    Collections.reverse(globalPath);
    return globalPath;
}
Also used : BoundableElement(org.obeonetwork.dsl.environment.BoundableElement) ArrayList(java.util.ArrayList) DBoundElement(org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)

Example 2 with BoundableElement

use of org.obeonetwork.dsl.environment.BoundableElement in project InformationSystem by ObeoNetwork.

the class CinematicBindingServices method createCinematicBindingInfo.

public BindingInfo createCinematicBindingInfo(AbstractViewElement viewElement, EObject boundElement) {
    if (boundElement instanceof BoundableElement) {
        BoundableElement target = (BoundableElement) boundElement;
        BindingRegistry bindingRegistry = getGlobalBindingRegistry(viewElement);
        BindingInfo newBindingInfo = EnvironmentFactory.eINSTANCE.createBindingInfo();
        newBindingInfo.setLeft(viewElement);
        newBindingInfo.setRight(target);
        bindingRegistry.getBindingInfos().add(newBindingInfo);
        return newBindingInfo;
    }
    return null;
}
Also used : BoundableElement(org.obeonetwork.dsl.environment.BoundableElement) BindingRegistry(org.obeonetwork.dsl.environment.BindingRegistry) BindingInfo(org.obeonetwork.dsl.environment.BindingInfo)

Example 3 with BoundableElement

use of org.obeonetwork.dsl.environment.BoundableElement in project InformationSystem by ObeoNetwork.

the class CreateMappingCommand method getExistingBindingElement.

private BindingElement getExistingBindingElement(List<BoundableElement> globalPath) {
    for (BindingElement bindingElement : bindingInfo.getElements()) {
        List<BoundableElement> bindingElementPath = getGlobalPath(bindingElement);
        boolean elementFound = true;
        // Check if the paths are the same
        if (globalPath.size() == bindingElementPath.size()) {
            for (int i = 0; i < globalPath.size(); i++) {
                if (!EcoreUtil.equals(globalPath.get(i), bindingElementPath.get(i))) {
                    // We stop analysing this binding element as soon as there is a difference between the paths
                    elementFound = false;
                    break;
                }
            }
            if (elementFound) {
                return bindingElement;
            }
        }
    }
    return null;
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) BoundableElement(org.obeonetwork.dsl.environment.BoundableElement)

Example 4 with BoundableElement

use of org.obeonetwork.dsl.environment.BoundableElement in project InformationSystem by ObeoNetwork.

the class CreateMappingCommand method getOrCreateBindingElement.

private BindingElement getOrCreateBindingElement(DBoundElement boundElement) {
    EObject target = boundElement.getTarget();
    List<BoundableElement> globalPath = getGlobalPath(boundElement);
    BindingElement element = getExistingBindingElement(globalPath);
    if (element == null) {
        // We have to create a new BindingElement because no one exists
        final BindingElement bindingElement = EnvironmentFactory.eINSTANCE.createBindingElement();
        bindingElement.setBoundElement((BoundableElement) target);
        // We remove the last element in path because it's the same than bindingElement.getboundElement
        globalPath.remove(globalPath.size() - 1);
        bindingElement.getPathReferences().addAll(globalPath);
        bindingInfo.getElements().add(bindingElement);
        element = bindingElement;
    }
    return element;
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) EObject(org.eclipse.emf.ecore.EObject) BoundableElement(org.obeonetwork.dsl.environment.BoundableElement)

Example 5 with BoundableElement

use of org.obeonetwork.dsl.environment.BoundableElement in project InformationSystem by ObeoNetwork.

the class TreeDataProvider method getBoundElement.

private DBoundElement getBoundElement(DBoundElement root, List<BoundableElement> path) {
    List<BoundableElement> remainingPath = new ArrayList<BoundableElement>(path);
    BoundableElement currentTarget = remainingPath.remove(0);
    if (EcoreUtil.equals(currentTarget, root.getTarget())) {
        if (remainingPath.isEmpty()) {
            return root;
        } else {
            return getBoundElementWithinChildren((DBoundElement[]) contentProvider.getChildren(root), remainingPath);
        }
    }
    return null;
}
Also used : BoundableElement(org.obeonetwork.dsl.environment.BoundableElement) ArrayList(java.util.ArrayList) DBoundElement(org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)

Aggregations

BoundableElement (org.obeonetwork.dsl.environment.BoundableElement)6 ArrayList (java.util.ArrayList)3 BindingElement (org.obeonetwork.dsl.environment.BindingElement)3 DBoundElement (org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)3 EObject (org.eclipse.emf.ecore.EObject)1 BindingInfo (org.obeonetwork.dsl.environment.BindingInfo)1 BindingReference (org.obeonetwork.dsl.environment.BindingReference)1 BindingRegistry (org.obeonetwork.dsl.environment.BindingRegistry)1 DBindingEdge (org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge)1