| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.pcm.resourcerepository.provider; |
| 8 | |
| 9 | |
| 10 | import de.uka.ipd.sdq.pcm.cost.costFactory; |
| 11 | |
| 12 | import de.uka.ipd.sdq.pcm.designdecision.provider.DesignDecisionEditPlugin; |
| 13 | |
| 14 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentFactory; |
| 15 | |
| 16 | import de.uka.ipd.sdq.pcm.resourcerepository.ResourceDescription; |
| 17 | import de.uka.ipd.sdq.pcm.resourcerepository.resourcerepositoryPackage; |
| 18 | |
| 19 | import java.util.Collection; |
| 20 | import java.util.List; |
| 21 | |
| 22 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 23 | import org.eclipse.emf.common.notify.Notification; |
| 24 | |
| 25 | import org.eclipse.emf.common.util.ResourceLocator; |
| 26 | |
| 27 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 28 | |
| 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.ItemProviderAdapter; |
| 36 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 37 | |
| 38 | /** |
| 39 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.resourcerepository.ResourceDescription} object. |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @generated |
| 43 | */ |
| 44 | public class ResourceDescriptionItemProvider |
| 45 | extends ItemProviderAdapter |
| 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 ResourceDescriptionItemProvider(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 | } |
| 74 | return itemPropertyDescriptors; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 79 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 80 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 81 | * <!-- begin-user-doc --> |
| 82 | * <!-- end-user-doc --> |
| 83 | * @generated |
| 84 | */ |
| 85 | @Override |
| 86 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 87 | if (childrenFeatures == null) { |
| 88 | super.getChildrenFeatures(object); |
| 89 | childrenFeatures.add(resourcerepositoryPackage.Literals.RESOURCE_DESCRIPTION__FIXED_PROCESSING_RESOURCE_COST_RESOURCE_DESCRIPTION); |
| 90 | childrenFeatures.add(resourcerepositoryPackage.Literals.RESOURCE_DESCRIPTION__PROCESSING_RESOURCE_SPECIFICATION_RESOURCE_DESCRIPTION); |
| 91 | } |
| 92 | return childrenFeatures; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * <!-- begin-user-doc --> |
| 97 | * <!-- end-user-doc --> |
| 98 | * @generated |
| 99 | */ |
| 100 | @Override |
| 101 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 102 | // Check the type of the specified child object and return the proper feature to use for |
| 103 | // adding (see {@link AddCommand}) it as a child. |
| 104 | |
| 105 | return super.getChildFeature(object, child); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * This returns ResourceDescription.gif. |
| 110 | * <!-- begin-user-doc --> |
| 111 | * <!-- end-user-doc --> |
| 112 | * @generated |
| 113 | */ |
| 114 | @Override |
| 115 | public Object getImage(Object object) { |
| 116 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ResourceDescription")); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * This returns the label text for the adapted class. |
| 121 | * <!-- begin-user-doc --> |
| 122 | * <!-- end-user-doc --> |
| 123 | * @generated |
| 124 | */ |
| 125 | @Override |
| 126 | public String getText(Object object) { |
| 127 | return getString("_UI_ResourceDescription_type"); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 132 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 133 | * <!-- begin-user-doc --> |
| 134 | * <!-- end-user-doc --> |
| 135 | * @generated |
| 136 | */ |
| 137 | @Override |
| 138 | public void notifyChanged(Notification notification) { |
| 139 | updateChildren(notification); |
| 140 | |
| 141 | switch (notification.getFeatureID(ResourceDescription.class)) { |
| 142 | case resourcerepositoryPackage.RESOURCE_DESCRIPTION__FIXED_PROCESSING_RESOURCE_COST_RESOURCE_DESCRIPTION: |
| 143 | case resourcerepositoryPackage.RESOURCE_DESCRIPTION__PROCESSING_RESOURCE_SPECIFICATION_RESOURCE_DESCRIPTION: |
| 144 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 145 | return; |
| 146 | } |
| 147 | super.notifyChanged(notification); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 152 | * that can be created under this object. |
| 153 | * <!-- begin-user-doc --> |
| 154 | * <!-- end-user-doc --> |
| 155 | * @generated |
| 156 | */ |
| 157 | @Override |
| 158 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 159 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 160 | |
| 161 | newChildDescriptors.add |
| 162 | (createChildParameter |
| 163 | (resourcerepositoryPackage.Literals.RESOURCE_DESCRIPTION__FIXED_PROCESSING_RESOURCE_COST_RESOURCE_DESCRIPTION, |
| 164 | costFactory.eINSTANCE.createFixedProcessingResourceCost())); |
| 165 | |
| 166 | newChildDescriptors.add |
| 167 | (createChildParameter |
| 168 | (resourcerepositoryPackage.Literals.RESOURCE_DESCRIPTION__PROCESSING_RESOURCE_SPECIFICATION_RESOURCE_DESCRIPTION, |
| 169 | ResourceenvironmentFactory.eINSTANCE.createProcessingResourceSpecification())); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Return the resource locator for this item provider's resources. |
| 174 | * <!-- begin-user-doc --> |
| 175 | * <!-- end-user-doc --> |
| 176 | * @generated |
| 177 | */ |
| 178 | @Override |
| 179 | public ResourceLocator getResourceLocator() { |
| 180 | return DesignDecisionEditPlugin.INSTANCE; |
| 181 | } |
| 182 | |
| 183 | } |