| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.core.entity.provider; |
| 7 | |
| 8 | |
| 9 | import java.util.Collection; |
| 10 | import java.util.List; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 15 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 16 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 17 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 18 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 19 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 20 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 21 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 22 | |
| 23 | import de.uka.ipd.sdq.pcm.core.entity.EntityFactory; |
| 24 | import de.uka.ipd.sdq.pcm.core.entity.EntityPackage; |
| 25 | import de.uka.ipd.sdq.pcm.core.entity.InterfaceRequiringEntity; |
| 26 | import de.uka.ipd.sdq.pcm.repository.RepositoryFactory; |
| 27 | |
| 28 | /** |
| 29 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.core.entity.InterfaceRequiringEntity} object. |
| 30 | * <!-- begin-user-doc --> |
| 31 | * <!-- end-user-doc --> |
| 32 | * @generated |
| 33 | */ |
| 34 | public class InterfaceRequiringEntityItemProvider |
| 35 | extends EntityItemProvider |
| 36 | implements |
| 37 | IEditingDomainItemProvider, |
| 38 | IStructuredItemContentProvider, |
| 39 | ITreeItemContentProvider, |
| 40 | IItemLabelProvider, |
| 41 | IItemPropertySource { |
| 42 | /** |
| 43 | * <!-- begin-user-doc --> |
| 44 | * <!-- end-user-doc --> |
| 45 | * @generated |
| 46 | */ |
| 47 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 48 | |
| 49 | /** |
| 50 | * This constructs an instance from a factory and a notifier. |
| 51 | * <!-- begin-user-doc --> |
| 52 | * <!-- end-user-doc --> |
| 53 | * @generated |
| 54 | */ |
| 55 | public InterfaceRequiringEntityItemProvider(AdapterFactory adapterFactory) { |
| 56 | super(adapterFactory); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * This returns the property descriptors for the adapted class. |
| 61 | * <!-- begin-user-doc --> |
| 62 | * <!-- end-user-doc --> |
| 63 | * @generated |
| 64 | */ |
| 65 | @Override |
| 66 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 67 | if (itemPropertyDescriptors == null) { |
| 68 | super.getPropertyDescriptors(object); |
| 69 | |
| 70 | } |
| 71 | return itemPropertyDescriptors; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 76 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 77 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 78 | * <!-- begin-user-doc --> |
| 79 | * <!-- end-user-doc --> |
| 80 | * @generated |
| 81 | */ |
| 82 | @Override |
| 83 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 84 | if (childrenFeatures == null) { |
| 85 | super.getChildrenFeatures(object); |
| 86 | childrenFeatures.add(EntityPackage.Literals.RESOURCE_INTERFACE_REQUIRING_ENTITY__RESOURCE_REQUIRED_ROLES_RESOURCE_INTERFACE_REQUIRING_ENTITY); |
| 87 | childrenFeatures.add(EntityPackage.Literals.INTERFACE_REQUIRING_ENTITY__REQUIRED_ROLES_INTERFACE_REQUIRING_ENTITY); |
| 88 | } |
| 89 | return childrenFeatures; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | @Override |
| 98 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 99 | // Check the type of the specified child object and return the proper feature to use for |
| 100 | // adding (see {@link AddCommand}) it as a child. |
| 101 | |
| 102 | return super.getChildFeature(object, child); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * This returns the label text for the adapted class. |
| 107 | * <!-- begin-user-doc --> |
| 108 | * <!-- end-user-doc --> |
| 109 | * @generated |
| 110 | */ |
| 111 | @Override |
| 112 | public String getText(Object object) { |
| 113 | String label = ((InterfaceRequiringEntity)object).getId(); |
| 114 | return label == null || label.length() == 0 ? |
| 115 | getString("_UI_InterfaceRequiringEntity_type") : |
| 116 | getString("_UI_InterfaceRequiringEntity_type") + " " + label; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 121 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 122 | * <!-- begin-user-doc --> |
| 123 | * <!-- end-user-doc --> |
| 124 | * @generated |
| 125 | */ |
| 126 | @Override |
| 127 | public void notifyChanged(Notification notification) { |
| 128 | updateChildren(notification); |
| 129 | |
| 130 | switch (notification.getFeatureID(InterfaceRequiringEntity.class)) { |
| 131 | case EntityPackage.INTERFACE_REQUIRING_ENTITY__RESOURCE_REQUIRED_ROLES_RESOURCE_INTERFACE_REQUIRING_ENTITY: |
| 132 | case EntityPackage.INTERFACE_REQUIRING_ENTITY__REQUIRED_ROLES_INTERFACE_REQUIRING_ENTITY: |
| 133 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 134 | return; |
| 135 | } |
| 136 | super.notifyChanged(notification); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 141 | * that can be created under this object. |
| 142 | * <!-- begin-user-doc --> |
| 143 | * <!-- end-user-doc --> |
| 144 | * @generated |
| 145 | */ |
| 146 | @Override |
| 147 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 148 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 149 | |
| 150 | newChildDescriptors.add |
| 151 | (createChildParameter |
| 152 | (EntityPackage.Literals.RESOURCE_INTERFACE_REQUIRING_ENTITY__RESOURCE_REQUIRED_ROLES_RESOURCE_INTERFACE_REQUIRING_ENTITY, |
| 153 | EntityFactory.eINSTANCE.createResourceRequiredRole())); |
| 154 | |
| 155 | newChildDescriptors.add |
| 156 | (createChildParameter |
| 157 | (EntityPackage.Literals.INTERFACE_REQUIRING_ENTITY__REQUIRED_ROLES_INTERFACE_REQUIRING_ENTITY, |
| 158 | RepositoryFactory.eINSTANCE.createInfrastructureRequiredRole())); |
| 159 | |
| 160 | newChildDescriptors.add |
| 161 | (createChildParameter |
| 162 | (EntityPackage.Literals.INTERFACE_REQUIRING_ENTITY__REQUIRED_ROLES_INTERFACE_REQUIRING_ENTITY, |
| 163 | RepositoryFactory.eINSTANCE.createOperationRequiredRole())); |
| 164 | |
| 165 | newChildDescriptors.add |
| 166 | (createChildParameter |
| 167 | (EntityPackage.Literals.INTERFACE_REQUIRING_ENTITY__REQUIRED_ROLES_INTERFACE_REQUIRING_ENTITY, |
| 168 | RepositoryFactory.eINSTANCE.createSourceRole())); |
| 169 | } |
| 170 | |
| 171 | } |