1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.DimensionTypeNumeric; |
11 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypeFactory; |
12 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypePackage; |
13 | |
14 | import java.util.Collection; |
15 | import java.util.List; |
16 | |
17 | import org.eclipse.emf.common.notify.AdapterFactory; |
18 | import org.eclipse.emf.common.notify.Notification; |
19 | |
20 | import org.eclipse.emf.ecore.EStructuralFeature; |
21 | |
22 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
23 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
24 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
25 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
26 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
27 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
28 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
29 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.DimensionTypeNumeric} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class DimensionTypeNumericItemProvider |
39 | extends DimensionTypeItemProvider |
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 DimensionTypeNumericItemProvider(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 | addDomainPropertyDescriptor(object); |
68 | } |
69 | return itemPropertyDescriptors; |
70 | } |
71 | |
72 | /** |
73 | * This adds a property descriptor for the Domain feature. |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @generated |
77 | */ |
78 | protected void addDomainPropertyDescriptor(Object object) { |
79 | itemPropertyDescriptors.add |
80 | (createItemPropertyDescriptor |
81 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
82 | getResourceLocator(), |
83 | getString("_UI_DimensionTypeNumeric_domain_feature"), |
84 | getString("_UI_PropertyDescriptor_description", "_UI_DimensionTypeNumeric_domain_feature", "_UI_DimensionTypeNumeric_type"), |
85 | QMLContractTypePackage.Literals.DIMENSION_TYPE_NUMERIC__DOMAIN, |
86 | true, |
87 | false, |
88 | false, |
89 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
90 | null, |
91 | null)); |
92 | } |
93 | |
94 | /** |
95 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
96 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
97 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | @Override |
103 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
104 | if (childrenFeatures == null) { |
105 | super.getChildrenFeatures(object); |
106 | childrenFeatures.add(QMLContractTypePackage.Literals.DIMENSION_TYPE_NUMERIC__RANGE); |
107 | } |
108 | return childrenFeatures; |
109 | } |
110 | |
111 | /** |
112 | * <!-- begin-user-doc --> |
113 | * <!-- end-user-doc --> |
114 | * @generated |
115 | */ |
116 | @Override |
117 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
118 | // Check the type of the specified child object and return the proper feature to use for |
119 | // adding (see {@link AddCommand}) it as a child. |
120 | |
121 | return super.getChildFeature(object, child); |
122 | } |
123 | |
124 | /** |
125 | * This returns DimensionTypeNumeric.gif. |
126 | * <!-- begin-user-doc --> |
127 | * <!-- end-user-doc --> |
128 | * @generated |
129 | */ |
130 | @Override |
131 | public Object getImage(Object object) { |
132 | return overlayImage(object, getResourceLocator().getImage("full/obj16/DimensionTypeNumeric")); |
133 | } |
134 | |
135 | /** |
136 | * This returns the label text for the adapted class. |
137 | * <!-- begin-user-doc --> |
138 | * <!-- end-user-doc --> |
139 | * @generated |
140 | */ |
141 | @Override |
142 | public String getText(Object object) { |
143 | String label = ((DimensionTypeNumeric)object).getId(); |
144 | return label == null || label.length() == 0 ? |
145 | getString("_UI_DimensionTypeNumeric_type") : |
146 | getString("_UI_DimensionTypeNumeric_type") + " " + label; |
147 | } |
148 | |
149 | /** |
150 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
151 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
152 | * <!-- begin-user-doc --> |
153 | * <!-- end-user-doc --> |
154 | * @generated |
155 | */ |
156 | @Override |
157 | public void notifyChanged(Notification notification) { |
158 | updateChildren(notification); |
159 | |
160 | switch (notification.getFeatureID(DimensionTypeNumeric.class)) { |
161 | case QMLContractTypePackage.DIMENSION_TYPE_NUMERIC__DOMAIN: |
162 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
163 | return; |
164 | case QMLContractTypePackage.DIMENSION_TYPE_NUMERIC__RANGE: |
165 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
166 | return; |
167 | } |
168 | super.notifyChanged(notification); |
169 | } |
170 | |
171 | /** |
172 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
173 | * that can be created under this object. |
174 | * <!-- begin-user-doc --> |
175 | * <!-- end-user-doc --> |
176 | * @generated |
177 | */ |
178 | @Override |
179 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
180 | super.collectNewChildDescriptors(newChildDescriptors, object); |
181 | |
182 | newChildDescriptors.add |
183 | (createChildParameter |
184 | (QMLContractTypePackage.Literals.DIMENSION_TYPE_NUMERIC__RANGE, |
185 | QMLContractTypeFactory.eINSTANCE.createNumericRange())); |
186 | } |
187 | |
188 | } |