Search in sources :

Example 1 with Participant

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

the class InteractionServices method computeCombinedFragmentDepth.

/**
 * Compute the depth of a combined fragment. If the EObject if not a
 * combined fragment, this method return 0.
 *
 * @param eobject
 *            the EObject to find the depth if it is a combined fragment
 * @param nbOfColors Total number of colors
 * @return the depth if it is a combined fragment.
 */
public int computeCombinedFragmentDepth(EObject eobject, int nbOfColors) {
    int combinedFragmentDepth = 0;
    if (eobject instanceof CombinedFragment) {
        CombinedFragment currentCombinedFragment = (CombinedFragment) eobject;
        EList<Participant> coveredParticipants = currentCombinedFragment.getCoveredParticipants();
        End start = currentCombinedFragment.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.isCombinedFragmentEnd()) {
                    CombinedFragment combinedFragment = end.getCombinedFragment();
                    if (covers(end, coveredParticipants)) {
                        if (combinedFragment.getStartingEnd().equals(end)) {
                            combinedFragmentDepth++;
                        } else if (combinedFragment.getFinishingEnd().equals(end)) {
                            combinedFragmentDepth--;
                        }
                    }
                }
            }
        }
    }
    return getColorDepth(combinedFragmentDepth, nbOfColors);
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Example 2 with Participant

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

the class InteractionServices method getReceivingContext.

/**
 * Returns the semantic element corresponding to the target of a message.
 * This can be a participant, execution or an instance role.
 *
 * @param msg
 *            the message.
 * @return the semantic elements corresponding to the target of the message.
 */
public EObject getReceivingContext(Message msg) {
    End receivingEnd = msg.getFinishingEnd();
    if (receivingEnd != null) {
        Participant p = receivingEnd.getContext();
        List<EventContext> structure = computeContainmentStructure(p);
        for (EventContext ec : structure) {
            if (ec.getElement().equals(msg) && !ec.isStart()) {
                EObject parent = ec.getParent();
                if (parent != null) {
                    return parent;
                } else {
                    return p;
                }
            }
        }
    }
    return msg;
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End)

Example 3 with Participant

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

the class ParticipantParticipantPropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        editingPart.setContext(elt, allResource);
        final Participant participant = (Participant) elt;
        final ParticipantPropertiesEditionPart participantPart = (ParticipantPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(InteractionViewsRepository.Participant.Properties.name))
            participantPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, participant.getName()));
        if (isAccessible(InteractionViewsRepository.Participant.Properties.type)) {
            // init part
            typeSettings = new EObjectFlatComboSettings(participant, InteractionPackage.eINSTANCE.getParticipant_Type());
            participantPart.initType(typeSettings);
            // set the button mode
            participantPart.setTypeButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(InteractionViewsRepository.Participant.Properties.description))
            participantPart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, participant.getDescription()));
        if (isAccessible(InteractionViewsRepository.Participant.Properties.type)) {
            participantPart.addFilterToType(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof ObeoDSMObject);
                }
            });
        // Start of user code for additional businessfilters for type
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) ParticipantPropertiesEditionPart(org.obeonetwork.dsl.interaction.parts.ParticipantPropertiesEditionPart) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)

Example 4 with Participant

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

the class InteractionServices method getSendingContext.

/**
 * Returns the event end which represents the finishing of an operand. An
 * operand only has a starting end in the model. Its finishing end must be
 * inferred from the context. If the operand is the last operand in the
 * Combined Fragment, it finishes with the end of the CF. Otherwise it
 * finished when the next operand starts.
 *
 * @param operand
 *            the operand.
 * @return the event end which represents the finishing of the operand.
 */
// public AbstractEnd getFinishingEnd(Operand operand) {
// AbstractEnd result = null;
// EObject eContainer = operand.eContainer();
// 
// if (eContainer instanceof CombinedFragment) {
// CombinedFragment cf = (CombinedFragment) eContainer;
// result = cf.getFinish();
// 
// Operand prev = null;
// for (Operand op : cf.getOwnedOperands()) {
// if (operand.equals(prev)) {
// result = op.getStart();
// break;
// } else {
// prev = op;
// }
// }
// }
// 
// return result;
// }
/**
 * Returns the semantic element corresponding to the source of a message.
 * This can be a participant or an execution.
 *
 * @param msg
 *            the message.
 * @return the semantic elements corresponding to the source of the message.
 */
public EObject getSendingContext(Message msg) {
    End sendingEnd = msg.getStartingEnd();
    if (sendingEnd != null) {
        Participant p = sendingEnd.getContext();
        List<EventContext> structure = computeContainmentStructure(p);
        for (EventContext ec : structure) {
            if (ec.getElement().equals(msg) && ec.isStart()) {
                EObject parent = ec.getParent();
                if (parent != null) {
                    return parent;
                } else {
                    return p;
                }
            }
        }
    }
    return msg;
}
Also used : Participant(org.obeonetwork.dsl.interaction.Participant) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End)

Example 5 with Participant

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

Aggregations

EObject (org.eclipse.emf.ecore.EObject)5 Participant (org.obeonetwork.dsl.interaction.Participant)5 End (org.obeonetwork.dsl.interaction.End)4 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)1 CombinedFragment (org.obeonetwork.dsl.interaction.CombinedFragment)1 Execution (org.obeonetwork.dsl.interaction.Execution)1 ParticipantPropertiesEditionPart (org.obeonetwork.dsl.interaction.parts.ParticipantPropertiesEditionPart)1