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