1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.pcm.cost.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.pcm.cost.Cost; |
11 | import de.uka.ipd.sdq.pcm.cost.costPackage; |
12 | |
13 | import java.util.Collection; |
14 | import java.util.List; |
15 | |
16 | import org.eclipse.emf.common.notify.AdapterFactory; |
17 | import org.eclipse.emf.common.notify.Notification; |
18 | |
19 | import org.eclipse.emf.common.util.ResourceLocator; |
20 | |
21 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
22 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
23 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
24 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
25 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
26 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
27 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
28 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
29 | import org.eclipse.emf.edit.provider.ItemProviderAdapter; |
30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.cost.Cost} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class CostItemProvider |
39 | extends ItemProviderAdapter |
40 | implements |
41 | IEditingDomainItemProvider, |
42 | IStructuredItemContentProvider, |
43 | ITreeItemContentProvider, |
44 | IItemLabelProvider, |
45 | IItemPropertySource { |
46 | /** |
47 | * This constructs an instance from a factory and a notifier. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @generated |
51 | */ |
52 | public CostItemProvider(AdapterFactory adapterFactory) { |
53 | super(adapterFactory); |
54 | } |
55 | |
56 | /** |
57 | * This returns the property descriptors for the adapted class. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @generated |
61 | */ |
62 | @Override |
63 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
64 | if (itemPropertyDescriptors == null) { |
65 | super.getPropertyDescriptors(object); |
66 | |
67 | addAnnotatedElementPropertyDescriptor(object); |
68 | addOperatingCostPropertyDescriptor(object); |
69 | addInitialCostPropertyDescriptor(object); |
70 | } |
71 | return itemPropertyDescriptors; |
72 | } |
73 | |
74 | /** |
75 | * This adds a property descriptor for the Annotated Element feature. |
76 | * <!-- begin-user-doc --> |
77 | * <!-- end-user-doc --> |
78 | * @generated |
79 | */ |
80 | protected void addAnnotatedElementPropertyDescriptor(Object object) { |
81 | itemPropertyDescriptors.add |
82 | (createItemPropertyDescriptor |
83 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
84 | getResourceLocator(), |
85 | getString("_UI_Cost_annotatedElement_feature"), |
86 | getString("_UI_PropertyDescriptor_description", "_UI_Cost_annotatedElement_feature", "_UI_Cost_type"), |
87 | costPackage.Literals.COST__ANNOTATED_ELEMENT, |
88 | false, |
89 | false, |
90 | false, |
91 | null, |
92 | null, |
93 | null)); |
94 | } |
95 | |
96 | /** |
97 | * This adds a property descriptor for the Operating Cost feature. |
98 | * <!-- begin-user-doc --> |
99 | * <!-- end-user-doc --> |
100 | * @generated |
101 | */ |
102 | protected void addOperatingCostPropertyDescriptor(Object object) { |
103 | itemPropertyDescriptors.add |
104 | (createItemPropertyDescriptor |
105 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
106 | getResourceLocator(), |
107 | getString("_UI_Cost_operatingCost_feature"), |
108 | getString("_UI_PropertyDescriptor_description", "_UI_Cost_operatingCost_feature", "_UI_Cost_type"), |
109 | costPackage.Literals.COST__OPERATING_COST, |
110 | false, |
111 | false, |
112 | false, |
113 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
114 | null, |
115 | null)); |
116 | } |
117 | |
118 | /** |
119 | * This adds a property descriptor for the Initial Cost feature. |
120 | * <!-- begin-user-doc --> |
121 | * <!-- end-user-doc --> |
122 | * @generated |
123 | */ |
124 | protected void addInitialCostPropertyDescriptor(Object object) { |
125 | itemPropertyDescriptors.add |
126 | (createItemPropertyDescriptor |
127 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
128 | getResourceLocator(), |
129 | getString("_UI_Cost_initialCost_feature"), |
130 | getString("_UI_PropertyDescriptor_description", "_UI_Cost_initialCost_feature", "_UI_Cost_type"), |
131 | costPackage.Literals.COST__INITIAL_COST, |
132 | false, |
133 | false, |
134 | false, |
135 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
136 | null, |
137 | null)); |
138 | } |
139 | |
140 | /** |
141 | * This returns the label text for the adapted class. |
142 | * <!-- begin-user-doc --> |
143 | * <!-- end-user-doc --> |
144 | * @generated |
145 | */ |
146 | @Override |
147 | public String getText(Object object) { |
148 | Cost cost = (Cost)object; |
149 | return getString("_UI_Cost_type") + " " + cost.getInitialCost(); |
150 | } |
151 | |
152 | /** |
153 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
154 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
155 | * <!-- begin-user-doc --> |
156 | * <!-- end-user-doc --> |
157 | * @generated |
158 | */ |
159 | @Override |
160 | public void notifyChanged(Notification notification) { |
161 | updateChildren(notification); |
162 | |
163 | switch (notification.getFeatureID(Cost.class)) { |
164 | case costPackage.COST__OPERATING_COST: |
165 | case costPackage.COST__INITIAL_COST: |
166 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
167 | return; |
168 | } |
169 | super.notifyChanged(notification); |
170 | } |
171 | |
172 | /** |
173 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
174 | * that can be created under this object. |
175 | * <!-- begin-user-doc --> |
176 | * <!-- end-user-doc --> |
177 | * @generated |
178 | */ |
179 | @Override |
180 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
181 | super.collectNewChildDescriptors(newChildDescriptors, object); |
182 | } |
183 | |
184 | /** |
185 | * Return the resource locator for this item provider's resources. |
186 | * <!-- begin-user-doc --> |
187 | * <!-- end-user-doc --> |
188 | * @generated |
189 | */ |
190 | @Override |
191 | public ResourceLocator getResourceLocator() { |
192 | return CostModelEditPlugin.INSTANCE; |
193 | } |
194 | |
195 | } |