1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.markov.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.markov.MarkovFactory; |
11 | import de.uka.ipd.sdq.markov.MarkovPackage; |
12 | import de.uka.ipd.sdq.markov.State; |
13 | |
14 | import java.util.Collection; |
15 | import java.util.List; |
16 | |
17 | import org.eclipse.emf.common.notify.AdapterFactory; |
18 | import org.eclipse.emf.common.notify.Notification; |
19 | |
20 | import org.eclipse.emf.ecore.EStructuralFeature; |
21 | |
22 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
23 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
24 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
25 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
26 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
27 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
28 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
29 | import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.markov.State} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class StateItemProvider |
39 | extends EntityItemProvider |
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 StateItemProvider(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 | addTypePropertyDescriptor(object); |
68 | addTracesPropertyDescriptor(object); |
69 | } |
70 | return itemPropertyDescriptors; |
71 | } |
72 | |
73 | /** |
74 | * This adds a property descriptor for the Type feature. |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @generated |
78 | */ |
79 | protected void addTypePropertyDescriptor(Object object) { |
80 | itemPropertyDescriptors.add |
81 | (createItemPropertyDescriptor |
82 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
83 | getResourceLocator(), |
84 | getString("_UI_State_type_feature"), |
85 | getString("_UI_PropertyDescriptor_description", "_UI_State_type_feature", "_UI_State_type"), |
86 | MarkovPackage.Literals.STATE__TYPE, |
87 | true, |
88 | false, |
89 | false, |
90 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
91 | null, |
92 | null)); |
93 | } |
94 | |
95 | /** |
96 | * This adds a property descriptor for the Traces feature. |
97 | * <!-- begin-user-doc --> |
98 | * <!-- end-user-doc --> |
99 | * @generated |
100 | */ |
101 | protected void addTracesPropertyDescriptor(Object object) { |
102 | itemPropertyDescriptors.add |
103 | (createItemPropertyDescriptor |
104 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
105 | getResourceLocator(), |
106 | getString("_UI_State_traces_feature"), |
107 | getString("_UI_PropertyDescriptor_description", "_UI_State_traces_feature", "_UI_State_type"), |
108 | MarkovPackage.Literals.STATE__TRACES, |
109 | true, |
110 | false, |
111 | false, |
112 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
113 | null, |
114 | null)); |
115 | } |
116 | |
117 | /** |
118 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
119 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
120 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
121 | * <!-- begin-user-doc --> |
122 | * <!-- end-user-doc --> |
123 | * @generated |
124 | */ |
125 | @Override |
126 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
127 | if (childrenFeatures == null) { |
128 | super.getChildrenFeatures(object); |
129 | childrenFeatures.add(MarkovPackage.Literals.STATE__LABELS); |
130 | } |
131 | return childrenFeatures; |
132 | } |
133 | |
134 | /** |
135 | * <!-- begin-user-doc --> |
136 | * <!-- end-user-doc --> |
137 | * @generated |
138 | */ |
139 | @Override |
140 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
141 | // Check the type of the specified child object and return the proper feature to use for |
142 | // adding (see {@link AddCommand}) it as a child. |
143 | |
144 | return super.getChildFeature(object, child); |
145 | } |
146 | |
147 | /** |
148 | * This returns State.gif. |
149 | * <!-- begin-user-doc --> |
150 | * <!-- end-user-doc --> |
151 | * @generated |
152 | */ |
153 | @Override |
154 | public Object getImage(Object object) { |
155 | return overlayImage(object, getResourceLocator().getImage("full/obj16/State")); |
156 | } |
157 | |
158 | /** |
159 | * This returns the label text for the adapted class. |
160 | * <!-- begin-user-doc --> |
161 | * <!-- end-user-doc --> |
162 | * @generated |
163 | */ |
164 | @Override |
165 | public String getText(Object object) { |
166 | String label = ((State)object).getName(); |
167 | return label == null || label.length() == 0 ? |
168 | getString("_UI_State_type") : |
169 | getString("_UI_State_type") + " " + label; |
170 | } |
171 | |
172 | /** |
173 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
174 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
175 | * <!-- begin-user-doc --> |
176 | * <!-- end-user-doc --> |
177 | * @generated |
178 | */ |
179 | @Override |
180 | public void notifyChanged(Notification notification) { |
181 | updateChildren(notification); |
182 | |
183 | switch (notification.getFeatureID(State.class)) { |
184 | case MarkovPackage.STATE__TYPE: |
185 | case MarkovPackage.STATE__TRACES: |
186 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
187 | return; |
188 | case MarkovPackage.STATE__LABELS: |
189 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
190 | return; |
191 | } |
192 | super.notifyChanged(notification); |
193 | } |
194 | |
195 | /** |
196 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
197 | * that can be created under this object. |
198 | * <!-- begin-user-doc --> |
199 | * <!-- end-user-doc --> |
200 | * @generated |
201 | */ |
202 | @Override |
203 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
204 | super.collectNewChildDescriptors(newChildDescriptors, object); |
205 | |
206 | newChildDescriptors.add |
207 | (createChildParameter |
208 | (MarkovPackage.Literals.STATE__LABELS, |
209 | MarkovFactory.eINSTANCE.createLabel())); |
210 | } |
211 | |
212 | } |