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.EntityItemProvider; |
27 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
28 | import de.uka.ipd.sdq.pcm.reliability.ReliabilityFactory; |
29 | import de.uka.ipd.sdq.pcm.repository.Repository; |
30 | import de.uka.ipd.sdq.pcm.repository.RepositoryFactory; |
31 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
32 | import de.uka.ipd.sdq.pcm.subsystem.SubsystemFactory; |
33 | |
34 | /** |
35 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.repository.Repository} object. |
36 | * <!-- begin-user-doc --> |
37 | * <!-- end-user-doc --> |
38 | * @generated |
39 | */ |
40 | public class RepositoryItemProvider |
41 | extends EntityItemProvider |
42 | implements |
43 | IEditingDomainItemProvider, |
44 | IStructuredItemContentProvider, |
45 | ITreeItemContentProvider, |
46 | IItemLabelProvider, |
47 | IItemPropertySource { |
48 | /** |
49 | * <!-- begin-user-doc --> |
50 | * <!-- end-user-doc --> |
51 | * @generated |
52 | */ |
53 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
54 | |
55 | /** |
56 | * This constructs an instance from a factory and a notifier. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @generated |
60 | */ |
61 | public RepositoryItemProvider(AdapterFactory adapterFactory) { |
62 | super(adapterFactory); |
63 | } |
64 | |
65 | /** |
66 | * This returns the property descriptors for the adapted class. |
67 | * <!-- begin-user-doc --> |
68 | * <!-- end-user-doc --> |
69 | * @generated |
70 | */ |
71 | @Override |
72 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
73 | if (itemPropertyDescriptors == null) { |
74 | super.getPropertyDescriptors(object); |
75 | |
76 | addRepositoryDescriptionPropertyDescriptor(object); |
77 | } |
78 | return itemPropertyDescriptors; |
79 | } |
80 | |
81 | /** |
82 | * This adds a property descriptor for the Repository Description feature. |
83 | * <!-- begin-user-doc --> |
84 | * <!-- end-user-doc --> |
85 | * @generated |
86 | */ |
87 | protected void addRepositoryDescriptionPropertyDescriptor(Object object) { |
88 | itemPropertyDescriptors.add |
89 | (createItemPropertyDescriptor |
90 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
91 | getResourceLocator(), |
92 | getString("_UI_Repository_repositoryDescription_feature"), |
93 | getString("_UI_PropertyDescriptor_description", "_UI_Repository_repositoryDescription_feature", "_UI_Repository_type"), |
94 | RepositoryPackage.Literals.REPOSITORY__REPOSITORY_DESCRIPTION, |
95 | true, |
96 | false, |
97 | false, |
98 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
99 | null, |
100 | null)); |
101 | } |
102 | |
103 | /** |
104 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
105 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
106 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
107 | * <!-- begin-user-doc --> |
108 | * <!-- end-user-doc --> |
109 | * @generated |
110 | */ |
111 | @Override |
112 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
113 | if (childrenFeatures == null) { |
114 | super.getChildrenFeatures(object); |
115 | childrenFeatures.add(RepositoryPackage.Literals.REPOSITORY__COMPONENTS_REPOSITORY); |
116 | childrenFeatures.add(RepositoryPackage.Literals.REPOSITORY__INTERFACES_REPOSITORY); |
117 | childrenFeatures.add(RepositoryPackage.Literals.REPOSITORY__FAILURE_TYPES_REPOSITORY); |
118 | childrenFeatures.add(RepositoryPackage.Literals.REPOSITORY__DATA_TYPES_REPOSITORY); |
119 | } |
120 | return childrenFeatures; |
121 | } |
122 | |
123 | /** |
124 | * <!-- begin-user-doc --> |
125 | * <!-- end-user-doc --> |
126 | * @generated |
127 | */ |
128 | @Override |
129 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
130 | // Check the type of the specified child object and return the proper feature to use for |
131 | // adding (see {@link AddCommand}) it as a child. |
132 | |
133 | return super.getChildFeature(object, child); |
134 | } |
135 | |
136 | /** |
137 | * This returns Repository.gif. |
138 | * <!-- begin-user-doc --> |
139 | * <!-- end-user-doc --> |
140 | * @generated |
141 | */ |
142 | @Override |
143 | public Object getImage(Object object) { |
144 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Repository")); |
145 | } |
146 | |
147 | /** |
148 | * This returns the label text for the adapted class. |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | @Override |
154 | public String getText(Object object) { |
155 | String label = ((Repository)object).getId(); |
156 | return label == null || label.length() == 0 ? |
157 | getString("_UI_Repository_type") : |
158 | getString("_UI_Repository_type") + " " + label; |
159 | } |
160 | |
161 | /** |
162 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
163 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
164 | * <!-- begin-user-doc --> |
165 | * <!-- end-user-doc --> |
166 | * @generated |
167 | */ |
168 | @Override |
169 | public void notifyChanged(Notification notification) { |
170 | updateChildren(notification); |
171 | |
172 | switch (notification.getFeatureID(Repository.class)) { |
173 | case RepositoryPackage.REPOSITORY__REPOSITORY_DESCRIPTION: |
174 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
175 | return; |
176 | case RepositoryPackage.REPOSITORY__COMPONENTS_REPOSITORY: |
177 | case RepositoryPackage.REPOSITORY__INTERFACES_REPOSITORY: |
178 | case RepositoryPackage.REPOSITORY__FAILURE_TYPES_REPOSITORY: |
179 | case RepositoryPackage.REPOSITORY__DATA_TYPES_REPOSITORY: |
180 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
181 | return; |
182 | } |
183 | super.notifyChanged(notification); |
184 | } |
185 | |
186 | /** |
187 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
188 | * that can be created under this object. |
189 | * <!-- begin-user-doc --> |
190 | * <!-- end-user-doc --> |
191 | * @generated |
192 | */ |
193 | @Override |
194 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
195 | super.collectNewChildDescriptors(newChildDescriptors, object); |
196 | |
197 | newChildDescriptors.add |
198 | (createChildParameter |
199 | (RepositoryPackage.Literals.REPOSITORY__COMPONENTS_REPOSITORY, |
200 | RepositoryFactory.eINSTANCE.createBasicComponent())); |
201 | |
202 | newChildDescriptors.add |
203 | (createChildParameter |
204 | (RepositoryPackage.Literals.REPOSITORY__COMPONENTS_REPOSITORY, |
205 | RepositoryFactory.eINSTANCE.createCompleteComponentType())); |
206 | |
207 | newChildDescriptors.add |
208 | (createChildParameter |
209 | (RepositoryPackage.Literals.REPOSITORY__COMPONENTS_REPOSITORY, |
210 | RepositoryFactory.eINSTANCE.createProvidesComponentType())); |
211 | |
212 | newChildDescriptors.add |
213 | (createChildParameter |
214 | (RepositoryPackage.Literals.REPOSITORY__COMPONENTS_REPOSITORY, |
215 | RepositoryFactory.eINSTANCE.createCompositeComponent())); |
216 | |
217 | newChildDescriptors.add |
218 | (createChildParameter |
219 | (RepositoryPackage.Literals.REPOSITORY__COMPONENTS_REPOSITORY, |
220 | SubsystemFactory.eINSTANCE.createSubSystem())); |
221 | |
222 | newChildDescriptors.add |
223 | (createChildParameter |
224 | (RepositoryPackage.Literals.REPOSITORY__INTERFACES_REPOSITORY, |
225 | RepositoryFactory.eINSTANCE.createEventGroup())); |
226 | |
227 | newChildDescriptors.add |
228 | (createChildParameter |
229 | (RepositoryPackage.Literals.REPOSITORY__INTERFACES_REPOSITORY, |
230 | RepositoryFactory.eINSTANCE.createInfrastructureInterface())); |
231 | |
232 | newChildDescriptors.add |
233 | (createChildParameter |
234 | (RepositoryPackage.Literals.REPOSITORY__INTERFACES_REPOSITORY, |
235 | RepositoryFactory.eINSTANCE.createOperationInterface())); |
236 | |
237 | newChildDescriptors.add |
238 | (createChildParameter |
239 | (RepositoryPackage.Literals.REPOSITORY__FAILURE_TYPES_REPOSITORY, |
240 | ReliabilityFactory.eINSTANCE.createHardwareInducedFailureType())); |
241 | |
242 | newChildDescriptors.add |
243 | (createChildParameter |
244 | (RepositoryPackage.Literals.REPOSITORY__FAILURE_TYPES_REPOSITORY, |
245 | ReliabilityFactory.eINSTANCE.createSoftwareInducedFailureType())); |
246 | |
247 | newChildDescriptors.add |
248 | (createChildParameter |
249 | (RepositoryPackage.Literals.REPOSITORY__FAILURE_TYPES_REPOSITORY, |
250 | ReliabilityFactory.eINSTANCE.createNetworkInducedFailureType())); |
251 | |
252 | newChildDescriptors.add |
253 | (createChildParameter |
254 | (RepositoryPackage.Literals.REPOSITORY__FAILURE_TYPES_REPOSITORY, |
255 | ReliabilityFactory.eINSTANCE.createResourceTimeoutFailureType())); |
256 | |
257 | newChildDescriptors.add |
258 | (createChildParameter |
259 | (RepositoryPackage.Literals.REPOSITORY__DATA_TYPES_REPOSITORY, |
260 | RepositoryFactory.eINSTANCE.createPrimitiveDataType())); |
261 | |
262 | newChildDescriptors.add |
263 | (createChildParameter |
264 | (RepositoryPackage.Literals.REPOSITORY__DATA_TYPES_REPOSITORY, |
265 | RepositoryFactory.eINSTANCE.createCollectionDataType())); |
266 | |
267 | newChildDescriptors.add |
268 | (createChildParameter |
269 | (RepositoryPackage.Literals.REPOSITORY__DATA_TYPES_REPOSITORY, |
270 | RepositoryFactory.eINSTANCE.createCompositeDataType())); |
271 | } |
272 | |
273 | /** |
274 | * Return the resource locator for this item provider's resources. |
275 | * <!-- begin-user-doc --> |
276 | * <!-- end-user-doc --> |
277 | * @generated |
278 | */ |
279 | @Override |
280 | public ResourceLocator getResourceLocator() { |
281 | return PalladioComponentModelEditPlugin.INSTANCE; |
282 | } |
283 | |
284 | } |