Search in sources :

Example 1 with Interaction

use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.

the class DeleteServices method getCombinedFragmentsForParticipant.

private List<CombinedFragment> getCombinedFragmentsForParticipant(Participant participant) {
    Interaction interaction = (Interaction) participant.eContainer();
    List<CombinedFragment> result = new ArrayList<CombinedFragment>();
    for (CombinedFragment combinedFragment : interaction.getCombinedFragments()) {
        if (combinedFragment.getCoveredParticipants().size() == 1 && combinedFragment.getCoveredParticipants().contains(participant)) {
            result.add(combinedFragment);
        }
    }
    return result;
}
Also used : Interaction(org.obeonetwork.dsl.interaction.Interaction) ArrayList(java.util.ArrayList) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Example 2 with Interaction

use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.

the class DeleteServices method getStateInvariantsForParticipant.

private List<StateInvariant> getStateInvariantsForParticipant(Participant participant) {
    Interaction interaction = (Interaction) participant.eContainer();
    List<StateInvariant> result = new ArrayList<StateInvariant>();
    for (StateInvariant stateInvariant : interaction.getStateInvariants()) {
        if (participant.equals(stateInvariant.getOwner())) {
            result.add(stateInvariant);
        }
    }
    return result;
}
Also used : Interaction(org.obeonetwork.dsl.interaction.Interaction) ArrayList(java.util.ArrayList) StateInvariant(org.obeonetwork.dsl.interaction.StateInvariant)

Example 3 with Interaction

use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.

the class InteractionServices method computeContainmentStructure.

private List<EventContext> computeContainmentStructure(Participant owner) {
    if (!(owner.eContainer() instanceof Interaction)) {
        return Collections.emptyList();
    } else {
        Interaction interaction = (Interaction) owner.eContainer();
        Stack<EObject> ancestors = new Stack<EObject>();
        ancestors.push(owner);
        List<EventContext> result = new ArrayList<EventContext>();
        for (End end : interaction.getEnds()) {
            if (end.getContext() != owner) {
                continue;
            }
            if (end.isStartingEnd() && end.isExecutionEnd()) {
                result.add(new EventContext(ancestors.peek(), end.getExecution(), true, ancestors.size() + 1));
                ancestors.push(end.getExecution());
            }
            if (end.isStartingEnd() && end.isStateInvariantEnd()) {
                result.add(new EventContext(ancestors.peek(), end.getStateInvariant(), true, ancestors.size() + 1));
                ancestors.push(end.getStateInvariant());
            }
            if (end.isMessageEnd()) {
                Message msg = end.getMessage();
                if (msg != null) {
                    result.add(new EventContext(ancestors.peek(), end.getMessage(), end.equals(msg.getStartingEnd()), ancestors.size()));
                }
            }
            if (end.isFinishingEnd() && end.isExecutionEnd()) {
                ancestors.pop();
                result.add(new EventContext(ancestors.peek(), end.getExecution(), false, ancestors.size() + 1));
            }
            if (end.isFinishingEnd() && (end.isStateInvariantEnd())) {
                ancestors.pop();
                result.add(new EventContext(ancestors.peek(), end.getStateInvariant(), false, ancestors.size() + 1));
            }
        }
        return result;
    }
}
Also used : Message(org.obeonetwork.dsl.interaction.Message) DestroyParticipantMessage(org.obeonetwork.dsl.interaction.DestroyParticipantMessage) Interaction(org.obeonetwork.dsl.interaction.Interaction) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) End(org.obeonetwork.dsl.interaction.End) Stack(java.util.Stack)

Example 4 with Interaction

use of org.obeonetwork.dsl.interaction.Interaction in project InformationSystem by ObeoNetwork.

the class CreateSequenceDiagramAction method run.

@Override
public void run() {
    if (context == null) {
        return;
    }
    final Shell shell = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    Session session = SessionManager.INSTANCE.getSession(context);
    if (session == null) {
        return;
    }
    TransactionalEditingDomain editingDomain = session.getTransactionalEditingDomain();
    if (editingDomain == null) {
        return;
    }
    RecordingCommand cmd = new RecordingCommand(editingDomain, "Create Sequence diagram") {

        protected void doExecute() {
            // Get Session
            Session session = SessionManager.INSTANCE.getSession(context);
            if (session != null) {
                // Ask the user to provide a name for the diagram
                InputDialog dialog = new InputDialog(shell, "New representation", "New representation name", "new Sequence diagram", null);
                int buttonPressed = dialog.open();
                if (buttonPressed == InputDialog.OK) {
                    String diagramName = dialog.getValue();
                    // Create a new interaction instance
                    Interaction interaction = InteractionFactory.eINSTANCE.createInteraction();
                    interaction.setName(diagramName);
                    context.getBehaviours().add(interaction);
                    Collection<RepresentationDescription> descs = DialectManager.INSTANCE.getAvailableRepresentationDescriptions(session.getSelectedViewpoints(false), interaction);
                    for (RepresentationDescription desc : descs) {
                        Viewpoint viewpoint = (Viewpoint) desc.eContainer();
                        if (InteractionAnalysisContextMenuActionProvider.isInteractionViewpoint(viewpoint) && "Sequence Diagram".equals(desc.getName())) {
                            // Create the new diagram
                            if (DialectManager.INSTANCE.canCreate(interaction, desc)) {
                                DRepresentation sequenceDiagram = DialectManager.INSTANCE.createRepresentation(diagramName, interaction, desc, session, new NullProgressMonitor());
                                if (sequenceDiagram != null) {
                                    DialectUIManager.INSTANCE.openEditor(session, sequenceDiagram, new NullProgressMonitor());
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    editingDomain.getCommandStack().execute(cmd);
}
Also used : RepresentationDescription(org.eclipse.sirius.viewpoint.description.RepresentationDescription) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) InputDialog(org.eclipse.jface.dialogs.InputDialog) Interaction(org.obeonetwork.dsl.interaction.Interaction) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) Shell(org.eclipse.swt.widgets.Shell) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) DRepresentation(org.eclipse.sirius.viewpoint.DRepresentation) Session(org.eclipse.sirius.business.api.session.Session)

Example 5 with Interaction

use of org.obeonetwork.dsl.interaction.Interaction 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)

Aggregations

Interaction (org.obeonetwork.dsl.interaction.Interaction)13 ArrayList (java.util.ArrayList)9 EObject (org.eclipse.emf.ecore.EObject)4 Message (org.obeonetwork.dsl.interaction.Message)3 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)2 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)2 Session (org.eclipse.sirius.business.api.session.Session)2 DestroyParticipantMessage (org.obeonetwork.dsl.interaction.DestroyParticipantMessage)2 End (org.obeonetwork.dsl.interaction.End)2 InteractionUse (org.obeonetwork.dsl.interaction.InteractionUse)2 Collection (java.util.Collection)1 Stack (java.util.Stack)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ECrossReferenceAdapter (org.eclipse.emf.ecore.util.ECrossReferenceAdapter)1 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 ModelAccessor (org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor)1 IEditingSession (org.eclipse.sirius.ui.business.api.session.IEditingSession)1