1 | /** |
2 | * Copyright 2007-2009, SDQ, IPD, U Karlsruhe |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.probfunction.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.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.ItemProviderAdapter; |
24 | import org.eclipse.emf.edit.provider.ViewerNotification; |
25 | |
26 | import de.uka.ipd.sdq.probfunction.Complex; |
27 | import de.uka.ipd.sdq.probfunction.ProbfunctionPackage; |
28 | |
29 | /** |
30 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.probfunction.Complex} object. |
31 | * <!-- begin-user-doc --> |
32 | * <!-- end-user-doc --> |
33 | * @generated |
34 | */ |
35 | public class ComplexItemProvider |
36 | extends ItemProviderAdapter |
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 2007-2009, SDQ, IPD, U Karlsruhe"; |
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 ComplexItemProvider(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 | addRealPropertyDescriptor(object); |
72 | addImaginaryPropertyDescriptor(object); |
73 | } |
74 | return itemPropertyDescriptors; |
75 | } |
76 | |
77 | /** |
78 | * This adds a property descriptor for the Real feature. |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | protected void addRealPropertyDescriptor(Object object) { |
84 | itemPropertyDescriptors.add |
85 | (createItemPropertyDescriptor |
86 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
87 | getResourceLocator(), |
88 | getString("_UI_Complex_real_feature"), |
89 | getString("_UI_PropertyDescriptor_description", "_UI_Complex_real_feature", "_UI_Complex_type"), |
90 | ProbfunctionPackage.Literals.COMPLEX__REAL, |
91 | true, |
92 | false, |
93 | false, |
94 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
95 | null, |
96 | null)); |
97 | } |
98 | |
99 | /** |
100 | * This adds a property descriptor for the Imaginary feature. |
101 | * <!-- begin-user-doc --> |
102 | * <!-- end-user-doc --> |
103 | * @generated |
104 | */ |
105 | protected void addImaginaryPropertyDescriptor(Object object) { |
106 | itemPropertyDescriptors.add |
107 | (createItemPropertyDescriptor |
108 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
109 | getResourceLocator(), |
110 | getString("_UI_Complex_imaginary_feature"), |
111 | getString("_UI_PropertyDescriptor_description", "_UI_Complex_imaginary_feature", "_UI_Complex_type"), |
112 | ProbfunctionPackage.Literals.COMPLEX__IMAGINARY, |
113 | true, |
114 | false, |
115 | false, |
116 | ItemPropertyDescriptor.REAL_VALUE_IMAGE, |
117 | null, |
118 | null)); |
119 | } |
120 | |
121 | /** |
122 | * This returns Complex.gif. |
123 | * <!-- begin-user-doc --> |
124 | * <!-- end-user-doc --> |
125 | * @generated |
126 | */ |
127 | @Override |
128 | public Object getImage(Object object) { |
129 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Complex")); |
130 | } |
131 | |
132 | /** |
133 | * This returns the label text for the adapted class. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public String getText(Object object) { |
140 | Complex complex = (Complex)object; |
141 | return getString("_UI_Complex_type") + " " + complex.getReal(); |
142 | } |
143 | |
144 | /** |
145 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
146 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
147 | * <!-- begin-user-doc --> |
148 | * <!-- end-user-doc --> |
149 | * @generated |
150 | */ |
151 | @Override |
152 | public void notifyChanged(Notification notification) { |
153 | updateChildren(notification); |
154 | |
155 | switch (notification.getFeatureID(Complex.class)) { |
156 | case ProbfunctionPackage.COMPLEX__REAL: |
157 | case ProbfunctionPackage.COMPLEX__IMAGINARY: |
158 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
159 | return; |
160 | } |
161 | super.notifyChanged(notification); |
162 | } |
163 | |
164 | /** |
165 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
166 | * that can be created under this object. |
167 | * <!-- begin-user-doc --> |
168 | * <!-- end-user-doc --> |
169 | * @generated |
170 | */ |
171 | @Override |
172 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
173 | super.collectNewChildDescriptors(newChildDescriptors, object); |
174 | } |
175 | |
176 | /** |
177 | * Return the resource locator for this item provider's resources. |
178 | * <!-- begin-user-doc --> |
179 | * <!-- end-user-doc --> |
180 | * @generated |
181 | */ |
182 | @Override |
183 | public ResourceLocator getResourceLocator() { |
184 | return ProbabilityFunctionEditPlugin.INSTANCE; |
185 | } |
186 | |
187 | } |