1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EMOF.provider; |
8 | |
9 | |
10 | import EMOF.EMOFPackage; |
11 | import EMOF.MultiplicityElement; |
12 | |
13 | import java.util.Collection; |
14 | import java.util.List; |
15 | |
16 | import org.eclipse.emf.common.notify.AdapterFactory; |
17 | import org.eclipse.emf.common.notify.Notification; |
18 | |
19 | import org.eclipse.emf.common.util.ResourceLocator; |
20 | |
21 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
22 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
23 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
24 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
25 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
26 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
27 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
28 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
29 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link EMOF.MultiplicityElement} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class MultiplicityElementItemProvider |
39 | extends ItemProviderAdapter |
40 | implements |
41 | IEditingDomainItemProvider, |
42 | IStructuredItemContentProvider, |
43 | ITreeItemContentProvider, |
44 | IItemLabelProvider, |
45 | IItemPropertySource { |
46 | /** |
47 | * This constructs an instance from a factory and a notifier. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @generated |
51 | */ |
52 | public MultiplicityElementItemProvider(AdapterFactory adapterFactory) { |
53 | super(adapterFactory); |
54 | } |
55 | |
56 | /** |
57 | * This returns the property descriptors for the adapted class. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @generated |
61 | */ |
62 | @Override |
63 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
64 | if (itemPropertyDescriptors == null) { |
65 | super.getPropertyDescriptors(object); |
66 | |
67 | addIsOrderedPropertyDescriptor(object); |
68 | addIsUniquePropertyDescriptor(object); |
69 | addLowerPropertyDescriptor(object); |
70 | addUpperPropertyDescriptor(object); |
71 | } |
72 | return itemPropertyDescriptors; |
73 | } |
74 | |
75 | /** |
76 | * This adds a property descriptor for the Is Ordered feature. |
77 | * <!-- begin-user-doc --> |
78 | * <!-- end-user-doc --> |
79 | * @generated |
80 | */ |
81 | protected void addIsOrderedPropertyDescriptor(Object object) { |
82 | itemPropertyDescriptors.add |
83 | (createItemPropertyDescriptor |
84 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
85 | getResourceLocator(), |
86 | getString("_UI_MultiplicityElement_isOrdered_feature"), |
87 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_isOrdered_feature", "_UI_MultiplicityElement_type"), |
88 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__IS_ORDERED, |
89 | true, |
90 | false, |
91 | false, |
92 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
93 | null, |
94 | null)); |
95 | } |
96 | |
97 | /** |
98 | * This adds a property descriptor for the Is Unique feature. |
99 | * <!-- begin-user-doc --> |
100 | * <!-- end-user-doc --> |
101 | * @generated |
102 | */ |
103 | protected void addIsUniquePropertyDescriptor(Object object) { |
104 | itemPropertyDescriptors.add |
105 | (createItemPropertyDescriptor |
106 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
107 | getResourceLocator(), |
108 | getString("_UI_MultiplicityElement_isUnique_feature"), |
109 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_isUnique_feature", "_UI_MultiplicityElement_type"), |
110 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__IS_UNIQUE, |
111 | true, |
112 | false, |
113 | false, |
114 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
115 | null, |
116 | null)); |
117 | } |
118 | |
119 | /** |
120 | * This adds a property descriptor for the Lower feature. |
121 | * <!-- begin-user-doc --> |
122 | * <!-- end-user-doc --> |
123 | * @generated |
124 | */ |
125 | protected void addLowerPropertyDescriptor(Object object) { |
126 | itemPropertyDescriptors.add |
127 | (createItemPropertyDescriptor |
128 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
129 | getResourceLocator(), |
130 | getString("_UI_MultiplicityElement_lower_feature"), |
131 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_lower_feature", "_UI_MultiplicityElement_type"), |
132 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__LOWER, |
133 | true, |
134 | false, |
135 | false, |
136 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
137 | null, |
138 | null)); |
139 | } |
140 | |
141 | /** |
142 | * This adds a property descriptor for the Upper feature. |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | protected void addUpperPropertyDescriptor(Object object) { |
148 | itemPropertyDescriptors.add |
149 | (createItemPropertyDescriptor |
150 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
151 | getResourceLocator(), |
152 | getString("_UI_MultiplicityElement_upper_feature"), |
153 | getString("_UI_PropertyDescriptor_description", "_UI_MultiplicityElement_upper_feature", "_UI_MultiplicityElement_type"), |
154 | EMOFPackage.Literals.MULTIPLICITY_ELEMENT__UPPER, |
155 | true, |
156 | false, |
157 | false, |
158 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
159 | null, |
160 | null)); |
161 | } |
162 | |
163 | /** |
164 | * This returns the label text for the adapted class. |
165 | * <!-- begin-user-doc --> |
166 | * <!-- end-user-doc --> |
167 | * @generated |
168 | */ |
169 | @Override |
170 | public String getText(Object object) { |
171 | Boolean labelValue = ((MultiplicityElement)object).getIsOrdered(); |
172 | String label = labelValue == null ? null : labelValue.toString(); |
173 | return label == null || label.length() == 0 ? |
174 | getString("_UI_MultiplicityElement_type") : |
175 | getString("_UI_MultiplicityElement_type") + " " + label; |
176 | } |
177 | |
178 | /** |
179 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
180 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
181 | * <!-- begin-user-doc --> |
182 | * <!-- end-user-doc --> |
183 | * @generated |
184 | */ |
185 | @Override |
186 | public void notifyChanged(Notification notification) { |
187 | updateChildren(notification); |
188 | |
189 | switch (notification.getFeatureID(MultiplicityElement.class)) { |
190 | case EMOFPackage.MULTIPLICITY_ELEMENT__IS_ORDERED: |
191 | case EMOFPackage.MULTIPLICITY_ELEMENT__IS_UNIQUE: |
192 | case EMOFPackage.MULTIPLICITY_ELEMENT__LOWER: |
193 | case EMOFPackage.MULTIPLICITY_ELEMENT__UPPER: |
194 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
195 | return; |
196 | } |
197 | super.notifyChanged(notification); |
198 | } |
199 | |
200 | /** |
201 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
202 | * that can be created under this object. |
203 | * <!-- begin-user-doc --> |
204 | * <!-- end-user-doc --> |
205 | * @generated |
206 | */ |
207 | @Override |
208 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
209 | super.collectNewChildDescriptors(newChildDescriptors, object); |
210 | } |
211 | |
212 | /** |
213 | * Return the resource locator for this item provider's resources. |
214 | * <!-- begin-user-doc --> |
215 | * <!-- end-user-doc --> |
216 | * @generated |
217 | */ |
218 | @Override |
219 | public ResourceLocator getResourceLocator() { |
220 | return QvtmodelsEditPlugin.INSTANCE; |
221 | } |
222 | |
223 | } |