1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featureconfig.provider; |
8 | |
9 | |
10 | import java.util.Collection; |
11 | import java.util.List; |
12 | |
13 | import org.eclipse.emf.common.notify.AdapterFactory; |
14 | import org.eclipse.emf.common.notify.Notification; |
15 | import org.eclipse.emf.common.util.ResourceLocator; |
16 | import org.eclipse.emf.ecore.EStructuralFeature; |
17 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
18 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
19 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
20 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
21 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
22 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
23 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
24 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
25 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
26 | import org.eclipse.emf.edit.provider.ViewerNotification; |
27 | |
28 | import de.uka.ipd.sdq.featureconfig.Configuration; |
29 | import de.uka.ipd.sdq.featureconfig.featureconfigFactory; |
30 | import de.uka.ipd.sdq.featureconfig.featureconfigPackage; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.featureconfig.Configuration} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class ConfigurationItemProvider |
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 ConfigurationItemProvider(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 | addNamePropertyDescriptor(object); |
68 | } |
69 | return itemPropertyDescriptors; |
70 | } |
71 | |
72 | /** |
73 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
74 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
75 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @generated |
79 | */ |
80 | @Override |
81 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
82 | if (childrenFeatures == null) { |
83 | super.getChildrenFeatures(object); |
84 | childrenFeatures.add(featureconfigPackage.Literals.CONFIGURATION__DEFAULT_CONFIG); |
85 | childrenFeatures.add(featureconfigPackage.Literals.CONFIGURATION__CONFIG_OVERRIDES); |
86 | } |
87 | return childrenFeatures; |
88 | } |
89 | |
90 | /** |
91 | * <!-- begin-user-doc --> |
92 | * <!-- end-user-doc --> |
93 | * @generated |
94 | */ |
95 | @Override |
96 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
97 | // Check the type of the specified child object and return the proper feature to use for |
98 | // adding (see {@link AddCommand}) it as a child. |
99 | |
100 | return super.getChildFeature(object, child); |
101 | } |
102 | |
103 | /** |
104 | * This adds a property descriptor for the Name feature. |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | protected void addNamePropertyDescriptor(Object object) { |
110 | itemPropertyDescriptors.add |
111 | (createItemPropertyDescriptor |
112 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
113 | getResourceLocator(), |
114 | getString("_UI_Configuration_name_feature"), |
115 | getString("_UI_PropertyDescriptor_description", "_UI_Configuration_name_feature", "_UI_Configuration_type"), |
116 | featureconfigPackage.Literals.CONFIGURATION__NAME, |
117 | true, |
118 | false, |
119 | false, |
120 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
121 | null, |
122 | null)); |
123 | } |
124 | |
125 | /** |
126 | * This returns Configuration.gif. |
127 | * <!-- begin-user-doc --> |
128 | * <!-- end-user-doc --> |
129 | * @generated |
130 | */ |
131 | @Override |
132 | public Object getImage(Object object) { |
133 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Configuration")); |
134 | } |
135 | |
136 | /** |
137 | * This returns the label text for the adapted class. |
138 | * <!-- begin-user-doc --> |
139 | * <!-- end-user-doc --> |
140 | * @generated |
141 | */ |
142 | @Override |
143 | public String getText(Object object) { |
144 | String label = ((Configuration)object).getName(); |
145 | return label == null || label.length() == 0 ? |
146 | getString("_UI_Configuration_type") : |
147 | getString("_UI_Configuration_type") + " " + label; |
148 | } |
149 | |
150 | /** |
151 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
152 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
153 | * <!-- begin-user-doc --> |
154 | * <!-- end-user-doc --> |
155 | * @generated |
156 | */ |
157 | @Override |
158 | public void notifyChanged(Notification notification) { |
159 | updateChildren(notification); |
160 | |
161 | switch (notification.getFeatureID(Configuration.class)) { |
162 | case featureconfigPackage.CONFIGURATION__NAME: |
163 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
164 | return; |
165 | case featureconfigPackage.CONFIGURATION__DEFAULT_CONFIG: |
166 | case featureconfigPackage.CONFIGURATION__CONFIG_OVERRIDES: |
167 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
168 | return; |
169 | } |
170 | super.notifyChanged(notification); |
171 | } |
172 | |
173 | /** |
174 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
175 | * that can be created under this object. |
176 | * <!-- begin-user-doc --> |
177 | * <!-- end-user-doc --> |
178 | * @generated |
179 | */ |
180 | @Override |
181 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
182 | super.collectNewChildDescriptors(newChildDescriptors, object); |
183 | |
184 | newChildDescriptors.add |
185 | (createChildParameter |
186 | (featureconfigPackage.Literals.CONFIGURATION__DEFAULT_CONFIG, |
187 | featureconfigFactory.eINSTANCE.createFeatureConfig())); |
188 | |
189 | newChildDescriptors.add |
190 | (createChildParameter |
191 | (featureconfigPackage.Literals.CONFIGURATION__CONFIG_OVERRIDES, |
192 | featureconfigFactory.eINSTANCE.createFeatureConfig())); |
193 | } |
194 | |
195 | /** |
196 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
197 | * <!-- begin-user-doc --> |
198 | * <!-- end-user-doc --> |
199 | * @generated |
200 | */ |
201 | @Override |
202 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
203 | Object childFeature = feature; |
204 | Object childObject = child; |
205 | |
206 | boolean qualify = |
207 | childFeature == featureconfigPackage.Literals.CONFIGURATION__DEFAULT_CONFIG || |
208 | childFeature == featureconfigPackage.Literals.CONFIGURATION__CONFIG_OVERRIDES; |
209 | |
210 | if (qualify) { |
211 | return getString |
212 | ("_UI_CreateChild_text2", |
213 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
214 | } |
215 | return super.getCreateChildText(owner, feature, child, selection); |
216 | } |
217 | |
218 | /** |
219 | * Return the resource locator for this item provider's resources. |
220 | * <!-- begin-user-doc --> |
221 | * <!-- end-user-doc --> |
222 | * @generated |
223 | */ |
224 | @Override |
225 | public ResourceLocator getResourceLocator() { |
226 | return FeatureConfigEditPlugin.INSTANCE; |
227 | } |
228 | |
229 | } |