1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.featureconfig.provider; |
8 | |
9 | |
10 | import java.util.Collection; |
11 | import java.util.List; |
12 | |
13 | import org.eclipse.emf.common.notify.AdapterFactory; |
14 | import org.eclipse.emf.common.notify.Notification; |
15 | import org.eclipse.emf.common.util.ResourceLocator; |
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.ViewerNotification; |
25 | |
26 | import de.uka.ipd.sdq.featureconfig.AttributeValue; |
27 | import de.uka.ipd.sdq.featureconfig.featureconfigPackage; |
28 | import de.uka.ipd.sdq.featuremodel.provider.NamedElementItemProvider; |
29 | |
30 | /** |
31 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.featureconfig.AttributeValue} object. |
32 | * <!-- begin-user-doc --> |
33 | * <!-- end-user-doc --> |
34 | * @generated |
35 | */ |
36 | public class AttributeValueItemProvider |
37 | extends NamedElementItemProvider |
38 | implements |
39 | IEditingDomainItemProvider, |
40 | IStructuredItemContentProvider, |
41 | ITreeItemContentProvider, |
42 | IItemLabelProvider, |
43 | IItemPropertySource { |
44 | /** |
45 | * This constructs an instance from a factory and a notifier. |
46 | * <!-- begin-user-doc --> |
47 | * <!-- end-user-doc --> |
48 | * @generated |
49 | */ |
50 | public AttributeValueItemProvider(AdapterFactory adapterFactory) { |
51 | super(adapterFactory); |
52 | } |
53 | |
54 | /** |
55 | * This returns the property descriptors for the adapted class. |
56 | * <!-- begin-user-doc --> |
57 | * <!-- end-user-doc --> |
58 | * @generated |
59 | */ |
60 | @Override |
61 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
62 | if (itemPropertyDescriptors == null) { |
63 | super.getPropertyDescriptors(object); |
64 | |
65 | addValuePropertyDescriptor(object); |
66 | addConfignodePropertyDescriptor(object); |
67 | } |
68 | return itemPropertyDescriptors; |
69 | } |
70 | |
71 | /** |
72 | * This adds a property descriptor for the Value feature. |
73 | * <!-- begin-user-doc --> |
74 | * <!-- end-user-doc --> |
75 | * @generated |
76 | */ |
77 | protected void addValuePropertyDescriptor(Object object) { |
78 | itemPropertyDescriptors.add |
79 | (createItemPropertyDescriptor |
80 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
81 | getResourceLocator(), |
82 | getString("_UI_AttributeValue_value_feature"), |
83 | getString("_UI_PropertyDescriptor_description", "_UI_AttributeValue_value_feature", "_UI_AttributeValue_type"), |
84 | featureconfigPackage.Literals.ATTRIBUTE_VALUE__VALUE, |
85 | true, |
86 | false, |
87 | false, |
88 | ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, |
89 | null, |
90 | null)); |
91 | } |
92 | |
93 | /** |
94 | * This adds a property descriptor for the Confignode feature. |
95 | * <!-- begin-user-doc --> |
96 | * <!-- end-user-doc --> |
97 | * @generated |
98 | */ |
99 | protected void addConfignodePropertyDescriptor(Object object) { |
100 | itemPropertyDescriptors.add |
101 | (createItemPropertyDescriptor |
102 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
103 | getResourceLocator(), |
104 | getString("_UI_AttributeValue_confignode_feature"), |
105 | getString("_UI_PropertyDescriptor_description", "_UI_AttributeValue_confignode_feature", "_UI_AttributeValue_type"), |
106 | featureconfigPackage.Literals.ATTRIBUTE_VALUE__CONFIGNODE, |
107 | true, |
108 | false, |
109 | true, |
110 | null, |
111 | null, |
112 | null)); |
113 | } |
114 | |
115 | /** |
116 | * This returns AttributeValue.gif. |
117 | * <!-- begin-user-doc --> |
118 | * <!-- end-user-doc --> |
119 | * @generated |
120 | */ |
121 | @Override |
122 | public Object getImage(Object object) { |
123 | return overlayImage(object, getResourceLocator().getImage("full/obj16/AttributeValue")); |
124 | } |
125 | |
126 | /** |
127 | * This returns the label text for the adapted class. |
128 | * <!-- begin-user-doc --> |
129 | * <!-- end-user-doc --> |
130 | * @generated |
131 | */ |
132 | @Override |
133 | public String getText(Object object) { |
134 | String label = ((AttributeValue)object).getName(); |
135 | return label == null || label.length() == 0 ? |
136 | getString("_UI_AttributeValue_type") : |
137 | getString("_UI_AttributeValue_type") + " " + label; |
138 | } |
139 | |
140 | /** |
141 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
142 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | @Override |
148 | public void notifyChanged(Notification notification) { |
149 | updateChildren(notification); |
150 | |
151 | switch (notification.getFeatureID(AttributeValue.class)) { |
152 | case featureconfigPackage.ATTRIBUTE_VALUE__VALUE: |
153 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); |
154 | return; |
155 | } |
156 | super.notifyChanged(notification); |
157 | } |
158 | |
159 | /** |
160 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
161 | * that can be created under this object. |
162 | * <!-- begin-user-doc --> |
163 | * <!-- end-user-doc --> |
164 | * @generated |
165 | */ |
166 | @Override |
167 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
168 | super.collectNewChildDescriptors(newChildDescriptors, object); |
169 | } |
170 | |
171 | /** |
172 | * Return the resource locator for this item provider's resources. |
173 | * <!-- begin-user-doc --> |
174 | * <!-- end-user-doc --> |
175 | * @generated |
176 | */ |
177 | @Override |
178 | public ResourceLocator getResourceLocator() { |
179 | return FeatureConfigEditPlugin.INSTANCE; |
180 | } |
181 | |
182 | } |