Search in sources :

Example 1 with EventType

use of org.palladiosimulator.pcm.repository.EventType in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddEmitEventAction method execute.

@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
    EmitEventAction emitEventAction = (EmitEventAction) parameters.get("instance");
    EventType eventType = getEventType(emitEventAction);
    emitEventAction.setEventType__EmitEventAction(eventType);
}
Also used : EventType(org.palladiosimulator.pcm.repository.EventType) EmitEventAction(org.palladiosimulator.pcm.seff.EmitEventAction)

Example 2 with EventType

use of org.palladiosimulator.pcm.repository.EventType in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddEmitEventAction method getEventType.

private EventType getEventType(EmitEventAction emitEventAction) {
    Collection<Object> filter = new ArrayList<Object>();
    filter.add(Repository.class);
    filter.add(EventGroup.class);
    filter.add(EventType.class);
    Collection<EReference> additionalChildReferences = new ArrayList<EReference>();
    PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(SHELL, filter, additionalChildReferences, emitEventAction.eResource().getResourceSet());
    dialog.setProvidedService(EventType.class);
    // Only show EventTypes from EventGroups from SourceRoles of the parent BasicComponent
    for (Object o : dialog.getTreeViewer().getExpandedElements()) {
        if (!(o instanceof EventGroup))
            continue;
        ServiceEffectSpecification seff = SEFFUtil.getEnclosingSEFF(emitEventAction.getResourceDemandingBehaviour_AbstractAction());
        BasicComponent parent = seff.getBasicComponent_ServiceEffectSpecification();
        boolean found = false;
        for (RequiredRole r : parent.getRequiredRoles_InterfaceRequiringEntity()) {
            if (!(r instanceof SourceRole))
                continue;
            SourceRole sourceRole = (SourceRole) r;
            if (sourceRole.getEventGroup__SourceRole().equals(o)) {
                found = true;
                emitEventAction.setSourceRole__EmitEventAction(sourceRole);
            }
        }
        if (!found)
            dialog.getTreeViewer().remove(o);
    }
    dialog.open();
    return (EventType) dialog.getResult();
}
Also used : SourceRole(org.palladiosimulator.pcm.repository.SourceRole) RequiredRole(org.palladiosimulator.pcm.repository.RequiredRole) EventType(org.palladiosimulator.pcm.repository.EventType) ArrayList(java.util.ArrayList) ServiceEffectSpecification(org.palladiosimulator.pcm.seff.ServiceEffectSpecification) EventGroup(org.palladiosimulator.pcm.repository.EventGroup) PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Aggregations

EventType (org.palladiosimulator.pcm.repository.EventType)2 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 EReference (org.eclipse.emf.ecore.EReference)1 PalladioSelectEObjectDialog (org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog)1 BasicComponent (org.palladiosimulator.pcm.repository.BasicComponent)1 EventGroup (org.palladiosimulator.pcm.repository.EventGroup)1 RequiredRole (org.palladiosimulator.pcm.repository.RequiredRole)1 SourceRole (org.palladiosimulator.pcm.repository.SourceRole)1 EmitEventAction (org.palladiosimulator.pcm.seff.EmitEventAction)1 ServiceEffectSpecification (org.palladiosimulator.pcm.seff.ServiceEffectSpecification)1