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