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