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