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