use of org.eclipse.emf.ecore.util.ECrossReferenceAdapter in project InformationSystem by ObeoNetwork.
the class DeleteStateMachineHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
final StateMachine stateMachine = extractStateMachine(event);
if (stateMachine == null) {
return null;
}
boolean confirm = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Delete State Machine", "Delete the selected state machine ?");
if (confirm) {
final Session session = SessionManager.INSTANCE.getSession(stateMachine);
final ModelAccessor modelAccessor = session.getModelAccessor();
final ECrossReferenceAdapter semanticCrossReferencer = session.getSemanticCrossReferencer();
TransactionalEditingDomain transactionalEditingDomain = session.getTransactionalEditingDomain();
transactionalEditingDomain.getCommandStack().execute(new RecordingCommand(transactionalEditingDomain) {
@Override
protected void doExecute() {
// Retrieve associated representations
Collection<DRepresentationDescriptor> representationDescriptors = DialectManager.INSTANCE.getRepresentationDescriptors(stateMachine, session);
// Delete representations
for (DRepresentationDescriptor representationDescriptor : representationDescriptors) {
closeEditor(session, representationDescriptor.getRepresentation());
DialectManager.INSTANCE.deleteRepresentation(representationDescriptor, session);
}
// Delete StateMachine
modelAccessor.eDelete(stateMachine, semanticCrossReferencer);
}
});
}
return null;
}
use of org.eclipse.emf.ecore.util.ECrossReferenceAdapter in project InformationSystem by ObeoNetwork.
the class DeleteServices method deleteObeoDSMObject.
public void deleteObeoDSMObject(StructuredType type) {
// First we have to delete all references pointing towards this type
Session session = getSession(type);
ECrossReferenceAdapter crossReferencer = session.getSemanticCrossReferencer();
Collection<Setting> inverseReferences = crossReferencer.getInverseReferences(type, true);
for (Setting setting : inverseReferences) {
if (EnvironmentPackage.Literals.REFERENCE__REFERENCED_TYPE == setting.getEStructuralFeature()) {
delete((ObeoDSMObject) setting.getEObject(), session);
}
}
delete(type);
}
Aggregations