1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.repository.provider; |
7 | |
8 | |
9 | import java.util.Collection; |
10 | import java.util.List; |
11 | |
12 | import org.eclipse.emf.common.notify.AdapterFactory; |
13 | import org.eclipse.emf.common.notify.Notification; |
14 | import org.eclipse.emf.common.util.ResourceLocator; |
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.pcm.core.entity.provider.ComposedProvidingRequiringEntityItemProvider; |
27 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
28 | import de.uka.ipd.sdq.pcm.parameter.ParameterFactory; |
29 | import de.uka.ipd.sdq.pcm.repository.CompositeComponent; |
30 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.repository.CompositeComponent} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class CompositeComponentItemProvider |
39 | extends ComposedProvidingRequiringEntityItemProvider |
40 | implements |
41 | IEditingDomainItemProvider, |
42 | IStructuredItemContentProvider, |
43 | ITreeItemContentProvider, |
44 | IItemLabelProvider, |
45 | IItemPropertySource { |
46 | /** |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @generated |
50 | */ |
51 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
52 | |
53 | /** |
54 | * This constructs an instance from a factory and a notifier. |
55 | * <!-- begin-user-doc --> |
56 | * <!-- end-user-doc --> |
57 | * @generated |
58 | */ |
59 | public CompositeComponentItemProvider(AdapterFactory adapterFactory) { |
60 | super(adapterFactory); |
61 | } |
62 | |
63 | /** |
64 | * This returns the property descriptors for the adapted class. |
65 | * <!-- begin-user-doc --> |
66 | * <!-- end-user-doc --> |
67 | * @generated |
68 | */ |
69 | @Override |
70 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
71 | if (itemPropertyDescriptors == null) { |
72 | super.getPropertyDescriptors(object); |
73 | |
74 | addParentCompleteComponentTypesPropertyDescriptor(object); |
75 | addComponentTypePropertyDescriptor(object); |
76 | } |
77 | return itemPropertyDescriptors; |
78 | } |
79 | |
80 | /** |
81 | * This adds a property descriptor for the Parent Complete Component Types feature. |
82 | * <!-- begin-user-doc --> |
83 | * <!-- end-user-doc --> |
84 | * @generated |
85 | */ |
86 | protected void addParentCompleteComponentTypesPropertyDescriptor(Object object) { |
87 | itemPropertyDescriptors.add |
88 | (createItemPropertyDescriptor |
89 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
90 | getResourceLocator(), |
91 | getString("_UI_ImplementationComponentType_parentCompleteComponentTypes_feature"), |
92 | getString("_UI_PropertyDescriptor_description", "_UI_ImplementationComponentType_parentCompleteComponentTypes_feature", "_UI_ImplementationComponentType_type"), |
93 | RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__PARENT_COMPLETE_COMPONENT_TYPES, |
94 | true, |
95 | false, |
96 | true, |
97 | null, |
98 | null, |
99 | null)); |
100 | } |
101 | |
102 | /** |
103 | * This adds a property descriptor for the Component Type feature. |
104 | * <!-- begin-user-doc --> |
105 | * <!-- end-user-doc --> |
106 | * @generated |
107 | */ |
108 | protected void addComponentTypePropertyDescriptor(Object object) { |
109 | itemPropertyDescriptors.add |
110 | (createItemPropertyDescriptor |
111 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
112 | getResourceLocator(), |
113 | getString("_UI_ImplementationComponentType_componentType_feature"), |
114 | getString("_UI_PropertyDescriptor_description", "_UI_ImplementationComponentType_componentType_feature", "_UI_ImplementationComponentType_type"), |
115 | RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_TYPE, |
116 | true, |
117 | false, |
118 | false, |
119 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
120 | null, |
121 | null)); |
122 | } |
123 | |
124 | /** |
125 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
126 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
127 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
128 | * <!-- begin-user-doc --> |
129 | * <!-- end-user-doc --> |
130 | * @generated |
131 | */ |
132 | @Override |
133 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
134 | if (childrenFeatures == null) { |
135 | super.getChildrenFeatures(object); |
136 | childrenFeatures.add(RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE); |
137 | } |
138 | return childrenFeatures; |
139 | } |
140 | |
141 | /** |
142 | * <!-- begin-user-doc --> |
143 | * <!-- end-user-doc --> |
144 | * @generated |
145 | */ |
146 | @Override |
147 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
148 | // Check the type of the specified child object and return the proper feature to use for |
149 | // adding (see {@link AddCommand}) it as a child. |
150 | |
151 | return super.getChildFeature(object, child); |
152 | } |
153 | |
154 | /** |
155 | * This returns CompositeComponent.gif. |
156 | * <!-- begin-user-doc --> |
157 | * <!-- end-user-doc --> |
158 | * @generated |
159 | */ |
160 | @Override |
161 | public Object getImage(Object object) { |
162 | return overlayImage(object, getResourceLocator().getImage("full/obj16/CompositeComponent")); |
163 | } |
164 | |
165 | /** |
166 | * This returns the label text for the adapted class. |
167 | * <!-- begin-user-doc --> |
168 | * <!-- end-user-doc --> |
169 | * @generated |
170 | */ |
171 | @Override |
172 | public String getText(Object object) { |
173 | String label = ((CompositeComponent)object).getId(); |
174 | return label == null || label.length() == 0 ? |
175 | getString("_UI_CompositeComponent_type") : |
176 | getString("_UI_CompositeComponent_type") + " " + label; |
177 | } |
178 | |
179 | /** |
180 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
181 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
182 | * <!-- begin-user-doc --> |
183 | * <!-- end-user-doc --> |
184 | * @generated |
185 | */ |
186 | @Override |
187 | public void notifyChanged(Notification notification) { |
188 | updateChildren(notification); |
189 | |
190 | switch (notification.getFeatureID(CompositeComponent.class)) { |
191 | case RepositoryPackage.COMPOSITE_COMPONENT__COMPONENT_TYPE: |
192 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
193 | return; |
194 | case RepositoryPackage.COMPOSITE_COMPONENT__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE: |
195 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
196 | return; |
197 | } |
198 | super.notifyChanged(notification); |
199 | } |
200 | |
201 | /** |
202 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
203 | * that can be created under this object. |
204 | * <!-- begin-user-doc --> |
205 | * <!-- end-user-doc --> |
206 | * @generated |
207 | */ |
208 | @Override |
209 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
210 | super.collectNewChildDescriptors(newChildDescriptors, object); |
211 | |
212 | newChildDescriptors.add |
213 | (createChildParameter |
214 | (RepositoryPackage.Literals.IMPLEMENTATION_COMPONENT_TYPE__COMPONENT_PARAMETER_USAGE_IMPLEMENTATION_COMPONENT_TYPE, |
215 | ParameterFactory.eINSTANCE.createVariableUsage())); |
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 PalladioComponentModelEditPlugin.INSTANCE; |
227 | } |
228 | |
229 | } |