1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourcetype.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.EntityFactory; |
27 | import de.uka.ipd.sdq.pcm.core.entity.EntityPackage; |
28 | import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProvider; |
29 | import de.uka.ipd.sdq.pcm.core.provider.PalladioComponentModelEditPlugin; |
30 | import de.uka.ipd.sdq.pcm.resourcetype.ResourceType; |
31 | import de.uka.ipd.sdq.pcm.resourcetype.ResourcetypePackage; |
32 | import de.uka.ipd.sdq.units.UnitsPackage; |
33 | |
34 | /** |
35 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.resourcetype.ResourceType} object. |
36 | * <!-- begin-user-doc --> |
37 | * <!-- end-user-doc --> |
38 | * @generated |
39 | */ |
40 | public class ResourceTypeItemProvider |
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 ResourceTypeItemProvider(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 | addUnitPropertyDescriptor(object); |
77 | addUnitSpecificationPropertyDescriptor(object); |
78 | } |
79 | return itemPropertyDescriptors; |
80 | } |
81 | |
82 | /** |
83 | * This adds a property descriptor for the Unit feature. |
84 | * <!-- begin-user-doc --> |
85 | * <!-- end-user-doc --> |
86 | * @generated |
87 | */ |
88 | protected void addUnitPropertyDescriptor(Object object) { |
89 | itemPropertyDescriptors.add |
90 | (createItemPropertyDescriptor |
91 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
92 | getResourceLocator(), |
93 | getString("_UI_UnitCarryingElement_unit_feature"), |
94 | getString("_UI_PropertyDescriptor_description", "_UI_UnitCarryingElement_unit_feature", "_UI_UnitCarryingElement_type"), |
95 | UnitsPackage.Literals.UNIT_CARRYING_ELEMENT__UNIT, |
96 | true, |
97 | false, |
98 | true, |
99 | null, |
100 | null, |
101 | null)); |
102 | } |
103 | |
104 | /** |
105 | * This adds a property descriptor for the Unit Specification feature. |
106 | * <!-- begin-user-doc --> |
107 | * <!-- end-user-doc --> |
108 | * @generated |
109 | */ |
110 | protected void addUnitSpecificationPropertyDescriptor(Object object) { |
111 | itemPropertyDescriptors.add |
112 | (createItemPropertyDescriptor |
113 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
114 | getResourceLocator(), |
115 | getString("_UI_UnitCarryingElement_unitSpecification_feature"), |
116 | getString("_UI_PropertyDescriptor_description", "_UI_UnitCarryingElement_unitSpecification_feature", "_UI_UnitCarryingElement_type"), |
117 | UnitsPackage.Literals.UNIT_CARRYING_ELEMENT__UNIT_SPECIFICATION, |
118 | true, |
119 | false, |
120 | false, |
121 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
122 | null, |
123 | null)); |
124 | } |
125 | |
126 | /** |
127 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
128 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
129 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @generated |
133 | */ |
134 | @Override |
135 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
136 | if (childrenFeatures == null) { |
137 | super.getChildrenFeatures(object); |
138 | childrenFeatures.add(EntityPackage.Literals.RESOURCE_INTERFACE_PROVIDING_ENTITY__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY); |
139 | } |
140 | return childrenFeatures; |
141 | } |
142 | |
143 | /** |
144 | * <!-- begin-user-doc --> |
145 | * <!-- end-user-doc --> |
146 | * @generated |
147 | */ |
148 | @Override |
149 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
150 | // Check the type of the specified child object and return the proper feature to use for |
151 | // adding (see {@link AddCommand}) it as a child. |
152 | |
153 | return super.getChildFeature(object, child); |
154 | } |
155 | |
156 | /** |
157 | * This returns the label text for the adapted class. |
158 | * <!-- begin-user-doc --> |
159 | * <!-- end-user-doc --> |
160 | * @generated |
161 | */ |
162 | @Override |
163 | public String getText(Object object) { |
164 | String label = ((ResourceType)object).getId(); |
165 | return label == null || label.length() == 0 ? |
166 | getString("_UI_ResourceType_type") : |
167 | getString("_UI_ResourceType_type") + " " + label; |
168 | } |
169 | |
170 | /** |
171 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
172 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
173 | * <!-- begin-user-doc --> |
174 | * <!-- end-user-doc --> |
175 | * @generated |
176 | */ |
177 | @Override |
178 | public void notifyChanged(Notification notification) { |
179 | updateChildren(notification); |
180 | |
181 | switch (notification.getFeatureID(ResourceType.class)) { |
182 | case ResourcetypePackage.RESOURCE_TYPE__UNIT_SPECIFICATION: |
183 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
184 | return; |
185 | case ResourcetypePackage.RESOURCE_TYPE__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY: |
186 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
187 | return; |
188 | } |
189 | super.notifyChanged(notification); |
190 | } |
191 | |
192 | /** |
193 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
194 | * that can be created under this object. |
195 | * <!-- begin-user-doc --> |
196 | * <!-- end-user-doc --> |
197 | * @generated |
198 | */ |
199 | @Override |
200 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
201 | super.collectNewChildDescriptors(newChildDescriptors, object); |
202 | |
203 | newChildDescriptors.add |
204 | (createChildParameter |
205 | (EntityPackage.Literals.RESOURCE_INTERFACE_PROVIDING_ENTITY__RESOURCE_PROVIDED_ROLES_RESOURCE_INTERFACE_PROVIDING_ENTITY, |
206 | EntityFactory.eINSTANCE.createResourceProvidedRole())); |
207 | } |
208 | |
209 | /** |
210 | * Return the resource locator for this item provider's resources. |
211 | * <!-- begin-user-doc --> |
212 | * <!-- end-user-doc --> |
213 | * @generated |
214 | */ |
215 | @Override |
216 | public ResourceLocator getResourceLocator() { |
217 | return PalladioComponentModelEditPlugin.INSTANCE; |
218 | } |
219 | |
220 | } |