1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourceenvironment.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.resourceenvironment.ResourceContainer; |
29 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentFactory; |
30 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentPackage; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class ResourceContainerItemProvider |
39 | extends EntityItemProvider |
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 ResourceContainerItemProvider(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 | addOperatingSystem_ResourceContainerPropertyDescriptor(object); |
75 | } |
76 | return itemPropertyDescriptors; |
77 | } |
78 | |
79 | /** |
80 | * This adds a property descriptor for the Operating System Resource Container feature. |
81 | * <!-- begin-user-doc --> |
82 | * <!-- end-user-doc --> |
83 | * @generated |
84 | */ |
85 | protected void addOperatingSystem_ResourceContainerPropertyDescriptor(Object object) { |
86 | itemPropertyDescriptors.add |
87 | (createItemPropertyDescriptor |
88 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
89 | getResourceLocator(), |
90 | getString("_UI_ResourceContainer_operatingSystem_ResourceContainer_feature"), |
91 | getString("_UI_PropertyDescriptor_description", "_UI_ResourceContainer_operatingSystem_ResourceContainer_feature", "_UI_ResourceContainer_type"), |
92 | ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER__OPERATING_SYSTEM_RESOURCE_CONTAINER, |
93 | true, |
94 | false, |
95 | false, |
96 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
97 | null, |
98 | null)); |
99 | } |
100 | |
101 | /** |
102 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
103 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
104 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
105 | * <!-- begin-user-doc --> |
106 | * <!-- end-user-doc --> |
107 | * @generated |
108 | */ |
109 | @Override |
110 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
111 | if (childrenFeatures == null) { |
112 | super.getChildrenFeatures(object); |
113 | childrenFeatures.add(ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER__ACTIVE_RESOURCE_SPECIFICATIONS_RESOURCE_CONTAINER); |
114 | childrenFeatures.add(ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER__NESTED_RESOURCE_CONTAINERS_RESOURCE_CONTAINER); |
115 | } |
116 | return childrenFeatures; |
117 | } |
118 | |
119 | /** |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | @Override |
125 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
126 | // Check the type of the specified child object and return the proper feature to use for |
127 | // adding (see {@link AddCommand}) it as a child. |
128 | |
129 | return super.getChildFeature(object, child); |
130 | } |
131 | |
132 | /** |
133 | * This returns ResourceContainer.gif. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public Object getImage(Object object) { |
140 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ResourceContainer")); |
141 | } |
142 | |
143 | /** |
144 | * This returns the label text for the adapted class. |
145 | * <!-- begin-user-doc --> |
146 | * FB: Adapted method to produce a more informative label for display in non-PCM editors. |
147 | * In PCM editors, display is not controlled by this method but through a more general |
148 | * mechanism (I'n not sure where it's actually controlled, maybe the |
149 | * de.uka.ipd.sdq.pcmbench.tabs.PropertyLabelProvider.getText() method?) |
150 | * <!-- end-user-doc --> |
151 | * @generated not |
152 | */ |
153 | @Override |
154 | public String getText(Object object) { |
155 | return ((ResourceContainer)object).getEntityName() |
156 | + " [ID: " + ((ResourceContainer)object).getId() + "]" |
157 | + " <" + getString("_UI_ResourceContainer_type") + ">"; |
158 | } |
159 | |
160 | /** |
161 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
162 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
163 | * <!-- begin-user-doc --> |
164 | * <!-- end-user-doc --> |
165 | * @generated |
166 | */ |
167 | @Override |
168 | public void notifyChanged(Notification notification) { |
169 | updateChildren(notification); |
170 | |
171 | switch (notification.getFeatureID(ResourceContainer.class)) { |
172 | case ResourceenvironmentPackage.RESOURCE_CONTAINER__OPERATING_SYSTEM_RESOURCE_CONTAINER: |
173 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
174 | return; |
175 | case ResourceenvironmentPackage.RESOURCE_CONTAINER__ACTIVE_RESOURCE_SPECIFICATIONS_RESOURCE_CONTAINER: |
176 | case ResourceenvironmentPackage.RESOURCE_CONTAINER__NESTED_RESOURCE_CONTAINERS_RESOURCE_CONTAINER: |
177 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
178 | return; |
179 | } |
180 | super.notifyChanged(notification); |
181 | } |
182 | |
183 | /** |
184 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
185 | * that can be created under this object. |
186 | * <!-- begin-user-doc --> |
187 | * <!-- end-user-doc --> |
188 | * @generated |
189 | */ |
190 | @Override |
191 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
192 | super.collectNewChildDescriptors(newChildDescriptors, object); |
193 | |
194 | newChildDescriptors.add |
195 | (createChildParameter |
196 | (ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER__ACTIVE_RESOURCE_SPECIFICATIONS_RESOURCE_CONTAINER, |
197 | ResourceenvironmentFactory.eINSTANCE.createProcessingResourceSpecification())); |
198 | |
199 | newChildDescriptors.add |
200 | (createChildParameter |
201 | (ResourceenvironmentPackage.Literals.RESOURCE_CONTAINER__NESTED_RESOURCE_CONTAINERS_RESOURCE_CONTAINER, |
202 | ResourceenvironmentFactory.eINSTANCE.createResourceContainer())); |
203 | } |
204 | |
205 | /** |
206 | * Return the resource locator for this item provider's resources. |
207 | * <!-- begin-user-doc --> |
208 | * <!-- end-user-doc --> |
209 | * @generated |
210 | */ |
211 | @Override |
212 | public ResourceLocator getResourceLocator() { |
213 | return PalladioComponentModelEditPlugin.INSTANCE; |
214 | } |
215 | |
216 | } |