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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations