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