| 1 | /** |
| 2 | * Copyright 2006, SDQ Group, University Karlsruhe (TH) |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.context.computed_usage.provider; |
| 7 | |
| 8 | |
| 9 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsage; |
| 10 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsageFactory; |
| 11 | import de.uka.ipd.sdq.context.computed_usage.ComputedUsagePackage; |
| 12 | |
| 13 | import java.util.Collection; |
| 14 | import java.util.List; |
| 15 | |
| 16 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 17 | import org.eclipse.emf.common.notify.Notification; |
| 18 | |
| 19 | import org.eclipse.emf.common.util.ResourceLocator; |
| 20 | |
| 21 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 22 | |
| 23 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 24 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 25 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 26 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 27 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 28 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 29 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
| 30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 31 | |
| 32 | /** |
| 33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.context.computed_usage.ComputedUsage} object. |
| 34 | * <!-- begin-user-doc --> |
| 35 | * <!-- end-user-doc --> |
| 36 | * @generated |
| 37 | */ |
| 38 | public class ComputedUsageItemProvider |
| 39 | extends ItemProviderAdapter |
| 40 | implements |
| 41 | IEditingDomainItemProvider, |
| 42 | IStructuredItemContentProvider, |
| 43 | ITreeItemContentProvider, |
| 44 | IItemLabelProvider, |
| 45 | IItemPropertySource { |
| 46 | /** |
| 47 | * <!-- begin-user-doc --> |
| 48 | * <!-- end-user-doc --> |
| 49 | * @generated |
| 50 | */ |
| 51 | public static final String copyright = "Copyright 2006, SDQ Group, University Karlsruhe (TH)"; |
| 52 | |
| 53 | /** |
| 54 | * This constructs an instance from a factory and a notifier. |
| 55 | * <!-- begin-user-doc --> |
| 56 | * <!-- end-user-doc --> |
| 57 | * @generated |
| 58 | */ |
| 59 | public ComputedUsageItemProvider(AdapterFactory adapterFactory) { |
| 60 | super(adapterFactory); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * This returns the property descriptors for the adapted class. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @generated |
| 68 | */ |
| 69 | @Override |
| 70 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 71 | if (itemPropertyDescriptors == null) { |
| 72 | super.getPropertyDescriptors(object); |
| 73 | |
| 74 | } |
| 75 | return itemPropertyDescriptors; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 80 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 81 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 82 | * <!-- begin-user-doc --> |
| 83 | * <!-- end-user-doc --> |
| 84 | * @generated |
| 85 | */ |
| 86 | @Override |
| 87 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 88 | if (childrenFeatures == null) { |
| 89 | super.getChildrenFeatures(object); |
| 90 | childrenFeatures.add(ComputedUsagePackage.Literals.COMPUTED_USAGE__USAGE_CONTEXTS_COMPUTED_USAGE); |
| 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 ComputedUsage.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/ComputedUsage")); |
| 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_ComputedUsage_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(ComputedUsage.class)) { |
| 142 | case ComputedUsagePackage.COMPUTED_USAGE__USAGE_CONTEXTS_COMPUTED_USAGE: |
| 143 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 144 | return; |
| 145 | } |
| 146 | super.notifyChanged(notification); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 151 | * that can be created under this object. |
| 152 | * <!-- begin-user-doc --> |
| 153 | * <!-- end-user-doc --> |
| 154 | * @generated |
| 155 | */ |
| 156 | @Override |
| 157 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 158 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 159 | |
| 160 | newChildDescriptors.add |
| 161 | (createChildParameter |
| 162 | (ComputedUsagePackage.Literals.COMPUTED_USAGE__USAGE_CONTEXTS_COMPUTED_USAGE, |
| 163 | ComputedUsageFactory.eINSTANCE.createComputedUsageContext())); |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Return the resource locator for this item provider's resources. |
| 168 | * <!-- begin-user-doc --> |
| 169 | * <!-- end-user-doc --> |
| 170 | * @generated |
| 171 | */ |
| 172 | @Override |
| 173 | public ResourceLocator getResourceLocator() { |
| 174 | return ContextEditPlugin.INSTANCE; |
| 175 | } |
| 176 | |
| 177 | } |