Search in sources :

Example 1 with ModelAccessor

use of org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor in project InformationSystem by ObeoNetwork.

the class DeleteUtils method delete.

public static void delete(EObject object, Session session, ModelAccessor modelAccessor) {
    Session vpSession = session;
    ModelAccessor vpModelAccessor = modelAccessor;
    if (vpSession == null) {
        vpSession = SessionManager.INSTANCE.getSession(object);
    }
    if (vpSession != null) {
        if (vpModelAccessor == null) {
            vpModelAccessor = vpSession.getModelAccessor();
        }
        if (vpModelAccessor != null) {
            vpModelAccessor.eDelete(object, vpSession.getSemanticCrossReferencer(), new EReferencePredicate() {

                public boolean apply(EReference reference) {
                    return DSemanticDecorator.class.isAssignableFrom(reference.getContainerClass());
                }
            });
        }
    }
    // If this code is executed it means that either the session or the model accessor is null (probably the session)
    // We use EcoreUtil.delete() then
    EcoreUtil.delete(object, true);
}
Also used : DSemanticDecorator(org.eclipse.sirius.viewpoint.DSemanticDecorator) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) EReferencePredicate(org.eclipse.sirius.ext.emf.EReferencePredicate) EReference(org.eclipse.emf.ecore.EReference) Session(org.eclipse.sirius.business.api.session.Session)

Example 2 with ModelAccessor

use of org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor in project InformationSystem by ObeoNetwork.

the class DeleteServices method delete.

public static void delete(EObject object, Session session, ModelAccessor modelAccessor) {
    Session vpSession = session;
    ModelAccessor vpModelAccessor = modelAccessor;
    if (vpSession == null) {
        vpSession = SessionManager.INSTANCE.getSession(object);
    }
    if (vpModelAccessor == null) {
        vpModelAccessor = vpSession.getModelAccessor();
    }
    vpModelAccessor.eDelete(object, vpSession.getSemanticCrossReferencer(), new EReferencePredicate() {

        public boolean apply(EReference reference) {
            return DSemanticDecorator.class.isAssignableFrom(reference.getContainerClass());
        }
    });
}
Also used : DSemanticDecorator(org.eclipse.sirius.viewpoint.DSemanticDecorator) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) EReferencePredicate(org.eclipse.sirius.ext.emf.EReferencePredicate) EReference(org.eclipse.emf.ecore.EReference) Session(org.eclipse.sirius.business.api.session.Session)

Example 3 with ModelAccessor

use of org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor in project InformationSystem by ObeoNetwork.

the class DeleteServices method deleteMessage.

public void deleteMessage(Message message) {
    if (message == null) {
        return;
    }
    Session session = SessionManager.INSTANCE.getSession(message);
    ModelAccessor modelAccessor = session.getModelAccessor();
    deleteMessageEnd(message.getStartingEnd(), session, modelAccessor);
    deleteMessageEnd(message.getFinishingEnd(), session, modelAccessor);
    delete(message, session, modelAccessor);
}
Also used : ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) Session(org.eclipse.sirius.business.api.session.Session)

Example 4 with ModelAccessor

use of org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor in project InformationSystem by ObeoNetwork.

the class DeleteServices method deleteStateInvariant.

public void deleteStateInvariant(StateInvariant stateInvariant) {
    if (stateInvariant == null) {
        return;
    }
    Session session = SessionManager.INSTANCE.getSession(stateInvariant);
    ModelAccessor modelAccessor = session.getModelAccessor();
    delete(stateInvariant.getStartingEnd(), session, modelAccessor);
    delete(stateInvariant.getFinishingEnd(), session, modelAccessor);
    delete(stateInvariant, session, modelAccessor);
}
Also used : ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) Session(org.eclipse.sirius.business.api.session.Session)

Example 5 with ModelAccessor

use of org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor in project InformationSystem by ObeoNetwork.

the class DeleteServices method delete.

private void delete(Interaction inter, End startingEnd, End finishingEnd, boolean deleteFinishingEnd, EList<Participant> coverage) {
    Set<EObject> toDelete = new HashSet<EObject>();
    boolean inside = false;
    for (End end : inter.getEnds()) {
        if (end == startingEnd) {
            toDelete.add(end);
            toDelete.add(end.getOwner());
            inside = true;
        } else if (end == finishingEnd) {
            if (deleteFinishingEnd) {
                toDelete.add(end);
                toDelete.add(end.getOwner());
            }
            break;
        } else if (inside && InteractionServices.covers(end, coverage)) {
            toDelete.add(end);
            toDelete.add(end.getOwner());
        }
    }
    Session session = null;
    ModelAccessor modelAccessor = null;
    for (EObject obj : toDelete) {
        if (session == null) {
            session = SessionManager.INSTANCE.getSession(obj);
        }
        if (modelAccessor == null) {
            modelAccessor = session.getModelAccessor();
        }
        delete(obj, session, modelAccessor);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) End(org.obeonetwork.dsl.interaction.End) CompoundEnd(org.obeonetwork.dsl.interaction.CompoundEnd) HashSet(java.util.HashSet) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

Session (org.eclipse.sirius.business.api.session.Session)14 ModelAccessor (org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor)14 EReference (org.eclipse.emf.ecore.EReference)5 EReferencePredicate (org.eclipse.sirius.ext.emf.EReferencePredicate)5 DSemanticDecorator (org.eclipse.sirius.viewpoint.DSemanticDecorator)5 Collection (java.util.Collection)2 ECrossReferenceAdapter (org.eclipse.emf.ecore.util.ECrossReferenceAdapter)2 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)2 IEditingSession (org.eclipse.sirius.ui.business.api.session.IEditingSession)2 DRepresentationDescriptor (org.eclipse.sirius.viewpoint.DRepresentationDescriptor)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 EObject (org.eclipse.emf.ecore.EObject)1 CompoundEnd (org.obeonetwork.dsl.interaction.CompoundEnd)1 End (org.obeonetwork.dsl.interaction.End)1 Interaction (org.obeonetwork.dsl.interaction.Interaction)1 StateMachine (org.obeonetwork.dsl.statemachine.StateMachine)1 AbstractTask (org.obeonetwork.graal.AbstractTask)1 Task (org.obeonetwork.graal.Task)1