| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EMOF.provider; |
| 8 | |
| 9 | |
| 10 | import EMOF.EMOFFactory; |
| 11 | import EMOF.EMOFPackage; |
| 12 | |
| 13 | import QVTBase.QVTBaseFactory; |
| 14 | |
| 15 | import java.util.Collection; |
| 16 | import java.util.List; |
| 17 | |
| 18 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 19 | import org.eclipse.emf.common.notify.Notification; |
| 20 | |
| 21 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 22 | |
| 23 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 24 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 25 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 26 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 27 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 28 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 29 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 30 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 31 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 32 | |
| 33 | /** |
| 34 | * This is the item provider adapter for a {@link EMOF.Class} object. |
| 35 | * <!-- begin-user-doc --> |
| 36 | * <!-- end-user-doc --> |
| 37 | * @generated |
| 38 | */ |
| 39 | public class ClassItemProvider |
| 40 | extends TypeItemProvider |
| 41 | implements |
| 42 | IEditingDomainItemProvider, |
| 43 | IStructuredItemContentProvider, |
| 44 | ITreeItemContentProvider, |
| 45 | IItemLabelProvider, |
| 46 | IItemPropertySource { |
| 47 | /** |
| 48 | * This constructs an instance from a factory and a notifier. |
| 49 | * <!-- begin-user-doc --> |
| 50 | * <!-- end-user-doc --> |
| 51 | * @generated |
| 52 | */ |
| 53 | public ClassItemProvider(AdapterFactory adapterFactory) { |
| 54 | super(adapterFactory); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * This returns the property descriptors for the adapted class. |
| 59 | * <!-- begin-user-doc --> |
| 60 | * <!-- end-user-doc --> |
| 61 | * @generated |
| 62 | */ |
| 63 | @Override |
| 64 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 65 | if (itemPropertyDescriptors == null) { |
| 66 | super.getPropertyDescriptors(object); |
| 67 | |
| 68 | addIsAbstractPropertyDescriptor(object); |
| 69 | addSuperClassPropertyDescriptor(object); |
| 70 | } |
| 71 | return itemPropertyDescriptors; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * This adds a property descriptor for the Is Abstract feature. |
| 76 | * <!-- begin-user-doc --> |
| 77 | * <!-- end-user-doc --> |
| 78 | * @generated |
| 79 | */ |
| 80 | protected void addIsAbstractPropertyDescriptor(Object object) { |
| 81 | itemPropertyDescriptors.add |
| 82 | (createItemPropertyDescriptor |
| 83 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 84 | getResourceLocator(), |
| 85 | getString("_UI_Class_isAbstract_feature"), |
| 86 | getString("_UI_PropertyDescriptor_description", "_UI_Class_isAbstract_feature", "_UI_Class_type"), |
| 87 | EMOFPackage.Literals.CLASS__IS_ABSTRACT, |
| 88 | true, |
| 89 | false, |
| 90 | false, |
| 91 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
| 92 | null, |
| 93 | null)); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * This adds a property descriptor for the Super Class feature. |
| 98 | * <!-- begin-user-doc --> |
| 99 | * <!-- end-user-doc --> |
| 100 | * @generated |
| 101 | */ |
| 102 | protected void addSuperClassPropertyDescriptor(Object object) { |
| 103 | itemPropertyDescriptors.add |
| 104 | (createItemPropertyDescriptor |
| 105 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 106 | getResourceLocator(), |
| 107 | getString("_UI_Class_superClass_feature"), |
| 108 | getString("_UI_PropertyDescriptor_description", "_UI_Class_superClass_feature", "_UI_Class_type"), |
| 109 | EMOFPackage.Literals.CLASS__SUPER_CLASS, |
| 110 | true, |
| 111 | false, |
| 112 | true, |
| 113 | null, |
| 114 | null, |
| 115 | null)); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
| 120 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
| 121 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
| 122 | * <!-- begin-user-doc --> |
| 123 | * <!-- end-user-doc --> |
| 124 | * @generated |
| 125 | */ |
| 126 | @Override |
| 127 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
| 128 | if (childrenFeatures == null) { |
| 129 | super.getChildrenFeatures(object); |
| 130 | childrenFeatures.add(EMOFPackage.Literals.CLASS__OWNED_ATTRIBUTE); |
| 131 | childrenFeatures.add(EMOFPackage.Literals.CLASS__OWNED_OPERATION); |
| 132 | } |
| 133 | return childrenFeatures; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * <!-- begin-user-doc --> |
| 138 | * <!-- end-user-doc --> |
| 139 | * @generated |
| 140 | */ |
| 141 | @Override |
| 142 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 143 | // Check the type of the specified child object and return the proper feature to use for |
| 144 | // adding (see {@link AddCommand}) it as a child. |
| 145 | |
| 146 | return super.getChildFeature(object, child); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * This returns Class.gif. |
| 151 | * <!-- begin-user-doc --> |
| 152 | * <!-- end-user-doc --> |
| 153 | * @generated |
| 154 | */ |
| 155 | @Override |
| 156 | public Object getImage(Object object) { |
| 157 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Class")); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * This returns the label text for the adapted class. |
| 162 | * <!-- begin-user-doc --> |
| 163 | * <!-- end-user-doc --> |
| 164 | * @generated |
| 165 | */ |
| 166 | @Override |
| 167 | public String getText(Object object) { |
| 168 | String label = ((EMOF.Class)object).getName(); |
| 169 | return label == null || label.length() == 0 ? |
| 170 | getString("_UI_Class_type") : |
| 171 | getString("_UI_Class_type") + " " + label; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 176 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 177 | * <!-- begin-user-doc --> |
| 178 | * <!-- end-user-doc --> |
| 179 | * @generated |
| 180 | */ |
| 181 | @Override |
| 182 | public void notifyChanged(Notification notification) { |
| 183 | updateChildren(notification); |
| 184 | |
| 185 | switch (notification.getFeatureID(EMOF.Class.class)) { |
| 186 | case EMOFPackage.CLASS__IS_ABSTRACT: |
| 187 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 188 | return; |
| 189 | case EMOFPackage.CLASS__OWNED_ATTRIBUTE: |
| 190 | case EMOFPackage.CLASS__OWNED_OPERATION: |
| 191 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 192 | return; |
| 193 | } |
| 194 | super.notifyChanged(notification); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 199 | * that can be created under this object. |
| 200 | * <!-- begin-user-doc --> |
| 201 | * <!-- end-user-doc --> |
| 202 | * @generated |
| 203 | */ |
| 204 | @Override |
| 205 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 206 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 207 | |
| 208 | newChildDescriptors.add |
| 209 | (createChildParameter |
| 210 | (EMOFPackage.Literals.CLASS__OWNED_ATTRIBUTE, |
| 211 | EMOFFactory.eINSTANCE.createProperty())); |
| 212 | |
| 213 | newChildDescriptors.add |
| 214 | (createChildParameter |
| 215 | (EMOFPackage.Literals.CLASS__OWNED_OPERATION, |
| 216 | EMOFFactory.eINSTANCE.createOperation())); |
| 217 | |
| 218 | newChildDescriptors.add |
| 219 | (createChildParameter |
| 220 | (EMOFPackage.Literals.CLASS__OWNED_OPERATION, |
| 221 | QVTBaseFactory.eINSTANCE.createFunction())); |
| 222 | } |
| 223 | |
| 224 | } |