| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.pcm.designdecision.provider; |
| 8 | |
| 9 | |
| 10 | import de.uka.ipd.sdq.pcm.designdecision.Choice; |
| 11 | import de.uka.ipd.sdq.pcm.designdecision.designdecisionPackage; |
| 12 | |
| 13 | import java.util.Collection; |
| 14 | import java.util.List; |
| 15 | |
| 16 | import org.eclipse.emf.common.notify.AdapterFactory; |
| 17 | import org.eclipse.emf.common.notify.Notification; |
| 18 | |
| 19 | import org.eclipse.emf.common.util.ResourceLocator; |
| 20 | |
| 21 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| 22 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
| 23 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
| 24 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
| 25 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
| 26 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
| 27 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
| 28 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| 29 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
| 30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
| 31 | |
| 32 | /** |
| 33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.designdecision.Choice} object. |
| 34 | * <!-- begin-user-doc --> |
| 35 | * <!-- end-user-doc --> |
| 36 | * @generated |
| 37 | */ |
| 38 | public class ChoiceItemProvider |
| 39 | extends ItemProviderAdapter |
| 40 | implements |
| 41 | IEditingDomainItemProvider, |
| 42 | IStructuredItemContentProvider, |
| 43 | ITreeItemContentProvider, |
| 44 | IItemLabelProvider, |
| 45 | IItemPropertySource { |
| 46 | /** |
| 47 | * This constructs an instance from a factory and a notifier. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @generated |
| 51 | */ |
| 52 | public ChoiceItemProvider(AdapterFactory adapterFactory) { |
| 53 | super(adapterFactory); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * This returns the property descriptors for the adapted class. |
| 58 | * <!-- begin-user-doc --> |
| 59 | * <!-- end-user-doc --> |
| 60 | * @generated |
| 61 | */ |
| 62 | @Override |
| 63 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
| 64 | if (itemPropertyDescriptors == null) { |
| 65 | super.getPropertyDescriptors(object); |
| 66 | |
| 67 | addIsActivePropertyDescriptor(object); |
| 68 | addDegreeOfFreedomInstancePropertyDescriptor(object); |
| 69 | } |
| 70 | return itemPropertyDescriptors; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * This adds a property descriptor for the Is Active feature. |
| 75 | * <!-- begin-user-doc --> |
| 76 | * <!-- end-user-doc --> |
| 77 | * @generated |
| 78 | */ |
| 79 | protected void addIsActivePropertyDescriptor(Object object) { |
| 80 | itemPropertyDescriptors.add |
| 81 | (createItemPropertyDescriptor |
| 82 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 83 | getResourceLocator(), |
| 84 | getString("_UI_Choice_isActive_feature"), |
| 85 | getString("_UI_PropertyDescriptor_description", "_UI_Choice_isActive_feature", "_UI_Choice_type"), |
| 86 | designdecisionPackage.Literals.CHOICE__IS_ACTIVE, |
| 87 | true, |
| 88 | false, |
| 89 | false, |
| 90 | ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, |
| 91 | null, |
| 92 | null)); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * This adds a property descriptor for the Degree Of Freedom Instance feature. |
| 97 | * <!-- begin-user-doc --> |
| 98 | * <!-- end-user-doc --> |
| 99 | * @generated |
| 100 | */ |
| 101 | protected void addDegreeOfFreedomInstancePropertyDescriptor(Object object) { |
| 102 | itemPropertyDescriptors.add |
| 103 | (createItemPropertyDescriptor |
| 104 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
| 105 | getResourceLocator(), |
| 106 | getString("_UI_Choice_degreeOfFreedomInstance_feature"), |
| 107 | getString("_UI_PropertyDescriptor_description", "_UI_Choice_degreeOfFreedomInstance_feature", "_UI_Choice_type"), |
| 108 | designdecisionPackage.Literals.CHOICE__DEGREE_OF_FREEDOM_INSTANCE, |
| 109 | true, |
| 110 | false, |
| 111 | true, |
| 112 | null, |
| 113 | null, |
| 114 | null)); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * This returns the label text for the adapted class. |
| 119 | * <!-- begin-user-doc --> |
| 120 | * <!-- end-user-doc --> |
| 121 | * @generated |
| 122 | */ |
| 123 | @Override |
| 124 | public String getText(Object object) { |
| 125 | Choice choice = (Choice)object; |
| 126 | return getString("_UI_Choice_type") + " " + choice.isActive(); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
| 131 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | @Override |
| 137 | public void notifyChanged(Notification notification) { |
| 138 | updateChildren(notification); |
| 139 | |
| 140 | switch (notification.getFeatureID(Choice.class)) { |
| 141 | case designdecisionPackage.CHOICE__IS_ACTIVE: |
| 142 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
| 143 | return; |
| 144 | } |
| 145 | super.notifyChanged(notification); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
| 150 | * that can be created under this object. |
| 151 | * <!-- begin-user-doc --> |
| 152 | * <!-- end-user-doc --> |
| 153 | * @generated |
| 154 | */ |
| 155 | @Override |
| 156 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| 157 | super.collectNewChildDescriptors(newChildDescriptors, object); |
| 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 DesignDecisionEditPlugin.INSTANCE; |
| 169 | } |
| 170 | |
| 171 | } |