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