1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.sensitivity.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.sensitivity.DoubleOffsetSequence; |
11 | import de.uka.ipd.sdq.sensitivity.DoubleOffsetType; |
12 | import de.uka.ipd.sdq.sensitivity.DoubleParameterSequence; |
13 | import de.uka.ipd.sdq.sensitivity.SensitivityPackage; |
14 | |
15 | import java.util.Collection; |
16 | import java.util.List; |
17 | |
18 | import org.eclipse.emf.common.notify.AdapterFactory; |
19 | import org.eclipse.emf.common.notify.Notification; |
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.ViewerNotification; |
30 | |
31 | /** |
32 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.sensitivity.DoubleOffsetSequence} object. |
33 | * <!-- begin-user-doc --> |
34 | * <!-- end-user-doc --> |
35 | * @generated |
36 | */ |
37 | public class DoubleOffsetSequenceItemProvider |
38 | extends DoubleParameterVariationItemProvider |
39 | implements |
40 | IEditingDomainItemProvider, |
41 | IStructuredItemContentProvider, |
42 | ITreeItemContentProvider, |
43 | IItemLabelProvider, |
44 | IItemPropertySource { |
45 | /** |
46 | * This constructs an instance from a factory and a notifier. |
47 | * <!-- begin-user-doc --> |
48 | * <!-- end-user-doc --> |
49 | * @generated |
50 | */ |
51 | public DoubleOffsetSequenceItemProvider(AdapterFactory adapterFactory) { |
52 | super(adapterFactory); |
53 | } |
54 | |
55 | /** |
56 | * This returns the property descriptors for the adapted class. |
57 | * <!-- begin-user-doc --> |
58 | * <!-- end-user-doc --> |
59 | * @generated |
60 | */ |
61 | @Override |
62 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
63 | if (itemPropertyDescriptors == null) { |
64 | super.getPropertyDescriptors(object); |
65 | |
66 | addOffsetValuesPropertyDescriptor(object); |
67 | addDoubleOffsetType__DoubleOffsetSequencePropertyDescriptor(object); |
68 | } |
69 | return itemPropertyDescriptors; |
70 | } |
71 | |
72 | /** |
73 | * This adds a property descriptor for the Offset Values feature. |
74 | * <!-- begin-user-doc --> |
75 | * <!-- end-user-doc --> |
76 | * @generated |
77 | */ |
78 | protected void addOffsetValuesPropertyDescriptor(Object object) { |
79 | itemPropertyDescriptors.add |
80 | (createItemPropertyDescriptor |
81 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
82 | getResourceLocator(), |
83 | getString("_UI_DoubleOffsetSequence_offsetValues_feature"), |
84 | getString("_UI_PropertyDescriptor_description", "_UI_DoubleOffsetSequence_offsetValues_feature", "_UI_DoubleOffsetSequence_type"), |
85 | SensitivityPackage.Literals.DOUBLE_OFFSET_SEQUENCE__OFFSET_VALUES, |
86 | true, |
87 | false, |
88 | false, |
89 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
90 | null, |
91 | null)); |
92 | } |
93 | |
94 | /** |
95 | * This adds a property descriptor for the Double Offset Type Double Offset Sequence feature. |
96 | * <!-- begin-user-doc --> |
97 | * <!-- end-user-doc --> |
98 | * @generated |
99 | */ |
100 | protected void addDoubleOffsetType__DoubleOffsetSequencePropertyDescriptor(Object object) { |
101 | itemPropertyDescriptors.add |
102 | (createItemPropertyDescriptor |
103 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
104 | getResourceLocator(), |
105 | getString("_UI_DoubleOffsetSequence_doubleOffsetType__DoubleOffsetSequence_feature"), |
106 | getString("_UI_PropertyDescriptor_description", "_UI_DoubleOffsetSequence_doubleOffsetType__DoubleOffsetSequence_feature", "_UI_DoubleOffsetSequence_type"), |
107 | SensitivityPackage.Literals.DOUBLE_OFFSET_SEQUENCE__DOUBLE_OFFSET_TYPE_DOUBLE_OFFSET_SEQUENCE, |
108 | true, |
109 | false, |
110 | false, |
111 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
112 | null, |
113 | null)); |
114 | } |
115 | |
116 | /** |
117 | * This returns DoubleOffsetSequence.gif. |
118 | * <!-- begin-user-doc --> |
119 | * <!-- end-user-doc --> |
120 | * @generated |
121 | */ |
122 | @Override |
123 | public Object getImage(Object object) { |
124 | return overlayImage(object, getResourceLocator().getImage("full/obj16/DoubleOffsetSequence")); |
125 | } |
126 | |
127 | /** |
128 | * This returns the label text for the adapted class. |
129 | * <!-- begin-user-doc --> |
130 | * <!-- end-user-doc --> |
131 | * @generated not |
132 | */ |
133 | @Override |
134 | public String getText(Object object) { |
135 | String doubleSequence = "UNSPECIFIED"; |
136 | String offsetType = ""; |
137 | try { |
138 | org.eclipse.emf.common.util.EList<Double> values = ((DoubleOffsetSequence)object).getOffsetValues(); |
139 | switch(((DoubleOffsetSequence)object).getDoubleOffsetType__DoubleOffsetSequence()) { |
140 | case ADD: |
141 | offsetType = "x + "; |
142 | break; |
143 | case SUBTRACT: |
144 | offsetType = "x - "; |
145 | break; |
146 | case MULTIPLY: |
147 | offsetType = "x * "; |
148 | break; |
149 | case DIVIDE: |
150 | offsetType = "x / "; |
151 | break; |
152 | } |
153 | doubleSequence = offsetType + values.get(0).toString() + " ... " |
154 | + offsetType + values.get(values.size() - 1).toString(); |
155 | } catch(Exception e) {} |
156 | return doubleSequence + " <" + getString("_UI_DoubleOffsetSequence_type") + ">"; |
157 | } |
158 | |
159 | /** |
160 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
161 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
162 | * <!-- begin-user-doc --> |
163 | * <!-- end-user-doc --> |
164 | * @generated |
165 | */ |
166 | @Override |
167 | public void notifyChanged(Notification notification) { |
168 | updateChildren(notification); |
169 | |
170 | switch (notification.getFeatureID(DoubleOffsetSequence.class)) { |
171 | case SensitivityPackage.DOUBLE_OFFSET_SEQUENCE__OFFSET_VALUES: |
172 | case SensitivityPackage.DOUBLE_OFFSET_SEQUENCE__DOUBLE_OFFSET_TYPE_DOUBLE_OFFSET_SEQUENCE: |
173 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
174 | return; |
175 | } |
176 | super.notifyChanged(notification); |
177 | } |
178 | |
179 | /** |
180 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
181 | * that can be created under this object. |
182 | * <!-- begin-user-doc --> |
183 | * <!-- end-user-doc --> |
184 | * @generated |
185 | */ |
186 | @Override |
187 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
188 | super.collectNewChildDescriptors(newChildDescriptors, object); |
189 | } |
190 | |
191 | } |