Search in sources :

Example 1 with CombinedFragment

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

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

the class DeleteServices method deleteOperand.

public void deleteOperand(Operand operand) {
    EObject result = operand.eContainer();
    if (result instanceof CombinedFragment) {
        CombinedFragment combinedFragment = (CombinedFragment) result;
        End startingEnd = operand.getStartingEnd();
        End finishingEnd = null;
        EList<Operand> siblings = combinedFragment.getOwnedOperands();
        if (siblings.size() == 1) {
            deleteCombinedFragment(combinedFragment);
            return;
        }
        int index = siblings.indexOf(operand);
        if (index == siblings.size() - 1) {
            // The last operand ends with the CF
            finishingEnd = combinedFragment.getFinishingEnd();
        } else {
            // Other operands ends when their successor starts
            finishingEnd = siblings.get(index + 1).getStartingEnd();
        }
        delete((Interaction) combinedFragment.eContainer(), startingEnd, finishingEnd, false, combinedFragment.getCoveredParticipants());
    }
    return;
}
Also used : Operand(org.obeonetwork.dsl.interaction.Operand) EObject(org.eclipse.emf.ecore.EObject) End(org.obeonetwork.dsl.interaction.End) CompoundEnd(org.obeonetwork.dsl.interaction.CompoundEnd) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Example 3 with CombinedFragment

use of org.obeonetwork.dsl.interaction.CombinedFragment 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 4 with CombinedFragment

use of org.obeonetwork.dsl.interaction.CombinedFragment 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 5 with CombinedFragment

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

the class CombinedFragmentCombinedFragmentPropertiesEditionComponent 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 CombinedFragment combinedFragment = (CombinedFragment) elt;
        final CombinedFragmentPropertiesEditionPart combinedFragmentPart = (CombinedFragmentPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(InteractionViewsRepository.CombinedFragment.Properties.name))
            combinedFragmentPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, combinedFragment.getName()));
        if (isAccessible(InteractionViewsRepository.CombinedFragment.Properties.operator))
            combinedFragmentPart.setOperator(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, combinedFragment.getOperator()));
        if (isAccessible(InteractionViewsRepository.CombinedFragment.Properties.description))
            combinedFragmentPart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, combinedFragment.getDescription()));
    // init filters
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : CombinedFragmentPropertiesEditionPart(org.obeonetwork.dsl.interaction.parts.CombinedFragmentPropertiesEditionPart) CombinedFragment(org.obeonetwork.dsl.interaction.CombinedFragment)

Aggregations

CombinedFragment (org.obeonetwork.dsl.interaction.CombinedFragment)6 End (org.obeonetwork.dsl.interaction.End)4 EObject (org.eclipse.emf.ecore.EObject)3 Operand (org.obeonetwork.dsl.interaction.Operand)2 ArrayList (java.util.ArrayList)1 CompoundEnd (org.obeonetwork.dsl.interaction.CompoundEnd)1 Interaction (org.obeonetwork.dsl.interaction.Interaction)1 Participant (org.obeonetwork.dsl.interaction.Participant)1 CombinedFragmentPropertiesEditionPart (org.obeonetwork.dsl.interaction.parts.CombinedFragmentPropertiesEditionPart)1