1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.Criterion; |
11 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractFactory; |
12 | import de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.QMLContractPackage; |
13 | |
14 | import de.uka.ipd.sdq.dsexplore.qml.profile.QMLProfile.provider.QMLProfileEditPlugin; |
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.ComposeableAdapterFactory; |
29 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
30 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
31 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
32 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
33 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
34 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
35 | import org.eclipse.emf.edit.provider.ViewerNotification; |
36 | |
37 | /** |
38 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.dsexplore.qml.contract.QMLContract.Criterion} object. |
39 | * <!-- begin-user-doc --> |
40 | * <!-- end-user-doc --> |
41 | * @generated |
42 | */ |
43 | public class CriterionItemProvider |
44 | extends IdentifierItemProvider |
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 CriterionItemProvider(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 | addDimensionPropertyDescriptor(object); |
73 | } |
74 | return itemPropertyDescriptors; |
75 | } |
76 | |
77 | /** |
78 | * This adds a property descriptor for the Dimension feature. |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | protected void addDimensionPropertyDescriptor(Object object) { |
84 | itemPropertyDescriptors.add |
85 | (createItemPropertyDescriptor |
86 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
87 | getResourceLocator(), |
88 | getString("_UI_Criterion_dimension_feature"), |
89 | getString("_UI_PropertyDescriptor_description", "_UI_Criterion_dimension_feature", "_UI_Criterion_type"), |
90 | QMLContractPackage.Literals.CRITERION__DIMENSION, |
91 | true, |
92 | false, |
93 | true, |
94 | null, |
95 | null, |
96 | null)); |
97 | } |
98 | |
99 | /** |
100 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
101 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
102 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | @Override |
108 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
109 | if (childrenFeatures == null) { |
110 | super.getChildrenFeatures(object); |
111 | childrenFeatures.add(QMLContractPackage.Literals.CRITERION__ASPECTS); |
112 | } |
113 | return childrenFeatures; |
114 | } |
115 | |
116 | /** |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | @Override |
122 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
123 | // Check the type of the specified child object and return the proper feature to use for |
124 | // adding (see {@link AddCommand}) it as a child. |
125 | |
126 | return super.getChildFeature(object, child); |
127 | } |
128 | |
129 | /** |
130 | * This returns the label text for the adapted class. |
131 | * <!-- begin-user-doc --> |
132 | * <!-- end-user-doc --> |
133 | * @generated |
134 | */ |
135 | @Override |
136 | public String getText(Object object) { |
137 | String label = ((Criterion)object).getId(); |
138 | return label == null || label.length() == 0 ? |
139 | getString("_UI_Criterion_type") : |
140 | getString("_UI_Criterion_type") + " " + label; |
141 | } |
142 | |
143 | /** |
144 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
145 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
146 | * <!-- begin-user-doc --> |
147 | * <!-- end-user-doc --> |
148 | * @generated |
149 | */ |
150 | @Override |
151 | public void notifyChanged(Notification notification) { |
152 | updateChildren(notification); |
153 | |
154 | switch (notification.getFeatureID(Criterion.class)) { |
155 | case QMLContractPackage.CRITERION__ASPECTS: |
156 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
157 | return; |
158 | } |
159 | super.notifyChanged(notification); |
160 | } |
161 | |
162 | /** |
163 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
164 | * that can be created under this object. |
165 | * <!-- begin-user-doc --> |
166 | * <!-- end-user-doc --> |
167 | * @generated |
168 | */ |
169 | @Override |
170 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
171 | super.collectNewChildDescriptors(newChildDescriptors, object); |
172 | |
173 | newChildDescriptors.add |
174 | (createChildParameter |
175 | (QMLContractPackage.Literals.CRITERION__ASPECTS, |
176 | QMLContractFactory.eINSTANCE.createPercentile())); |
177 | |
178 | newChildDescriptors.add |
179 | (createChildParameter |
180 | (QMLContractPackage.Literals.CRITERION__ASPECTS, |
181 | QMLContractFactory.eINSTANCE.createFrequency())); |
182 | |
183 | newChildDescriptors.add |
184 | (createChildParameter |
185 | (QMLContractPackage.Literals.CRITERION__ASPECTS, |
186 | QMLContractFactory.eINSTANCE.createMean())); |
187 | |
188 | newChildDescriptors.add |
189 | (createChildParameter |
190 | (QMLContractPackage.Literals.CRITERION__ASPECTS, |
191 | QMLContractFactory.eINSTANCE.createVariance())); |
192 | |
193 | newChildDescriptors.add |
194 | (createChildParameter |
195 | (QMLContractPackage.Literals.CRITERION__ASPECTS, |
196 | QMLContractFactory.eINSTANCE.createValue())); |
197 | } |
198 | |
199 | /** |
200 | * Return the resource locator for this item provider's resources. |
201 | * <!-- begin-user-doc --> |
202 | * <!-- end-user-doc --> |
203 | * @generated |
204 | */ |
205 | @Override |
206 | public ResourceLocator getResourceLocator() { |
207 | return QMLProfileEditPlugin.INSTANCE; |
208 | } |
209 | |
210 | } |