| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.units.provider; |
| 8 | |
| 9 | |
| 10 | import java.util.Collection; |
| 11 | import java.util.List; |
| 12 | |
| 13 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 14 | import org.eclipse.emf.common.notify.Notification; |
| 15 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 16 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 17 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 18 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 19 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 20 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 21 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 22 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 23 | |
| 24 | import de.uka.ipd.sdq.units.UnitMultiplication; |
| 25 | import de.uka.ipd.sdq.units.UnitsFactory; |
| 26 | import de.uka.ipd.sdq.units.UnitsPackage; |
| 27 | |
| 28 | /** |
| 29 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.units.UnitMultiplication} object. |
| 30 | * <!-- begin-user-doc --> |
| 31 | * <!-- end-user-doc --> |
| 32 | * @generated |
| 33 | */ |
| 34 | public class UnitMultiplicationItemProvider |
| 35 | extends UnitItemProvider |
| 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 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 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 UnitMultiplicationItemProvider(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(UnitsPackage.Literals.UNIT_MULTIPLICATION__UNITS); |
| 87 | } |
| 88 | return childrenFeatures; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * <!-- begin-user-doc --> |
| 93 | * <!-- end-user-doc --> |
| 94 | * @generated |
| 95 | */ |
| 96 | @Override |
| 97 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 98 | // Check the type of the specified child object and return the proper feature to use for |
| 99 | // adding (see {@link AddCommand}) it as a child. |
| 100 | |
| 101 | return super.getChildFeature(object, child); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * This returns UnitMultiplication.gif. |
| 106 | * <!-- begin-user-doc --> |
| 107 | * <!-- end-user-doc --> |
| 108 | * @generated |
| 109 | */ |
| 110 | @Override |
| 111 | public Object getImage(Object object) { |
| 112 | return overlayImage(object, getResourceLocator().getImage("full/obj16/UnitMultiplication")); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * This returns the label text for the adapted class. |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | @Override |
| 122 | public String getText(Object object) { |
| 123 | return getString("_UI_UnitMultiplication_type"); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 128 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 129 | * <!-- begin-user-doc --> |
| 130 | * <!-- end-user-doc --> |
| 131 | * @generated |
| 132 | */ |
| 133 | @Override |
| 134 | public void notifyChanged(Notification notification) { |
| 135 | updateChildren(notification); |
| 136 | |
| 137 | switch (notification.getFeatureID(UnitMultiplication.class)) { |
| 138 | case UnitsPackage.UNIT_MULTIPLICATION__UNITS: |
| 139 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 140 | return; |
| 141 | } |
| 142 | super.notifyChanged(notification); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 147 | * that can be created under this object. |
| 148 | * <!-- begin-user-doc --> |
| 149 | * <!-- end-user-doc --> |
| 150 | * @generated |
| 151 | */ |
| 152 | @Override |
| 153 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 154 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 155 | |
| 156 | newChildDescriptors.add |
| 157 | (createChildParameter |
| 158 | (UnitsPackage.Literals.UNIT_MULTIPLICATION__UNITS, |
| 159 | UnitsFactory.eINSTANCE.createUnitMultiplication())); |
| 160 | |
| 161 | newChildDescriptors.add |
| 162 | (createChildParameter |
| 163 | (UnitsPackage.Literals.UNIT_MULTIPLICATION__UNITS, |
| 164 | UnitsFactory.eINSTANCE.createUnitPower())); |
| 165 | |
| 166 | newChildDescriptors.add |
| 167 | (createChildParameter |
| 168 | (UnitsPackage.Literals.UNIT_MULTIPLICATION__UNITS, |
| 169 | UnitsFactory.eINSTANCE.createUnitLiteral())); |
| 170 | } |
| 171 | |
| 172 | } |