| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package QVTRelation.provider; |
| 8 | |
| 9 | |
| 10 | import EMOF.EMOFPackage; |
| 11 | |
| 12 | import EMOF.provider.QvtmodelsEditPlugin; |
| 13 | |
| 14 | import QVTBase.provider.TransformationItemProvider; |
| 15 | |
| 16 | import QVTRelation.QVTRelationFactory; |
| 17 | import QVTRelation.QVTRelationPackage; |
| 18 | import QVTRelation.RelationalTransformation; |
| 19 | |
| 20 | import java.util.Collection; |
| 21 | import java.util.List; |
| 22 | |
| 23 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 24 | import org.eclipse.emf.common.notify.Notification; |
| 25 | |
| 26 | import org.eclipse.emf.common.util.ResourceLocator; |
| 27 | |
| 28 | import org.eclipse.emf.ecore.EStructuralFeature; |
| 29 | |
| 30 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 31 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 32 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 33 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 34 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 35 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 36 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 37 | |
| 38 | /** |
| 39 | * This is the item provider adapter for a {@link QVTRelation.RelationalTransformation} object. |
| 40 | * <!-- begin-user-doc --> |
| 41 | * <!-- end-user-doc --> |
| 42 | * @generated |
| 43 | */ |
| 44 | public class RelationalTransformationItemProvider |
| 45 | extends TransformationItemProvider |
| 46 | implements |
| 47 | IEditingDomainItemProvider, |
| 48 | IStructuredItemContentProvider, |
| 49 | ITreeItemContentProvider, |
| 50 | IItemLabelProvider, |
| 51 | IItemPropertySource { |
| 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 RelationalTransformationItemProvider(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(QVTRelationPackage.Literals.RELATIONAL_TRANSFORMATION__OWNED_KEY); |
| 90 | } |
| 91 | return childrenFeatures; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * <!-- begin-user-doc --> |
| 96 | * <!-- end-user-doc --> |
| 97 | * @generated |
| 98 | */ |
| 99 | @Override |
| 100 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
| 101 | // Check the type of the specified child object and return the proper feature to use for |
| 102 | // adding (see {@link AddCommand}) it as a child. |
| 103 | |
| 104 | return super.getChildFeature(object, child); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * This returns RelationalTransformation.gif. |
| 109 | * <!-- begin-user-doc --> |
| 110 | * <!-- end-user-doc --> |
| 111 | * @generated |
| 112 | */ |
| 113 | @Override |
| 114 | public Object getImage(Object object) { |
| 115 | return overlayImage(object, getResourceLocator().getImage("full/obj16/RelationalTransformation")); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * This returns the label text for the adapted class. |
| 120 | * <!-- begin-user-doc --> |
| 121 | * <!-- end-user-doc --> |
| 122 | * @generated |
| 123 | */ |
| 124 | @Override |
| 125 | public String getText(Object object) { |
| 126 | String label = ((RelationalTransformation)object).getName(); |
| 127 | return label == null || label.length() == 0 ? |
| 128 | getString("_UI_RelationalTransformation_type") : |
| 129 | getString("_UI_RelationalTransformation_type") + " " + label; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 134 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 135 | * <!-- begin-user-doc --> |
| 136 | * <!-- end-user-doc --> |
| 137 | * @generated |
| 138 | */ |
| 139 | @Override |
| 140 | public void notifyChanged(Notification notification) { |
| 141 | updateChildren(notification); |
| 142 | |
| 143 | switch (notification.getFeatureID(RelationalTransformation.class)) { |
| 144 | case QVTRelationPackage.RELATIONAL_TRANSFORMATION__OWNED_KEY: |
| 145 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
| 146 | return; |
| 147 | } |
| 148 | super.notifyChanged(notification); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 153 | * that can be created under this object. |
| 154 | * <!-- begin-user-doc --> |
| 155 | * <!-- end-user-doc --> |
| 156 | * @generated |
| 157 | */ |
| 158 | @Override |
| 159 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 160 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 161 | |
| 162 | newChildDescriptors.add |
| 163 | (createChildParameter |
| 164 | (QVTRelationPackage.Literals.RELATIONAL_TRANSFORMATION__OWNED_KEY, |
| 165 | QVTRelationFactory.eINSTANCE.createKey())); |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
| 170 | * <!-- begin-user-doc --> |
| 171 | * <!-- end-user-doc --> |
| 172 | * @generated |
| 173 | */ |
| 174 | @Override |
| 175 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
| 176 | Object childFeature = feature; |
| 177 | Object childObject = child; |
| 178 | |
| 179 | boolean qualify = |
| 180 | childFeature == EMOFPackage.Literals.PACKAGE__NESTED_PACKAGE || |
| 181 | childFeature == EMOFPackage.Literals.PACKAGE__OWNED_TYPE; |
| 182 | |
| 183 | if (qualify) { |
| 184 | return getString |
| 185 | ("_UI_CreateChild_text2", |
| 186 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
| 187 | } |
| 188 | return super.getCreateChildText(owner, feature, child, selection); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Return the resource locator for this item provider's resources. |
| 193 | * <!-- begin-user-doc --> |
| 194 | * <!-- end-user-doc --> |
| 195 | * @generated |
| 196 | */ |
| 197 | @Override |
| 198 | public ResourceLocator getResourceLocator() { |
| 199 | return QvtmodelsEditPlugin.INSTANCE; |
| 200 | } |
| 201 | |
| 202 | } |