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