1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featureconfig.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.ecore.EStructuralFeature; |
17 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
18 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
19 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
20 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
21 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
22 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
23 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
24 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
25 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
26 | import org.eclipse.emf.edit.provider.ViewerNotification; |
27 | |
28 | import de.uka.ipd.sdq.featureconfig.ConfigNode; |
29 | import de.uka.ipd.sdq.featureconfig.ConfigState; |
30 | import de.uka.ipd.sdq.featureconfig.featureconfigFactory; |
31 | import de.uka.ipd.sdq.featureconfig.featureconfigPackage; |
32 | import de.uka.ipd.sdq.featuremodel.Feature; |
33 | |
34 | /** |
35 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.featureconfig.ConfigNode} object. |
36 | * <!-- begin-user-doc --> |
37 | * <!-- end-user-doc --> |
38 | * @generated |
39 | */ |
40 | public class ConfigNodeItemProvider |
41 | extends ItemProviderAdapter |
42 | implements |
43 | IEditingDomainItemProvider, |
44 | IStructuredItemContentProvider, |
45 | ITreeItemContentProvider, |
46 | IItemLabelProvider, |
47 | IItemPropertySource { |
48 | /** |
49 | * This constructs an instance from a factory and a notifier. |
50 | * <!-- begin-user-doc --> |
51 | * <!-- end-user-doc --> |
52 | * @generated |
53 | */ |
54 | public ConfigNodeItemProvider(AdapterFactory adapterFactory) { |
55 | super(adapterFactory); |
56 | } |
57 | |
58 | /** |
59 | * This returns the property descriptors for the adapted class. |
60 | * <!-- begin-user-doc --> |
61 | * <!-- end-user-doc --> |
62 | * @generated |
63 | */ |
64 | @Override |
65 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
66 | if (itemPropertyDescriptors == null) { |
67 | super.getPropertyDescriptors(object); |
68 | |
69 | addOriginPropertyDescriptor(object); |
70 | addConfigStatePropertyDescriptor(object); |
71 | addAttributevaluePropertyDescriptor(object); |
72 | } |
73 | return itemPropertyDescriptors; |
74 | } |
75 | |
76 | /** |
77 | * This adds a property descriptor for the Origin feature. |
78 | * <!-- begin-user-doc --> |
79 | * <!-- end-user-doc --> |
80 | * @generated |
81 | */ |
82 | protected void addOriginPropertyDescriptor(Object object) { |
83 | itemPropertyDescriptors.add |
84 | (createItemPropertyDescriptor |
85 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
86 | getResourceLocator(), |
87 | getString("_UI_ConfigNode_origin_feature"), |
88 | getString("_UI_PropertyDescriptor_description", "_UI_ConfigNode_origin_feature", "_UI_ConfigNode_type"), |
89 | featureconfigPackage.Literals.CONFIG_NODE__ORIGIN, |
90 | true, |
91 | false, |
92 | true, |
93 | null, |
94 | null, |
95 | null)); |
96 | } |
97 | |
98 | /** |
99 | * This adds a property descriptor for the Config State feature. |
100 | * <!-- begin-user-doc --> |
101 | * <!-- end-user-doc --> |
102 | * @generated |
103 | */ |
104 | protected void addConfigStatePropertyDescriptor(Object object) { |
105 | itemPropertyDescriptors.add |
106 | (createItemPropertyDescriptor |
107 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
108 | getResourceLocator(), |
109 | getString("_UI_ConfigNode_configState_feature"), |
110 | getString("_UI_PropertyDescriptor_description", "_UI_ConfigNode_configState_feature", "_UI_ConfigNode_type"), |
111 | featureconfigPackage.Literals.CONFIG_NODE__CONFIG_STATE, |
112 | true, |
113 | false, |
114 | false, |
115 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
116 | null, |
117 | null)); |
118 | } |
119 | |
120 | /** |
121 | * This adds a property descriptor for the Attributevalue feature. |
122 | * <!-- begin-user-doc --> |
123 | * <!-- end-user-doc --> |
124 | * @generated |
125 | */ |
126 | protected void addAttributevaluePropertyDescriptor(Object object) { |
127 | itemPropertyDescriptors.add |
128 | (createItemPropertyDescriptor |
129 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
130 | getResourceLocator(), |
131 | getString("_UI_ConfigNode_attributevalue_feature"), |
132 | getString("_UI_PropertyDescriptor_description", "_UI_ConfigNode_attributevalue_feature", "_UI_ConfigNode_type"), |
133 | featureconfigPackage.Literals.CONFIG_NODE__ATTRIBUTEVALUE, |
134 | true, |
135 | false, |
136 | true, |
137 | null, |
138 | null, |
139 | null)); |
140 | } |
141 | |
142 | /** |
143 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
144 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
145 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
146 | * <!-- begin-user-doc --> |
147 | * <!-- end-user-doc --> |
148 | * @generated |
149 | */ |
150 | @Override |
151 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
152 | if (childrenFeatures == null) { |
153 | super.getChildrenFeatures(object); |
154 | childrenFeatures.add(featureconfigPackage.Literals.CONFIG_NODE__ATTRIBUTEVALUE); |
155 | } |
156 | return childrenFeatures; |
157 | } |
158 | |
159 | /** |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | @Override |
165 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
166 | // Check the type of the specified child object and return the proper feature to use for |
167 | // adding (see {@link AddCommand}) it as a child. |
168 | |
169 | return super.getChildFeature(object, child); |
170 | } |
171 | |
172 | /** |
173 | * This returns ConfigNode.gif. |
174 | * <!-- begin-user-doc --> |
175 | * <!-- end-user-doc --> |
176 | * @generated |
177 | */ |
178 | @Override |
179 | public Object getImage(Object object) { |
180 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ConfigNode")); |
181 | } |
182 | |
183 | /** |
184 | * This returns the label text for the adapted class. |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated NOT |
188 | */ |
189 | @Override |
190 | public String getText(Object object) { |
191 | //<user-generated> |
192 | Feature originValue = ConfigNode.class.cast(object).getOrigin(); |
193 | String origin = originValue == null? null: originValue.getName(); |
194 | //</user-generated> |
195 | ConfigState labelValue = ((ConfigNode)object).getConfigState(); |
196 | String label = labelValue == null ? null : labelValue.toString(); |
197 | return label == null || label.length() == 0 ? |
198 | getString("_UI_ConfigNode_type") : |
199 | //<user-modified> |
200 | origin == null || origin.length() == 0 ? |
201 | getString("_UI_ConfigNode_type") + " " + label : |
202 | getString("_UI_ConfigNode_type") + " " + label + " " + origin; |
203 | //</user-modified> |
204 | } |
205 | |
206 | /** |
207 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
208 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
209 | * <!-- begin-user-doc --> |
210 | * <!-- end-user-doc --> |
211 | * @generated NOT |
212 | */ |
213 | @Override |
214 | public void notifyChanged(Notification notification) { |
215 | updateChildren(notification); |
216 | |
217 | switch (notification.getFeatureID(ConfigNode.class)) { |
218 | case featureconfigPackage.CONFIG_NODE__CONFIG_STATE: |
219 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
220 | return; |
221 | //<user-added> |
222 | case featureconfigPackage.CONFIG_NODE__ORIGIN: |
223 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
224 | return; |
225 | //</user-added> |
226 | case featureconfigPackage.CONFIG_NODE__ATTRIBUTEVALUE: |
227 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
228 | return; |
229 | } |
230 | super.notifyChanged(notification); |
231 | } |
232 | |
233 | /** |
234 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
235 | * that can be created under this object. |
236 | * <!-- begin-user-doc --> |
237 | * <!-- end-user-doc --> |
238 | * @generated |
239 | */ |
240 | @Override |
241 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
242 | super.collectNewChildDescriptors(newChildDescriptors, object); |
243 | |
244 | newChildDescriptors.add |
245 | (createChildParameter |
246 | (featureconfigPackage.Literals.CONFIG_NODE__ATTRIBUTEVALUE, |
247 | featureconfigFactory.eINSTANCE.createIntegerAttributeValue())); |
248 | |
249 | newChildDescriptors.add |
250 | (createChildParameter |
251 | (featureconfigPackage.Literals.CONFIG_NODE__ATTRIBUTEVALUE, |
252 | featureconfigFactory.eINSTANCE.createDoubleAttributeValue())); |
253 | |
254 | newChildDescriptors.add |
255 | (createChildParameter |
256 | (featureconfigPackage.Literals.CONFIG_NODE__ATTRIBUTEVALUE, |
257 | featureconfigFactory.eINSTANCE.createStringAttributeValue())); |
258 | |
259 | newChildDescriptors.add |
260 | (createChildParameter |
261 | (featureconfigPackage.Literals.CONFIG_NODE__ATTRIBUTEVALUE, |
262 | featureconfigFactory.eINSTANCE.createExternalObjectAttributeValue())); |
263 | } |
264 | |
265 | /** |
266 | * Return the resource locator for this item provider's resources. |
267 | * <!-- begin-user-doc --> |
268 | * <!-- end-user-doc --> |
269 | * @generated |
270 | */ |
271 | @Override |
272 | public ResourceLocator getResourceLocator() { |
273 | return FeatureConfigEditPlugin.INSTANCE; |
274 | } |
275 | |
276 | } |