1 | /** |
2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.usagemodel.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.ecore.EStructuralFeature; |
15 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
16 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
17 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
18 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
19 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
20 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
21 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
22 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
23 | import org.eclipse.emf.edit.provider.ViewerNotification; |
24 | |
25 | import de.uka.ipd.sdq.pcm.core.CoreFactory; |
26 | import de.uka.ipd.sdq.pcm.usagemodel.ClosedWorkload; |
27 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
28 | |
29 | /** |
30 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.pcm.usagemodel.ClosedWorkload} object. |
31 | * <!-- begin-user-doc --> |
32 | * <!-- end-user-doc --> |
33 | * @generated |
34 | */ |
35 | public class ClosedWorkloadItemProvider |
36 | extends WorkloadItemProvider |
37 | implements |
38 | IEditingDomainItemProvider, |
39 | IStructuredItemContentProvider, |
40 | ITreeItemContentProvider, |
41 | IItemLabelProvider, |
42 | IItemPropertySource { |
43 | /** |
44 | * <!-- begin-user-doc --> |
45 | * <!-- end-user-doc --> |
46 | * @generated |
47 | */ |
48 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
49 | |
50 | /** |
51 | * This constructs an instance from a factory and a notifier. |
52 | * <!-- begin-user-doc --> |
53 | * <!-- end-user-doc --> |
54 | * @generated |
55 | */ |
56 | public ClosedWorkloadItemProvider(AdapterFactory adapterFactory) { |
57 | super(adapterFactory); |
58 | } |
59 | |
60 | /** |
61 | * This returns the property descriptors for the adapted class. |
62 | * <!-- begin-user-doc --> |
63 | * <!-- end-user-doc --> |
64 | * @generated |
65 | */ |
66 | @Override |
67 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
68 | if (itemPropertyDescriptors == null) { |
69 | super.getPropertyDescriptors(object); |
70 | |
71 | addPopulationPropertyDescriptor(object); |
72 | } |
73 | return itemPropertyDescriptors; |
74 | } |
75 | |
76 | /** |
77 | * This adds a property descriptor for the Population feature. |
78 | * <!-- begin-user-doc --> |
79 | * <!-- end-user-doc --> |
80 | * @generated |
81 | */ |
82 | protected void addPopulationPropertyDescriptor(Object object) { |
83 | itemPropertyDescriptors.add |
84 | (createItemPropertyDescriptor |
85 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
86 | getResourceLocator(), |
87 | getString("_UI_ClosedWorkload_population_feature"), |
88 | getString("_UI_PropertyDescriptor_description", "_UI_ClosedWorkload_population_feature", "_UI_ClosedWorkload_type"), |
89 | UsagemodelPackage.Literals.CLOSED_WORKLOAD__POPULATION, |
90 | true, |
91 | false, |
92 | false, |
93 | ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, |
94 | null, |
95 | null)); |
96 | } |
97 | |
98 | /** |
99 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
100 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
101 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | @Override |
107 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
108 | if (childrenFeatures == null) { |
109 | super.getChildrenFeatures(object); |
110 | childrenFeatures.add(UsagemodelPackage.Literals.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD); |
111 | } |
112 | return childrenFeatures; |
113 | } |
114 | |
115 | /** |
116 | * <!-- begin-user-doc --> |
117 | * <!-- end-user-doc --> |
118 | * @generated |
119 | */ |
120 | @Override |
121 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
122 | // Check the type of the specified child object and return the proper feature to use for |
123 | // adding (see {@link AddCommand}) it as a child. |
124 | |
125 | return super.getChildFeature(object, child); |
126 | } |
127 | |
128 | /** |
129 | * This returns ClosedWorkload.gif. |
130 | * <!-- begin-user-doc --> |
131 | * <!-- end-user-doc --> |
132 | * @generated |
133 | */ |
134 | @Override |
135 | public Object getImage(Object object) { |
136 | return overlayImage(object, getResourceLocator().getImage("full/obj16/ClosedWorkload")); |
137 | } |
138 | |
139 | /** |
140 | * This returns the label text for the adapted class. |
141 | * <!-- begin-user-doc --> |
142 | * <!-- end-user-doc --> |
143 | * @generated |
144 | */ |
145 | @Override |
146 | public String getText(Object object) { |
147 | ClosedWorkload closedWorkload = (ClosedWorkload)object; |
148 | return getString("_UI_ClosedWorkload_type") + " " + closedWorkload.getPopulation(); |
149 | } |
150 | |
151 | /** |
152 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
153 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | @Override |
159 | public void notifyChanged(Notification notification) { |
160 | updateChildren(notification); |
161 | |
162 | switch (notification.getFeatureID(ClosedWorkload.class)) { |
163 | case UsagemodelPackage.CLOSED_WORKLOAD__POPULATION: |
164 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
165 | return; |
166 | case UsagemodelPackage.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD: |
167 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
168 | return; |
169 | } |
170 | super.notifyChanged(notification); |
171 | } |
172 | |
173 | /** |
174 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
175 | * that can be created under this object. |
176 | * <!-- begin-user-doc --> |
177 | * <!-- end-user-doc --> |
178 | * @generated |
179 | */ |
180 | @Override |
181 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
182 | super.collectNewChildDescriptors(newChildDescriptors, object); |
183 | |
184 | newChildDescriptors.add |
185 | (createChildParameter |
186 | (UsagemodelPackage.Literals.CLOSED_WORKLOAD__THINK_TIME_CLOSED_WORKLOAD, |
187 | CoreFactory.eINSTANCE.createPCMRandomVariable())); |
188 | } |
189 | |
190 | } |