| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.provider; |
| 8 | |
| 9 | |
| 10 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.EvaluationAspect; |
| 11 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractFactory; |
| 12 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractPackage; |
| 13 | |
| 14 | import de.uka.ipd.sdq.dsexplore.qml.profile.QMLProfile.provider.QMLProfileEditPlugin; |
| 15 | |
| 16 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProvider; |
| 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.IEditingDomainItemProvider; |
| 29 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 30 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 31 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 32 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 33 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 34 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 35 | |
| 36 | /** |
| 37 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.EvaluationAspect} object. |
| 38 | * <!-- begin-user-doc --> |
| 39 | * <!-- end-user-doc --> |
| 40 | * @generated |
| 41 | */ |
| 42 | public class EvaluationAspectItemProvider |
| 43 | extends IdentifierItemProvider |
| 44 | implements |
| 45 | IEditingDomainItemProvider, |
| 46 | IStructuredItemContentProvider, |
| 47 | ITreeItemContentProvider, |
| 48 | IItemLabelProvider, |
| 49 | IItemPropertySource { |
| 50 | /** |
| 51 | * This constructs an instance from a factory and a notifier. |
| 52 | * <!-- begin-user-doc --> |
| 53 | * <!-- end-user-doc --> |
| 54 | * @generated |
| 55 | */ |
| 56 | public EvaluationAspectItemProvider(AdapterFactory adapterFactory) { |
| 57 | super(adapterFactory); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * This returns the property descriptors for the adapted class. |
| 62 | * <!-- begin-user-doc --> |
| 63 | * <!-- end-user-doc --> |
| 64 | * @generated |
| 65 | */ |
| 66 | @Override |
| 67 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 68 | if (itemPropertyDescriptors == null) { |
| 69 | super.getPropertyDescriptors(object); |
| 70 | |
| 71 | } |
| 72 | return itemPropertyDescriptors; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 77 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 78 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | @Override |
| 84 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 85 | if (childrenFeatures == null) { |
| 86 | super.getChildrenFeatures(object); |
| 87 | childrenFeatures.add(QMLContractPackage.Literals.EVALUATION_ASPECT__ASPECT_REQUIREMENT); |
| 88 | } |
| 89 | return childrenFeatures; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | @Override |
| 98 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 99 | // Check the type of the specified child object and return the proper feature to use for |
| 100 | // adding (see {@link AddCommand}) it as a child. |
| 101 | |
| 102 | return super.getChildFeature(object, child); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * This returns the label text for the adapted class. |
| 107 | * <!-- begin-user-doc --> |
| 108 | * <!-- end-user-doc --> |
| 109 | * @generated |
| 110 | */ |
| 111 | @Override |
| 112 | public String getText(Object object) { |
| 113 | String label = ((EvaluationAspect)object).getId(); |
| 114 | return label == null || label.length() == 0 ? |
| 115 | getString("_UI_EvaluationAspect_type") : |
| 116 | getString("_UI_EvaluationAspect_type") + " " + label; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 121 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 122 | * <!-- begin-user-doc --> |
| 123 | * <!-- end-user-doc --> |
| 124 | * @generated |
| 125 | */ |
| 126 | @Override |
| 127 | public void notifyChanged(Notification notification) { |
| 128 | updateChildren(notification); |
| 129 | |
| 130 | switch (notification.getFeatureID(EvaluationAspect.class)) { |
| 131 | case QMLContractPackage.EVALUATION_ASPECT__ASPECT_REQUIREMENT: |
| 132 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 133 | return; |
| 134 | } |
| 135 | super.notifyChanged(notification); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 140 | * that can be created under this object. |
| 141 | * <!-- begin-user-doc --> |
| 142 | * <!-- end-user-doc --> |
| 143 | * @generated |
| 144 | */ |
| 145 | @Override |
| 146 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 147 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 148 | |
| 149 | newChildDescriptors.add |
| 150 | (createChildParameter |
| 151 | (QMLContractPackage.Literals.EVALUATION_ASPECT__ASPECT_REQUIREMENT, |
| 152 | QMLContractFactory.eINSTANCE.createRestriction())); |
| 153 | |
| 154 | newChildDescriptors.add |
| 155 | (createChildParameter |
| 156 | (QMLContractPackage.Literals.EVALUATION_ASPECT__ASPECT_REQUIREMENT, |
| 157 | QMLContractFactory.eINSTANCE.createGoal())); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Return the resource locator for this item provider's resources. |
| 162 | * <!-- begin-user-doc --> |
| 163 | * <!-- end-user-doc --> |
| 164 | * @generated |
| 165 | */ |
| 166 | @Override |
| 167 | public ResourceLocator getResourceLocator() { |
| 168 | return QMLProfileEditPlugin.INSTANCE; |
| 169 | } |
| 170 | |
| 171 | } |