Search in sources :

Example 11 with End

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

the class InteractionServices method computeExecutionDepth.

/**
 * Computes the depth of an Execution. If the EObject is not an Execution,
 * this method returns 0.
 *
 * @param eobject the EObject to find the depth if it is an Execution
 * @param nbOfColors Total number of colors
 * @return the depth if it is an Execution.
 */
public int computeExecutionDepth(EObject eobject, int nbOfColors) {
    int executionDepth = 0;
    if (eobject instanceof Execution) {
        Execution currentExecution = (Execution) eobject;
        Participant currentLifeline = currentExecution.getOwner();
        End start = currentExecution.getStartingEnd();
        EObject eContainer = start.eContainer();
        EList<EObject> eContents = eContainer.eContents();
        int startIndex = eContents.lastIndexOf(start);
        List<EObject> contents = eContents.subList(0, startIndex);
        for (EObject obj : contents) {
            if (obj instanceof End) {
                End end = (End) obj;
                if (end.isExecutionEnd()) {
                    Execution execution = end.getExecution();
                    if (currentLifeline != null && execution != null && currentLifeline.equals(execution.getOwner())) {
                        if (execution.getStartingEnd().equals(end)) {
                            executionDepth++;
                        } else if (execution.getFinishingEnd().equals(end)) {
                            executionDepth--;
                        }
                    }
                }
            }
        }
    }
    return getColorDepth(executionDepth, nbOfColors);
}
Also used : Execution(org.obeonetwork.dsl.interaction.Execution) Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End)

Example 12 with End

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

the class InteractionServices method computePredecessorForOperand.

public Operand computePredecessorForOperand(Operand operand) {
    // Get the preceding end
    List<End> precedingEnds = getPrecedingEnds(operand.getStartingEnd());
    // The predecessor is the last Operand found amongst the preceding operands for the same combined fragment
    Operand predecessor = null;
    for (End end : precedingEnds) {
        if (end.isOperandEnd() && end.isStartingEnd() && operand.eContainer().equals(end.getOperand().eContainer())) {
            predecessor = end.getOperand();
        }
    }
    return predecessor;
}
Also used : Operand(org.obeonetwork.dsl.interaction.Operand) End(org.obeonetwork.dsl.interaction.End)

Example 13 with End

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

the class InteractionServices method computePredecessorForCombinedFragment.

public CombinedFragment computePredecessorForCombinedFragment(CombinedFragment combinedFragment) {
    // Get the preceding end
    List<End> precedingEnds = getPrecedingEnds(combinedFragment.getStartingEnd());
    // The predecessor is the last CombinedFragment found amongst the preceding combined fragments
    CombinedFragment predecessor = null;
    for (End end : precedingEnds) {
        if (end.isCombinedFragmentEnd() && end.isStartingEnd()) {
            predecessor = end.getCombinedFragment();
        }
    }
    return predecessor;
}
Also used : End(org.obeonetwork.dsl.interaction.End) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Example 14 with End

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

the class InteractionServices method getPrecedingEnds.

private List<End> getPrecedingEnds(End end) {
    List<End> result = new ArrayList<End>();
    Interaction interaction = (Interaction) end.eContainer();
    for (End siblingEnd : interaction.getEnds()) {
        if (!end.equals(siblingEnd)) {
            result.add(siblingEnd);
        } else {
            return result;
        }
    }
    return result;
}
Also used : Interaction(org.obeonetwork.dsl.interaction.Interaction) ArrayList(java.util.ArrayList) End(org.obeonetwork.dsl.interaction.End)

Example 15 with End

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

the class OperandImpl method getFinishingEnd.

/**
 * @generated NOT
 */
@Override
public End getFinishingEnd() {
    End result = null;
    EObject eContainer = eContainer();
    if (eContainer instanceof CombinedFragment) {
        CombinedFragment cf = (CombinedFragment) eContainer;
        result = cf.getFinishingEnd();
        Operand prev = null;
        for (Operand op : cf.getOwnedOperands()) {
            if (this.equals(prev)) {
                result = op.getStartingEnd();
                break;
            } else {
                prev = op;
            }
        }
    }
    return result;
}
Also used : Operand(org.obeonetwork.dsl.interaction.Operand) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Aggregations

End (org.obeonetwork.dsl.interaction.End)15 EObject (org.eclipse.emf.ecore.EObject)8 CombinedFragment (org.obeonetwork.dsl.interaction.CombinedFragment)4 Participant (org.obeonetwork.dsl.interaction.Participant)4 Operand (org.obeonetwork.dsl.interaction.Operand)3 ArrayList (java.util.ArrayList)2 CompoundEnd (org.obeonetwork.dsl.interaction.CompoundEnd)2 DestroyParticipantMessage (org.obeonetwork.dsl.interaction.DestroyParticipantMessage)2 Execution (org.obeonetwork.dsl.interaction.Execution)2 Interaction (org.obeonetwork.dsl.interaction.Interaction)2 Message (org.obeonetwork.dsl.interaction.Message)2 HashSet (java.util.HashSet)1 Stack (java.util.Stack)1 Session (org.eclipse.sirius.business.api.session.Session)1 ModelAccessor (org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor)1 InteractionUse (org.obeonetwork.dsl.interaction.InteractionUse)1 StateInvariant (org.obeonetwork.dsl.interaction.StateInvariant)1