Search in sources :

Example 6 with ModelAccessor

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

the class DeleteServices method deleteExecution.

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

Example 7 with ModelAccessor

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

the class TaskUtils method deleteTaskUseTaskEdge.

/**
 * This service is used to remove the "use" relationship between 2 abstract
 * tasks and remove the corresponding elements on the using task's Actions
 * Plan when needed
 *
 * @param usingTask
 *            Source AbstractTask instance of the relationship
 * @param usedTask
 *            Target AbstractTask instance of the relationship
 */
public void deleteTaskUseTaskEdge(AbstractTask usingTask, AbstractTask usedTask) {
    Session session = SessionManager.INSTANCE.getSession(usingTask);
    ModelAccessor modelAccessor = session.getModelAccessor();
    // Get all potentially concerned used Tasks
    List<Task> usedTasks = new ArrayList<Task>();
    if (usedTask instanceof Task) {
        usedTasks.add((Task) usedTask);
    } else {
        usedTasks.addAll(getAllUsedTasks((TasksGroup) usedTask));
    }
    // Check if the using "task" is a Task or a Group
    if (usingTask instanceof Task) {
        for (Task realUsedTask : usedTasks) {
            deleteUseRelationship((Task) usingTask, realUsedTask, session, modelAccessor);
        }
    } else {
        for (Task realUsedTask : usedTasks) {
            for (Task realUsingTask : getTasksFromGroupUsingTask((TasksGroup) usingTask, realUsedTask)) {
                deleteUseRelationship(realUsingTask, realUsedTask, session, modelAccessor);
            }
        }
    }
}
Also used : AbstractTask(org.obeonetwork.graal.AbstractTask) Task(org.obeonetwork.graal.Task) TasksGroup(org.obeonetwork.graal.TasksGroup) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) ArrayList(java.util.ArrayList) Session(org.eclipse.sirius.business.api.session.Session)

Example 8 with ModelAccessor

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

the class DeleteInteractionHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final Interaction interaction = extractInteraction(event);
    if (interaction == null) {
        return null;
    }
    boolean confirm = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Delete interaction", "Delete the selected interaction ?");
    if (confirm) {
        final Session session = SessionManager.INSTANCE.getSession(interaction);
        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(interaction, session);
                // Delete representations
                for (DRepresentationDescriptor representationDescriptor : representationDescriptors) {
                    closeEditor(session, representationDescriptor.getRepresentation());
                    DialectManager.INSTANCE.deleteRepresentation(representationDescriptor, session);
                }
                // Delete interaction
                modelAccessor.eDelete(interaction, semanticCrossReferencer);
            }
        });
    }
    return null;
}
Also used : ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) Interaction(org.obeonetwork.dsl.interaction.Interaction) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) Collection(java.util.Collection) DRepresentationDescriptor(org.eclipse.sirius.viewpoint.DRepresentationDescriptor) Session(org.eclipse.sirius.business.api.session.Session) IEditingSession(org.eclipse.sirius.ui.business.api.session.IEditingSession)

Example 9 with ModelAccessor

use of org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor 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;
}
Also used : ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) StateMachine(org.obeonetwork.dsl.statemachine.StateMachine) ModelAccessor(org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor) Collection(java.util.Collection) DRepresentationDescriptor(org.eclipse.sirius.viewpoint.DRepresentationDescriptor) Session(org.eclipse.sirius.business.api.session.Session) IEditingSession(org.eclipse.sirius.ui.business.api.session.IEditingSession)

Example 10 with ModelAccessor

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

the class DocumentationLinkImpl method delete.

/**
 * {@inheritDoc}
 * @see org.obeonetwork.tools.doc.core.DocumentationLink#delete()
 */
public void delete() {
    Session session = SessionManager.INSTANCE.getSession(annotation);
    if (session != null) {
        ModelAccessor vpModelAccessor = session.getModelAccessor();
        vpModelAccessor.eDelete(annotation, session.getSemanticCrossReferencer(), new EReferencePredicate() {

            public boolean apply(EReference reference) {
                return DSemanticDecorator.class.isAssignableFrom(reference.getContainerClass());
            }
        });
    } else {
        EcoreUtil.delete(annotation);
    }
    // $NON-NLS-1$
    name = "";
    // $NON-NLS-1$
    value = "";
    annotation = null;
}
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)

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