Search in sources :

Example 1 with BindingReference

use of org.obeonetwork.dsl.environment.BindingReference 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 BindingReference

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

the class BindingReferenceItemProvider method getText.

/**
 * This returns the label text for the adapted class.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public String getText(Object object) {
    String label = " ";
    BindingReference bindingReference = (BindingReference) object;
    if (bindingReference.getLeft() != null && bindingReference.getLeft().getBoundElement() != null) {
        label += labelProvider.getText(bindingReference.getLeft().getBoundElement());
    } else {
        label += "undefined";
    }
    label += " - ";
    if (bindingReference.getRight() != null && bindingReference.getRight().getBoundElement() != null) {
        label += labelProvider.getText(bindingReference.getRight().getBoundElement());
    } else {
        label += "undefined";
    }
    return " ".equals(label) ? getString("_UI_BindingReference_type") : getString("_UI_BindingReference_type") + " " + label;
}
Also used : BindingReference(org.obeonetwork.dsl.environment.BindingReference)

Example 3 with BindingReference

use of org.obeonetwork.dsl.environment.BindingReference 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 4 with BindingReference

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

the class TreeDataProvider method computeData.

public void computeData() {
    edges = new ArrayList<DBindingEdge>();
    leftRoot = BindingdialectFactory.eINSTANCE.createDBoundElement();
    leftRoot.setTarget(bindingInfo.getLeft());
    rightRoot = BindingdialectFactory.eINSTANCE.createDBoundElement();
    rightRoot.setTarget(bindingInfo.getRight());
    for (BindingReference bindingReference : bindingInfo.getReferences()) {
        BindingElement leftBindingElement = bindingReference.getLeft();
        BindingElement rightBindingElement = bindingReference.getRight();
        List<BoundableElement> leftPathReferences = new ArrayList<BoundableElement>(leftBindingElement.getPathReferences());
        leftPathReferences.add(leftBindingElement.getBoundElement());
        DBoundElement leftBoundElement = getBoundElement(leftRoot, leftPathReferences);
        List<BoundableElement> rightPathReferences = new ArrayList<BoundableElement>(rightBindingElement.getPathReferences());
        rightPathReferences.add(rightBindingElement.getBoundElement());
        DBoundElement rightBoundElement = getBoundElement(rightRoot, rightPathReferences);
        DBindingEdge edge = BindingdialectFactory.eINSTANCE.createDBindingEdge();
        edge.setTarget(bindingReference);
        edge.setLeft(leftBoundElement);
        edge.setRight(rightBoundElement);
        edges.add(edge);
    }
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) BindingReference(org.obeonetwork.dsl.environment.BindingReference) BoundableElement(org.obeonetwork.dsl.environment.BoundableElement) ArrayList(java.util.ArrayList) DBindingEdge(org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge) DBoundElement(org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)

Example 5 with BindingReference

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

the class BindingReferenceBindingReferencePropertiesEditionComponent 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 BindingReference bindingReference = (BindingReference) elt;
        final BindingReferencePropertiesEditionPart bindingReferencePart = (BindingReferencePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.BindingReference.Properties.left)) {
            bindingReferencePart.initLeft(EEFUtils.choiceOfValues(bindingReference, EnvironmentPackage.eINSTANCE.getBindingReference_Left()), bindingReference.getLeft());
        }
        if (isAccessible(EnvironmentViewsRepository.BindingReference.Properties.right)) {
            bindingReferencePart.initRight(EEFUtils.choiceOfValues(bindingReference, EnvironmentPackage.eINSTANCE.getBindingReference_Right()), bindingReference.getRight());
        }
        if (isAccessible(EnvironmentViewsRepository.BindingReference.Properties.description))
            bindingReferencePart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, bindingReference.getDescription()));
    // init filters
    // Start of user code for additional businessfilters for left
    // End of user code
    // Start of user code for additional businessfilters for right
    // End of user code
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : BindingReference(org.obeonetwork.dsl.environment.BindingReference) BindingReferencePropertiesEditionPart(org.obeonetwork.dsl.environment.parts.BindingReferencePropertiesEditionPart)

Aggregations

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