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