Search in sources :

Example 1 with BindingElement

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);
    }
}
Also used : ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) BindingElement(org.obeonetwork.dsl.environment.BindingElement) BindingReference(org.obeonetwork.dsl.environment.BindingReference) Session(org.eclipse.sirius.business.api.session.Session)

Example 2 with BindingElement

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);
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) BindingElementPropertiesEditionPart(org.obeonetwork.dsl.environment.parts.BindingElementPropertiesEditionPart)

Example 3 with BindingElement

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;
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) BoundableElement(org.obeonetwork.dsl.environment.BoundableElement)

Example 4 with BindingElement

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);
    }
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) BindingReference(org.obeonetwork.dsl.environment.BindingReference)

Example 5 with BindingElement

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;
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) EObject(org.eclipse.emf.ecore.EObject) BoundableElement(org.obeonetwork.dsl.environment.BoundableElement)

Aggregations

BindingElement (org.obeonetwork.dsl.environment.BindingElement)7 BindingReference (org.obeonetwork.dsl.environment.BindingReference)3 BoundableElement (org.obeonetwork.dsl.environment.BoundableElement)3 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 ECrossReferenceAdapter (org.eclipse.emf.ecore.util.ECrossReferenceAdapter)1 Session (org.eclipse.sirius.business.api.session.Session)1 DBindingEdge (org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge)1 DBoundElement (org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)1 BindingElementPropertiesEditionPart (org.obeonetwork.dsl.environment.parts.BindingElementPropertiesEditionPart)1