Search in sources :

Example 1 with ProvidedRole

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

the class AddSEFF method getSignature.

private Signature getSignature(ResourceDemandingSEFF seff) {
    // Filter list (Repository > Interface > Signature)
    Collection<Object> filter = new ArrayList<Object>();
    filter.add(Repository.class);
    filter.add(Interface.class);
    filter.add(Signature.class);
    // Additional Child References
    Collection<EReference> additionalChildReferences = new ArrayList<EReference>();
    // Creating the dialog
    PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(SHELL, filter, additionalChildReferences, seff.eResource().getResourceSet());
    // Setting the needed object type
    dialog.setProvidedService(Signature.class);
    // Filter: Show only provided interfaces
    for (Object o : dialog.getTreeViewer().getExpandedElements()) {
        BasicComponent parent = seff.getBasicComponent_ServiceEffectSpecification();
        EList<ProvidedRole> providedRoles = parent.getProvidedRoles_InterfaceProvidingEntity();
        if (o instanceof Interface) {
            boolean found = false;
            for (ProvidedRole p : providedRoles) {
                if (p instanceof OperationProvidedRole) {
                    OperationProvidedRole role = (OperationProvidedRole) p;
                    if (role.getProvidedInterface__OperationProvidedRole().equals(o))
                        found = true;
                } else if (p instanceof InfrastructureProvidedRole) {
                    InfrastructureProvidedRole role = (InfrastructureProvidedRole) p;
                    if (role.getProvidedInterface__InfrastructureProvidedRole().equals(o))
                        found = true;
                } else if (p instanceof SinkRole) {
                    SinkRole role = (SinkRole) p;
                    if (role.getEventGroup__SinkRole().equals(o))
                        found = true;
                }
            }
            if (!found)
                dialog.getTreeViewer().remove(o);
        }
    }
    dialog.open();
    return (Signature) dialog.getResult();
}
Also used : OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) SinkRole(org.palladiosimulator.pcm.repository.SinkRole) ArrayList(java.util.ArrayList) OperationProvidedRole(org.palladiosimulator.pcm.repository.OperationProvidedRole) InfrastructureProvidedRole(org.palladiosimulator.pcm.repository.InfrastructureProvidedRole) ProvidedRole(org.palladiosimulator.pcm.repository.ProvidedRole) PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) Signature(org.palladiosimulator.pcm.repository.Signature) BasicComponent(org.palladiosimulator.pcm.repository.BasicComponent) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference) Interface(org.palladiosimulator.pcm.repository.Interface) InfrastructureProvidedRole(org.palladiosimulator.pcm.repository.InfrastructureProvidedRole)

Aggregations

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 InfrastructureProvidedRole (org.palladiosimulator.pcm.repository.InfrastructureProvidedRole)1 Interface (org.palladiosimulator.pcm.repository.Interface)1 OperationProvidedRole (org.palladiosimulator.pcm.repository.OperationProvidedRole)1 ProvidedRole (org.palladiosimulator.pcm.repository.ProvidedRole)1 Signature (org.palladiosimulator.pcm.repository.Signature)1 SinkRole (org.palladiosimulator.pcm.repository.SinkRole)1