| 1 | /** |
| 2 | * Copyright SDQ, IPD, U Karlsruhe, 2007 |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.completions.provider; |
| 7 | |
| 8 | |
| 9 | import de.uka.ipd.sdq.completions.Completion; |
| 10 | import de.uka.ipd.sdq.completions.CompletionsPackage; |
| 11 | |
| 12 | import de.uka.ipd.sdq.pcm.core.entity.provider.ComposedProvidingRequiringEntityItemProvider; |
| 13 | |
| 14 | import de.uka.ipd.sdq.pcm.parameter.ParameterFactory; |
| 15 | |
| 16 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
| 17 | |
| 18 | import java.util.Collection; |
| 19 | import java.util.List; |
| 20 | |
| 21 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 22 | import org.eclipse.emf.common.notify.Notification; |
| 23 | |
| 24 | import org.eclipse.emf.common.util.ResourceLocator; |
| 25 | |
| 26 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 27 | |
| 28 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 29 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 30 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 31 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 32 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 33 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 34 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 35 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 36 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 37 | |
| 38 | /** |
| 39 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.completions.Completion} object. |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @generated |
| 43 | */ |
| 44 | public class CompletionItemProvider |
| 45 | extends ComposedProvidingRequiringEntityItemProvider |
| 46 | implements |
| 47 | IEditingDomainItemProvider, |
| 48 | IStructuredItemContentProvider, |
| 49 | ITreeItemContentProvider, |
| 50 | IItemLabelProvider, |
| 51 | IItemPropertySource { |
| 52 | /** |
| 53 | * This constructs an instance from a factory and a notifier. |
| 54 | * <!-- begin-user-doc --> |
| 55 | * <!-- end-user-doc --> |
| 56 | * @generated |
| 57 | */ |
| 58 | public CompletionItemProvider(AdapterFactory adapterFactory) { |
| 59 | super(adapterFactory); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * This returns the property descriptors for the adapted class. |
| 64 | * <!-- begin-user-doc --> |
| 65 | * <!-- end-user-doc --> |
| 66 | * @generated |
| 67 | */ |
| 68 | @Override |
| 69 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 70 | if (itemPropertyDescriptors == null) { |
| 71 | super.getPropertyDescriptors(object); |
| 72 | |
| 73 | addParentCompleteComponentTypesPropertyDescriptor(object); |
| 74 | addComponentTypePropertyDescriptor(object); |
| 75 | } |
| 76 | return itemPropertyDescriptors; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * This adds a property descriptor for the Parent Complete Component Types feature. |
| 81 | * <!-- begin-user-doc --> |
| 82 | * <!-- end-user-doc --> |
| 83 | * @generated |
| 84 | */ |
| 85 | protected void addParentCompleteComponentTypesPropertyDescriptor(Object object) { |
| 86 | itemPropertyDescriptors.add |
| 87 | (createItemPropertyDescriptor |
| 88 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 89 | getResourceLocator(), |
| 90 | getString("_UI_ImplementationComponentType_parentCompleteComponentTypes_feature"), |
| 91 | getString("_UI_PropertyDescriptor_description", "_UI_ImplementationComponentType_parentCompleteComponentTypes_feature", "_UI_ImplementationComponentType_type"), |
| 92 | RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__PARENT_COMPLETE_COMPONENT_TYPES, |
| 93 | true, |
| 94 | false, |
| 95 | true, |
| 96 | null, |
| 97 | null, |
| 98 | null)); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * This adds a property descriptor for the Component Type feature. |
| 103 | * <!-- begin-user-doc --> |
| 104 | * <!-- end-user-doc --> |
| 105 | * @generated |
| 106 | */ |
| 107 | protected void addComponentTypePropertyDescriptor(Object object) { |
| 108 | itemPropertyDescriptors.add |
| 109 | (createItemPropertyDescriptor |
| 110 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 111 | getResourceLocator(), |
| 112 | getString("_UI_ImplementationComponentType_componentType_feature"), |
| 113 | getString("_UI_PropertyDescriptor_description", "_UI_ImplementationComponentType_componentType_feature", "_UI_ImplementationComponentType_type"), |
| 114 | RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_TYPE, |
| 115 | true, |
| 116 | false, |
| 117 | false, |
| 118 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
| 119 | null, |
| 120 | null)); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 125 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 126 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | @Override |
| 132 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 133 | if (childrenFeatures == null) { |
| 134 | super.getChildrenFeatures(object); |
| 135 | childrenFeatures.add(RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE); |
| 136 | } |
| 137 | return childrenFeatures; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * <!-- begin-user-doc --> |
| 142 | * <!-- end-user-doc --> |
| 143 | * @generated |
| 144 | */ |
| 145 | @Override |
| 146 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 147 | // Check the type of the specified child object and return the proper feature to use for |
| 148 | // adding (see {@link AddCommand}) it as a child. |
| 149 | |
| 150 | return super.getChildFeature(object, child); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * This returns Completion.gif. |
| 155 | * <!-- begin-user-doc --> |
| 156 | * <!-- end-user-doc --> |
| 157 | * @generated |
| 158 | */ |
| 159 | @Override |
| 160 | public Object getImage(Object object) { |
| 161 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Completion")); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * This returns the label text for the adapted class. |
| 166 | * <!-- begin-user-doc --> |
| 167 | * <!-- end-user-doc --> |
| 168 | * @generated |
| 169 | */ |
| 170 | @Override |
| 171 | public String getText(Object object) { |
| 172 | String label = ((Completion)object).getId(); |
| 173 | return label == null || label.length() == 0 ? |
| 174 | getString("_UI_Completion_type") : |
| 175 | getString("_UI_Completion_type") + " " + label; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 180 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 181 | * <!-- begin-user-doc --> |
| 182 | * <!-- end-user-doc --> |
| 183 | * @generated |
| 184 | */ |
| 185 | @Override |
| 186 | public void notifyChanged(Notification notification) { |
| 187 | updateChildren(notification); |
| 188 | |
| 189 | switch (notification.getFeatureID(Completion.class)) { |
| 190 | case CompletionsPackage.COMPLETION__COMPONENT_TYPE: |
| 191 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 192 | return; |
| 193 | case CompletionsPackage.COMPLETION__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
| 194 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 195 | return; |
| 196 | } |
| 197 | super.notifyChanged(notification); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 202 | * that can be created under this object. |
| 203 | * <!-- begin-user-doc --> |
| 204 | * <!-- end-user-doc --> |
| 205 | * @generated |
| 206 | */ |
| 207 | @Override |
| 208 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 209 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 210 | |
| 211 | newChildDescriptors.add |
| 212 | (createChildParameter |
| 213 | (RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE, |
| 214 | ParameterFactory.eINSTANCE.createVariableUsage())); |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Return the resource locator for this item provider's resources. |
| 219 | * <!-- begin-user-doc --> |
| 220 | * <!-- end-user-doc --> |
| 221 | * @generated |
| 222 | */ |
| 223 | @Override |
| 224 | public ResourceLocator getResourceLocator() { |
| 225 | return CompletionsEditPlugin.INSTANCE; |
| 226 | } |
| 227 | |
| 228 | } |