use of org.obeonetwork.dsl.environment.BindingElement in project InformationSystem by ObeoNetwork.
the class DeleteMappingCommand method doExecute.
@Override
protected void doExecute() {
if (bindingEdge.getTarget() != null && bindingEdge.getTarget() instanceof BindingReference) {
BindingReference bindingReference = (BindingReference) bindingEdge.getTarget();
Session session = SessionManager.INSTANCE.getSession(bindingReference);
ECrossReferenceAdapter crossReferencer = session.getSemanticCrossReferencer();
BindingElement left = bindingReference.getLeft();
BindingElement right = bindingReference.getRight();
if (hasNoOtherReference(left)) {
// Delete the useless element
accessor.eDelete(left, crossReferencer);
}
if (hasNoOtherReference(right)) {
// Delete the useless element
accessor.eDelete(right, crossReferencer);
} else {
}
accessor.eDelete(bindingReference, crossReferencer);
accessor.eDelete(bindingEdge, crossReferencer);
bindingEdge.setLeft(null);
bindingEdge.setRight(null);
} else {
EcoreUtil.delete(bindingEdge);
bindingEdge.setLeft(null);
bindingEdge.setRight(null);
}
}
use of org.obeonetwork.dsl.environment.BindingElement in project InformationSystem by ObeoNetwork.
the class BindingElementBindingElementPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final BindingElement bindingElement = (BindingElement) elt;
final BindingElementPropertiesEditionPart bindingElementPart = (BindingElementPropertiesEditionPart) editingPart;
// init values
if (isAccessible(EnvironmentViewsRepository.BindingElement.Properties.boundElement)) {
bindingElementPart.initBoundElement(EEFUtils.choiceOfValues(bindingElement, EnvironmentPackage.eINSTANCE.getBindingElement_BoundElement()), bindingElement.getBoundElement());
}
if (isAccessible(EnvironmentViewsRepository.BindingElement.Properties.bindingExpression))
bindingElementPart.setBindingExpression(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, bindingElement.getBindingExpression()));
if (isAccessible(EnvironmentViewsRepository.BindingElement.Properties.description))
bindingElementPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, bindingElement.getDescription()));
// init filters
// Start of user code for additional businessfilters for boundElement
// End of user code
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.environment.BindingElement 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.BindingElement in project InformationSystem by ObeoNetwork.
the class CreateMappingCommand method doExecute.
@Override
protected void doExecute() {
final BindingElement leftBindingElement = getOrCreateBindingElement(leftBoundElement);
final BindingElement rightBindingElement = getOrCreateBindingElement(rightBoundElement);
if (!areAlreadyBound(leftBindingElement, rightBindingElement)) {
BindingReference bindingReference = EnvironmentFactory.eINSTANCE.createBindingReference();
bindingReference.setLeft(leftBindingElement);
bindingReference.setRight(rightBindingElement);
bindingInfo.getReferences().add(bindingReference);
edge = BindingdialectFactory.eINSTANCE.createDBindingEdge();
edge.setTarget(bindingReference);
edge.setLeft(leftBoundElement);
edge.setRight(rightBoundElement);
}
}
use of org.obeonetwork.dsl.environment.BindingElement 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;
}
Aggregations