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