| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcmbench.ui.provider.categoryaware; |
| 5 | |
| 6 | import java.util.ArrayList; |
| 7 | import java.util.Collection; |
| 8 | import java.util.Collections; |
| 9 | |
| 10 | import org.eclipse.emf.ecore.EObject; |
| 11 | |
| 12 | import de.uka.ipd.sdq.pcm.core.composition.AssemblyConnector; |
| 13 | import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext; |
| 14 | import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage; |
| 15 | import de.uka.ipd.sdq.pcm.core.entity.EntityPackage; |
| 16 | import de.uka.ipd.sdq.pcm.repository.BasicComponent; |
| 17 | import de.uka.ipd.sdq.pcm.repository.CompositeComponent; |
| 18 | import de.uka.ipd.sdq.pcm.repository.Interface; |
| 19 | import de.uka.ipd.sdq.pcm.repository.ProvidedRole; |
| 20 | import de.uka.ipd.sdq.pcm.repository.ProvidesComponentType; |
| 21 | import de.uka.ipd.sdq.pcm.repository.Repository; |
| 22 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
| 23 | import de.uka.ipd.sdq.pcm.repository.RequiredRole; |
| 24 | import de.uka.ipd.sdq.pcm.seff.ServiceEffectSpecification; |
| 25 | |
| 26 | /** |
| 27 | * @author Snowball |
| 28 | * |
| 29 | */ |
| 30 | public class PalladioCategoryDescriptions implements ICategoryDescriptions { |
| 31 | |
| 32 | /** |
| 33 | * |
| 34 | */ |
| 35 | public PalladioCategoryDescriptions() { |
| 36 | } |
| 37 | |
| 38 | public Collection<CategoryDescriptor> getCategoriesForObject(EObject object) { |
| 39 | if (object instanceof Repository) |
| 40 | { |
| 41 | ArrayList<CategoryDescriptor> result = new ArrayList<CategoryDescriptor>(); |
| 42 | result.add(new CategoryDescriptor(Repository.class, Interface.class, |
| 43 | RepositoryPackage.eINSTANCE.getRepository_Interfaces__Repository(), "Interfaces" )); |
| 44 | result.add(new CategoryDescriptor(Repository.class, ProvidesComponentType.class, |
| 45 | RepositoryPackage.eINSTANCE.getRepository_Components__Repository(), "Components" )); |
| 46 | return Collections.unmodifiableCollection(result); |
| 47 | } |
| 48 | if (object instanceof ProvidesComponentType) |
| 49 | { |
| 50 | ArrayList<CategoryDescriptor> result = new ArrayList<CategoryDescriptor>(); |
| 51 | result.add(new CategoryDescriptor(ProvidesComponentType.class, ProvidedRole.class, |
| 52 | EntityPackage.eINSTANCE.getInterfaceProvidingEntity_ProvidedRoles_InterfaceProvidingEntity(), "Provided Roles" )); |
| 53 | result.add(new CategoryDescriptor(ProvidesComponentType.class, RequiredRole.class, |
| 54 | EntityPackage.eINSTANCE.getInterfaceRequiringEntity_RequiredRoles_InterfaceRequiringEntity(), "Required Roles" )); |
| 55 | if (object instanceof BasicComponent) |
| 56 | { |
| 57 | result.add(new CategoryDescriptor(BasicComponent.class, ServiceEffectSpecification.class, |
| 58 | RepositoryPackage.eINSTANCE.getBasicComponent_ServiceEffectSpecifications__BasicComponent(), "Service Effect Specifications" )); |
| 59 | } |
| 60 | if (object instanceof CompositeComponent) |
| 61 | { |
| 62 | result.add(new CategoryDescriptor(CompositeComponent.class, AssemblyContext.class, |
| 63 | CompositionPackage.eINSTANCE.getAssemblyContext_EncapsulatedComponent__AssemblyContext(), "Child Component Contexts" )); |
| 64 | result.add(new CategoryDescriptor(CompositeComponent.class, AssemblyConnector.class, |
| 65 | CompositionPackage.eINSTANCE.getComposedStructure_Connectors__ComposedStructure(), "Assembly Connectors" )); |
| 66 | } |
| 67 | return Collections.unmodifiableCollection(result); |
| 68 | } |
| 69 | return Collections.EMPTY_LIST; |
| 70 | } |
| 71 | |
| 72 | public boolean hasCategoriesForObject(EObject object) { |
| 73 | return getCategoriesForObject(object).size() > 0; |
| 74 | } |
| 75 | } |