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