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.FeatureConfig; |
29 | import de.uka.ipd.sdq.featureconfig.FeatureConfigState; |
30 | import de.uka.ipd.sdq.featureconfig.featureconfigFactory; |
31 | import de.uka.ipd.sdq.featureconfig.featureconfigPackage; |
32 | |
33 | /** |
34 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.featureconfig.FeatureConfig} object. |
35 | * <!-- begin-user-doc --> |
36 | * <!-- end-user-doc --> |
37 | * @generated |
38 | */ |
39 | public class FeatureConfigItemProvider |
40 | extends ItemProviderAdapter |
41 | implements |
42 | IEditingDomainItemProvider, |
43 | IStructuredItemContentProvider, |
44 | ITreeItemContentProvider, |
45 | IItemLabelProvider, |
46 | IItemPropertySource { |
47 | /** |
48 | * This constructs an instance from a factory and a notifier. |
49 | * <!-- begin-user-doc --> |
50 | * <!-- end-user-doc --> |
51 | * @generated |
52 | */ |
53 | public FeatureConfigItemProvider(AdapterFactory adapterFactory) { |
54 | super(adapterFactory); |
55 | } |
56 | |
57 | /** |
58 | * This returns the property descriptors for the adapted class. |
59 | * <!-- begin-user-doc --> |
60 | * <!-- end-user-doc --> |
61 | * @generated |
62 | */ |
63 | @Override |
64 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
65 | if (itemPropertyDescriptors == null) { |
66 | super.getPropertyDescriptors(object); |
67 | |
68 | addFeatureConfigStatePropertyDescriptor(object); |
69 | addAnnotatedElementPropertyDescriptor(object); |
70 | } |
71 | return itemPropertyDescriptors; |
72 | } |
73 | |
74 | /** |
75 | * This adds a property descriptor for the Feature Config State feature. |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @generated |
79 | */ |
80 | protected void addFeatureConfigStatePropertyDescriptor(Object object) { |
81 | itemPropertyDescriptors.add |
82 | (createItemPropertyDescriptor |
83 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
84 | getResourceLocator(), |
85 | getString("_UI_FeatureConfig_featureConfigState_feature"), |
86 | getString("_UI_PropertyDescriptor_description", "_UI_FeatureConfig_featureConfigState_feature", "_UI_FeatureConfig_type"), |
87 | featureconfigPackage.Literals.FEATURE_CONFIG__FEATURE_CONFIG_STATE, |
88 | true, |
89 | false, |
90 | false, |
91 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
92 | null, |
93 | null)); |
94 | } |
95 | |
96 | /** |
97 | * This adds a property descriptor for the Annotated Element feature. |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | protected void addAnnotatedElementPropertyDescriptor(Object object) { |
103 | itemPropertyDescriptors.add |
104 | (createItemPropertyDescriptor |
105 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
106 | getResourceLocator(), |
107 | getString("_UI_FeatureConfig_annotatedElement_feature"), |
108 | getString("_UI_PropertyDescriptor_description", "_UI_FeatureConfig_annotatedElement_feature", "_UI_FeatureConfig_type"), |
109 | featureconfigPackage.Literals.FEATURE_CONFIG__ANNOTATED_ELEMENT, |
110 | true, |
111 | false, |
112 | true, |
113 | null, |
114 | null, |
115 | null)); |
116 | } |
117 | |
118 | /** |
119 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
120 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
121 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
122 | * <!-- begin-user-doc --> |
123 | * <!-- end-user-doc --> |
124 | * @generated |
125 | */ |
126 | @Override |
127 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
128 | if (childrenFeatures == null) { |
129 | super.getChildrenFeatures(object); |
130 | childrenFeatures.add(featureconfigPackage.Literals.FEATURE_CONFIG__CONFIGNODE); |
131 | } |
132 | return childrenFeatures; |
133 | } |
134 | |
135 | /** |
136 | * <!-- begin-user-doc --> |
137 | * <!-- end-user-doc --> |
138 | * @generated |
139 | */ |
140 | @Override |
141 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
142 | // Check the type of the specified child object and return the proper feature to use for |
143 | // adding (see {@link AddCommand}) it as a child. |
144 | |
145 | return super.getChildFeature(object, child); |
146 | } |
147 | |
148 | /** |
149 | * This returns FeatureConfig.gif. |
150 | * <!-- begin-user-doc --> |
151 | * <!-- end-user-doc --> |
152 | * @generated |
153 | */ |
154 | @Override |
155 | public Object getImage(Object object) { |
156 | return overlayImage(object, getResourceLocator().getImage("full/obj16/FeatureConfig")); |
157 | } |
158 | |
159 | /** |
160 | * This returns the label text for the adapted class. |
161 | * <!-- begin-user-doc --> |
162 | * <!-- end-user-doc --> |
163 | * @generated |
164 | */ |
165 | @Override |
166 | public String getText(Object object) { |
167 | FeatureConfigState labelValue = ((FeatureConfig)object).getFeatureConfigState(); |
168 | String label = labelValue == null ? null : labelValue.toString(); |
169 | return label == null || label.length() == 0 ? |
170 | getString("_UI_FeatureConfig_type") : |
171 | getString("_UI_FeatureConfig_type") + " " + label; |
172 | } |
173 | |
174 | /** |
175 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
176 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
177 | * <!-- begin-user-doc --> |
178 | * <!-- end-user-doc --> |
179 | * @generated |
180 | */ |
181 | @Override |
182 | public void notifyChanged(Notification notification) { |
183 | updateChildren(notification); |
184 | |
185 | switch (notification.getFeatureID(FeatureConfig.class)) { |
186 | case featureconfigPackage.FEATURE_CONFIG__FEATURE_CONFIG_STATE: |
187 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
188 | return; |
189 | case featureconfigPackage.FEATURE_CONFIG__CONFIGNODE: |
190 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
191 | return; |
192 | } |
193 | super.notifyChanged(notification); |
194 | } |
195 | |
196 | /** |
197 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
198 | * that can be created under this object. |
199 | * <!-- begin-user-doc --> |
200 | * <!-- end-user-doc --> |
201 | * @generated |
202 | */ |
203 | @Override |
204 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
205 | super.collectNewChildDescriptors(newChildDescriptors, object); |
206 | |
207 | newChildDescriptors.add |
208 | (createChildParameter |
209 | (featureconfigPackage.Literals.FEATURE_CONFIG__CONFIGNODE, |
210 | featureconfigFactory.eINSTANCE.createConfigNode())); |
211 | } |
212 | |
213 | /** |
214 | * Return the resource locator for this item provider's resources. |
215 | * <!-- begin-user-doc --> |
216 | * <!-- end-user-doc --> |
217 | * @generated |
218 | */ |
219 | @Override |
220 | public ResourceLocator getResourceLocator() { |
221 | return FeatureConfigEditPlugin.INSTANCE; |
222 | } |
223 | |
224 | } |