| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.qosannotations.provider; |
| 7 | |
| 8 | |
| 9 | import java.util.Collection; |
| 10 | import java.util.List; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.common.util.ResourceLocator; |
| 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.pcm.core.entity.provider.EntityItemProvider; |
| 25 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
| 26 | import de.uka.ipd.sdq.pcm.qosannotations.QoSAnnotations; |
| 27 | import de.uka.ipd.sdq.pcm.qosannotations.QosannotationsPackage; |
| 28 | import de.uka.ipd.sdq.pcm.qosannotations.qos_performance.Qos_performanceFactory; |
| 29 | import de.uka.ipd.sdq.pcm.qosannotations.qos_reliability.Qos_reliabilityFactory; |
| 30 | |
| 31 | /** |
| 32 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.qosannotations.QoSAnnotations} object. |
| 33 | * <!-- begin-user-doc --> |
| 34 | * <!-- end-user-doc --> |
| 35 | * @generated |
| 36 | */ |
| 37 | public class QoSAnnotationsItemProvider |
| 38 | extends EntityItemProvider |
| 39 | implements |
| 40 | IEditingDomainItemProvider, |
| 41 | IStructuredItemContentProvider, |
| 42 | ITreeItemContentProvider, |
| 43 | IItemLabelProvider, |
| 44 | IItemPropertySource { |
| 45 | /** |
| 46 | * <!-- begin-user-doc --> |
| 47 | * <!-- end-user-doc --> |
| 48 | * @generated |
| 49 | */ |
| 50 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 51 | |
| 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 QoSAnnotationsItemProvider(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(QosannotationsPackage.Literals.QO_SANNOTATIONS__SPECIFIED_OUTPUT_PARAMETER_ABSTRACTIONS_QO_SANNOTATIONS); |
| 90 | childrenFeatures.add(QosannotationsPackage.Literals.QO_SANNOTATIONS__SPECIFIED_QO_SANNOTATIONS_QO_SANNOTATIONS); |
| 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 QoSAnnotations.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/QoSAnnotations")); |
| 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 | String label = ((QoSAnnotations)object).getId(); |
| 128 | return label == null || label.length() == 0 ? |
| 129 | getString("_UI_QoSAnnotations_type") : |
| 130 | getString("_UI_QoSAnnotations_type") + " " + label; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 135 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 136 | * <!-- begin-user-doc --> |
| 137 | * <!-- end-user-doc --> |
| 138 | * @generated |
| 139 | */ |
| 140 | @Override |
| 141 | public void notifyChanged(Notification notification) { |
| 142 | updateChildren(notification); |
| 143 | |
| 144 | switch (notification.getFeatureID(QoSAnnotations.class)) { |
| 145 | case QosannotationsPackage.QO_SANNOTATIONS__SPECIFIED_OUTPUT_PARAMETER_ABSTRACTIONS_QO_SANNOTATIONS: |
| 146 | case QosannotationsPackage.QO_SANNOTATIONS__SPECIFIED_QO_SANNOTATIONS_QO_SANNOTATIONS: |
| 147 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 148 | return; |
| 149 | } |
| 150 | super.notifyChanged(notification); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 155 | * that can be created under this object. |
| 156 | * <!-- begin-user-doc --> |
| 157 | * <!-- end-user-doc --> |
| 158 | * @generated |
| 159 | */ |
| 160 | @Override |
| 161 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 162 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 163 | |
| 164 | newChildDescriptors.add |
| 165 | (createChildParameter |
| 166 | (QosannotationsPackage.Literals.QO_SANNOTATIONS__SPECIFIED_QO_SANNOTATIONS_QO_SANNOTATIONS, |
| 167 | Qos_performanceFactory.eINSTANCE.createSystemSpecifiedExecutionTime())); |
| 168 | |
| 169 | newChildDescriptors.add |
| 170 | (createChildParameter |
| 171 | (QosannotationsPackage.Literals.QO_SANNOTATIONS__SPECIFIED_QO_SANNOTATIONS_QO_SANNOTATIONS, |
| 172 | Qos_performanceFactory.eINSTANCE.createComponentSpecifiedExecutionTime())); |
| 173 | |
| 174 | newChildDescriptors.add |
| 175 | (createChildParameter |
| 176 | (QosannotationsPackage.Literals.QO_SANNOTATIONS__SPECIFIED_QO_SANNOTATIONS_QO_SANNOTATIONS, |
| 177 | Qos_reliabilityFactory.eINSTANCE.createSpecifiedReliabilityAnnotation())); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Return the resource locator for this item provider's resources. |
| 182 | * <!-- begin-user-doc --> |
| 183 | * <!-- end-user-doc --> |
| 184 | * @generated |
| 185 | */ |
| 186 | @Override |
| 187 | public ResourceLocator getResourceLocator() { |
| 188 | return PalladioComponentModelEditPlugin.INSTANCE; |
| 189 | } |
| 190 | |
| 191 | } |