1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.pcm.designdecision.GDoF.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.pcm.designdecision.GDoF.DegreeOfFreedom; |
11 | import de.uka.ipd.sdq.pcm.designdecision.GDoF.GDoFFactory; |
12 | import de.uka.ipd.sdq.pcm.designdecision.GDoF.GDoFPackage; |
13 | |
14 | import de.uka.ipd.sdq.pcm.designdecision.provider.DesignDecisionEditPlugin; |
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.ComposeableAdapterFactory; |
27 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
28 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
29 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
30 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
31 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
32 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
33 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
34 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
35 | import org.eclipse.emf.edit.provider.ViewerNotification; |
36 | |
37 | /** |
38 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.designdecision.GDoF.DegreeOfFreedom} object. |
39 | * <!-- begin-user-doc --> |
40 | * <!-- end-user-doc --> |
41 | * @generated |
42 | */ |
43 | public class DegreeOfFreedomItemProvider |
44 | extends ItemProviderAdapter |
45 | implements |
46 | IEditingDomainItemProvider, |
47 | IStructuredItemContentProvider, |
48 | ITreeItemContentProvider, |
49 | IItemLabelProvider, |
50 | IItemPropertySource { |
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 DegreeOfFreedomItemProvider(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 | addAddedElementsPropertyDescriptor(object); |
74 | addInteractionConstraintsPropertyDescriptor(object); |
75 | addPrimaryChangeablePropertyDescriptor(object); |
76 | } |
77 | return itemPropertyDescriptors; |
78 | } |
79 | |
80 | /** |
81 | * This adds a property descriptor for the Name feature. |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected void addNamePropertyDescriptor(Object object) { |
87 | itemPropertyDescriptors.add |
88 | (createItemPropertyDescriptor |
89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
90 | getResourceLocator(), |
91 | getString("_UI_DegreeOfFreedom_name_feature"), |
92 | getString("_UI_PropertyDescriptor_description", "_UI_DegreeOfFreedom_name_feature", "_UI_DegreeOfFreedom_type"), |
93 | GDoFPackage.Literals.DEGREE_OF_FREEDOM__NAME, |
94 | true, |
95 | false, |
96 | false, |
97 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
98 | null, |
99 | null)); |
100 | } |
101 | |
102 | /** |
103 | * This adds a property descriptor for the Added Elements feature. |
104 | * <!-- begin-user-doc --> |
105 | * <!-- end-user-doc --> |
106 | * @generated |
107 | */ |
108 | protected void addAddedElementsPropertyDescriptor(Object object) { |
109 | itemPropertyDescriptors.add |
110 | (createItemPropertyDescriptor |
111 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
112 | getResourceLocator(), |
113 | getString("_UI_DegreeOfFreedom_addedElements_feature"), |
114 | getString("_UI_PropertyDescriptor_description", "_UI_DegreeOfFreedom_addedElements_feature", "_UI_DegreeOfFreedom_type"), |
115 | GDoFPackage.Literals.DEGREE_OF_FREEDOM__ADDED_ELEMENTS, |
116 | true, |
117 | false, |
118 | true, |
119 | null, |
120 | null, |
121 | null)); |
122 | } |
123 | |
124 | /** |
125 | * This adds a property descriptor for the Interaction Constraints feature. |
126 | * <!-- begin-user-doc --> |
127 | * <!-- end-user-doc --> |
128 | * @generated |
129 | */ |
130 | protected void addInteractionConstraintsPropertyDescriptor(Object object) { |
131 | itemPropertyDescriptors.add |
132 | (createItemPropertyDescriptor |
133 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
134 | getResourceLocator(), |
135 | getString("_UI_DegreeOfFreedom_interactionConstraints_feature"), |
136 | getString("_UI_PropertyDescriptor_description", "_UI_DegreeOfFreedom_interactionConstraints_feature", "_UI_DegreeOfFreedom_type"), |
137 | GDoFPackage.Literals.DEGREE_OF_FREEDOM__INTERACTION_CONSTRAINTS, |
138 | true, |
139 | false, |
140 | true, |
141 | null, |
142 | null, |
143 | null)); |
144 | } |
145 | |
146 | /** |
147 | * This adds a property descriptor for the Primary Changeable feature. |
148 | * <!-- begin-user-doc --> |
149 | * <!-- end-user-doc --> |
150 | * @generated |
151 | */ |
152 | protected void addPrimaryChangeablePropertyDescriptor(Object object) { |
153 | itemPropertyDescriptors.add |
154 | (createItemPropertyDescriptor |
155 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
156 | getResourceLocator(), |
157 | getString("_UI_DegreeOfFreedom_primaryChangeable_feature"), |
158 | getString("_UI_PropertyDescriptor_description", "_UI_DegreeOfFreedom_primaryChangeable_feature", "_UI_DegreeOfFreedom_type"), |
159 | GDoFPackage.Literals.DEGREE_OF_FREEDOM__PRIMARY_CHANGEABLE, |
160 | true, |
161 | false, |
162 | true, |
163 | null, |
164 | null, |
165 | null)); |
166 | } |
167 | |
168 | /** |
169 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
170 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
171 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | @Override |
177 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
178 | if (childrenFeatures == null) { |
179 | super.getChildrenFeatures(object); |
180 | childrenFeatures.add(GDoFPackage.Literals.DEGREE_OF_FREEDOM__CHANGEABLE_ELEMENT_DESCRIPTIONS); |
181 | } |
182 | return childrenFeatures; |
183 | } |
184 | |
185 | /** |
186 | * <!-- begin-user-doc --> |
187 | * <!-- end-user-doc --> |
188 | * @generated |
189 | */ |
190 | @Override |
191 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
192 | // Check the type of the specified child object and return the proper feature to use for |
193 | // adding (see {@link AddCommand}) it as a child. |
194 | |
195 | return super.getChildFeature(object, child); |
196 | } |
197 | |
198 | /** |
199 | * This returns DegreeOfFreedom.gif. |
200 | * <!-- begin-user-doc --> |
201 | * <!-- end-user-doc --> |
202 | * @generated |
203 | */ |
204 | @Override |
205 | public Object getImage(Object object) { |
206 | return overlayImage(object, getResourceLocator().getImage("full/obj16/DegreeOfFreedom")); |
207 | } |
208 | |
209 | /** |
210 | * This returns the label text for the adapted class. |
211 | * <!-- begin-user-doc --> |
212 | * <!-- end-user-doc --> |
213 | * @generated |
214 | */ |
215 | @Override |
216 | public String getText(Object object) { |
217 | String label = ((DegreeOfFreedom)object).getName(); |
218 | return label == null || label.length() == 0 ? |
219 | getString("_UI_DegreeOfFreedom_type") : |
220 | getString("_UI_DegreeOfFreedom_type") + " " + label; |
221 | } |
222 | |
223 | /** |
224 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
225 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
226 | * <!-- begin-user-doc --> |
227 | * <!-- end-user-doc --> |
228 | * @generated |
229 | */ |
230 | @Override |
231 | public void notifyChanged(Notification notification) { |
232 | updateChildren(notification); |
233 | |
234 | switch (notification.getFeatureID(DegreeOfFreedom.class)) { |
235 | case GDoFPackage.DEGREE_OF_FREEDOM__NAME: |
236 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
237 | return; |
238 | case GDoFPackage.DEGREE_OF_FREEDOM__CHANGEABLE_ELEMENT_DESCRIPTIONS: |
239 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
240 | return; |
241 | } |
242 | super.notifyChanged(notification); |
243 | } |
244 | |
245 | /** |
246 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
247 | * that can be created under this object. |
248 | * <!-- begin-user-doc --> |
249 | * <!-- end-user-doc --> |
250 | * @generated |
251 | */ |
252 | @Override |
253 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
254 | super.collectNewChildDescriptors(newChildDescriptors, object); |
255 | |
256 | newChildDescriptors.add |
257 | (createChildParameter |
258 | (GDoFPackage.Literals.DEGREE_OF_FREEDOM__CHANGEABLE_ELEMENT_DESCRIPTIONS, |
259 | GDoFFactory.eINSTANCE.createChangeableElementDescription())); |
260 | } |
261 | |
262 | /** |
263 | * Return the resource locator for this item provider's resources. |
264 | * <!-- begin-user-doc --> |
265 | * <!-- end-user-doc --> |
266 | * @generated |
267 | */ |
268 | @Override |
269 | public ResourceLocator getResourceLocator() { |
270 | return DesignDecisionEditPlugin.INSTANCE; |
271 | } |
272 | |
273 | } |