| 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.common.util.ResourceLocator; |
| 16 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 17 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 18 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 19 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 20 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 21 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 22 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 23 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 24 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
| 25 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 26 | |
| 27 | import de.uka.ipd.sdq.units.BaseUnit; |
| 28 | import de.uka.ipd.sdq.units.UnitsPackage; |
| 29 | |
| 30 | /** |
| 31 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.units.BaseUnit} object. |
| 32 | * <!-- begin-user-doc --> |
| 33 | * <!-- end-user-doc --> |
| 34 | * @generated |
| 35 | */ |
| 36 | public class BaseUnitItemProvider |
| 37 | extends ItemProviderAdapter |
| 38 | implements |
| 39 | IEditingDomainItemProvider, |
| 40 | IStructuredItemContentProvider, |
| 41 | ITreeItemContentProvider, |
| 42 | IItemLabelProvider, |
| 43 | IItemPropertySource { |
| 44 | /** |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @generated |
| 48 | */ |
| 49 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 50 | |
| 51 | /** |
| 52 | * This constructs an instance from a factory and a notifier. |
| 53 | * <!-- begin-user-doc --> |
| 54 | * <!-- end-user-doc --> |
| 55 | * @generated |
| 56 | */ |
| 57 | public BaseUnitItemProvider(AdapterFactory adapterFactory) { |
| 58 | super(adapterFactory); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * This returns the property descriptors for the adapted class. |
| 63 | * <!-- begin-user-doc --> |
| 64 | * <!-- end-user-doc --> |
| 65 | * @generated |
| 66 | */ |
| 67 | @Override |
| 68 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 69 | if (itemPropertyDescriptors == null) { |
| 70 | super.getPropertyDescriptors(object); |
| 71 | |
| 72 | addNamePropertyDescriptor(object); |
| 73 | } |
| 74 | return itemPropertyDescriptors; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * This adds a property descriptor for the Name feature. |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | protected void addNamePropertyDescriptor(Object object) { |
| 84 | itemPropertyDescriptors.add |
| 85 | (createItemPropertyDescriptor |
| 86 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 87 | getResourceLocator(), |
| 88 | getString("_UI_BaseUnit_name_feature"), |
| 89 | getString("_UI_PropertyDescriptor_description", "_UI_BaseUnit_name_feature", "_UI_BaseUnit_type"), |
| 90 | UnitsPackage.Literals.BASE_UNIT__NAME, |
| 91 | true, |
| 92 | false, |
| 93 | false, |
| 94 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
| 95 | null, |
| 96 | null)); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * This returns BaseUnit.gif. |
| 101 | * <!-- begin-user-doc --> |
| 102 | * <!-- end-user-doc --> |
| 103 | * @generated |
| 104 | */ |
| 105 | @Override |
| 106 | public Object getImage(Object object) { |
| 107 | return overlayImage(object, getResourceLocator().getImage("full/obj16/BaseUnit")); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * This returns the label text for the adapted class. |
| 112 | * <!-- begin-user-doc --> |
| 113 | * <!-- end-user-doc --> |
| 114 | * @generated |
| 115 | */ |
| 116 | @Override |
| 117 | public String getText(Object object) { |
| 118 | String label = ((BaseUnit)object).getName(); |
| 119 | return label == null || label.length() == 0 ? |
| 120 | getString("_UI_BaseUnit_type") : |
| 121 | getString("_UI_BaseUnit_type") + " " + label; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 126 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | @Override |
| 132 | public void notifyChanged(Notification notification) { |
| 133 | updateChildren(notification); |
| 134 | |
| 135 | switch (notification.getFeatureID(BaseUnit.class)) { |
| 136 | case UnitsPackage.BASE_UNIT__NAME: |
| 137 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 138 | return; |
| 139 | } |
| 140 | super.notifyChanged(notification); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 145 | * that can be created under this object. |
| 146 | * <!-- begin-user-doc --> |
| 147 | * <!-- end-user-doc --> |
| 148 | * @generated |
| 149 | */ |
| 150 | @Override |
| 151 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 152 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Return the resource locator for this item provider's resources. |
| 157 | * <!-- begin-user-doc --> |
| 158 | * <!-- end-user-doc --> |
| 159 | * @generated |
| 160 | */ |
| 161 | @Override |
| 162 | public ResourceLocator getResourceLocator() { |
| 163 | return UnitsEditPlugin.INSTANCE; |
| 164 | } |
| 165 | |
| 166 | } |