1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.provider; |
8 | |
9 | |
10 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.Dimension; |
11 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypeFactory; |
12 | import de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.QMLContractTypePackage; |
13 | |
14 | import de.uka.ipd.sdq.dsexplore.qml.profile.QMLProfile.provider.QMLProfileEditPlugin; |
15 | |
16 | import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProvider; |
17 | |
18 | import java.util.Collection; |
19 | import java.util.List; |
20 | |
21 | import org.eclipse.emf.common.notify.AdapterFactory; |
22 | import org.eclipse.emf.common.notify.Notification; |
23 | |
24 | import org.eclipse.emf.common.util.ResourceLocator; |
25 | |
26 | import org.eclipse.emf.ecore.EStructuralFeature; |
27 | |
28 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
29 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
30 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
31 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
32 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
33 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
34 | import org.eclipse.emf.edit.provider.ViewerNotification; |
35 | |
36 | /** |
37 | * This is the item provider adapter for a {@link de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.Dimension} object. |
38 | * <!-- begin-user-doc --> |
39 | * <!-- end-user-doc --> |
40 | * @generated |
41 | */ |
42 | public class DimensionItemProvider |
43 | extends EntityItemProvider |
44 | implements |
45 | IEditingDomainItemProvider, |
46 | IStructuredItemContentProvider, |
47 | ITreeItemContentProvider, |
48 | IItemLabelProvider, |
49 | IItemPropertySource { |
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 DimensionItemProvider(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 | } |
72 | return itemPropertyDescriptors; |
73 | } |
74 | |
75 | /** |
76 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
77 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
78 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | @Override |
84 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
85 | if (childrenFeatures == null) { |
86 | super.getChildrenFeatures(object); |
87 | childrenFeatures.add(QMLContractTypePackage.Literals.DIMENSION__TYPE); |
88 | childrenFeatures.add(QMLContractTypePackage.Literals.DIMENSION__UNIT); |
89 | } |
90 | return childrenFeatures; |
91 | } |
92 | |
93 | /** |
94 | * <!-- begin-user-doc --> |
95 | * <!-- end-user-doc --> |
96 | * @generated |
97 | */ |
98 | @Override |
99 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
100 | // Check the type of the specified child object and return the proper feature to use for |
101 | // adding (see {@link AddCommand}) it as a child. |
102 | |
103 | return super.getChildFeature(object, child); |
104 | } |
105 | |
106 | /** |
107 | * This returns Dimension.gif. |
108 | * <!-- begin-user-doc --> |
109 | * <!-- end-user-doc --> |
110 | * @generated |
111 | */ |
112 | @Override |
113 | public Object getImage(Object object) { |
114 | return overlayImage(object, getResourceLocator().getImage("full/obj16/Dimension")); |
115 | } |
116 | |
117 | /** |
118 | * This returns the label text for the adapted class. |
119 | * <!-- begin-user-doc --> |
120 | * <!-- end-user-doc --> |
121 | * @generated |
122 | */ |
123 | @Override |
124 | public String getText(Object object) { |
125 | String label = ((Dimension)object).getId(); |
126 | return label == null || label.length() == 0 ? |
127 | getString("_UI_Dimension_type") : |
128 | getString("_UI_Dimension_type") + " " + label; |
129 | } |
130 | |
131 | /** |
132 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
133 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
134 | * <!-- begin-user-doc --> |
135 | * <!-- end-user-doc --> |
136 | * @generated |
137 | */ |
138 | @Override |
139 | public void notifyChanged(Notification notification) { |
140 | updateChildren(notification); |
141 | |
142 | switch (notification.getFeatureID(Dimension.class)) { |
143 | case QMLContractTypePackage.DIMENSION__TYPE: |
144 | case QMLContractTypePackage.DIMENSION__UNIT: |
145 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
146 | return; |
147 | } |
148 | super.notifyChanged(notification); |
149 | } |
150 | |
151 | /** |
152 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
153 | * that can be created under this object. |
154 | * <!-- begin-user-doc --> |
155 | * <!-- end-user-doc --> |
156 | * @generated |
157 | */ |
158 | @Override |
159 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
160 | super.collectNewChildDescriptors(newChildDescriptors, object); |
161 | |
162 | newChildDescriptors.add |
163 | (createChildParameter |
164 | (QMLContractTypePackage.Literals.DIMENSION__TYPE, |
165 | QMLContractTypeFactory.eINSTANCE.createDimensionTypeSet())); |
166 | |
167 | newChildDescriptors.add |
168 | (createChildParameter |
169 | (QMLContractTypePackage.Literals.DIMENSION__TYPE, |
170 | QMLContractTypeFactory.eINSTANCE.createDimensionTypeEnum())); |
171 | |
172 | newChildDescriptors.add |
173 | (createChildParameter |
174 | (QMLContractTypePackage.Literals.DIMENSION__TYPE, |
175 | QMLContractTypeFactory.eINSTANCE.createDimensionTypeNumeric())); |
176 | |
177 | newChildDescriptors.add |
178 | (createChildParameter |
179 | (QMLContractTypePackage.Literals.DIMENSION__UNIT, |
180 | QMLContractTypeFactory.eINSTANCE.createUnit())); |
181 | } |
182 | |
183 | /** |
184 | * Return the resource locator for this item provider's resources. |
185 | * <!-- begin-user-doc --> |
186 | * <!-- end-user-doc --> |
187 | * @generated |
188 | */ |
189 | @Override |
190 | public ResourceLocator getResourceLocator() { |
191 | return QMLProfileEditPlugin.INSTANCE; |
192 | } |
193 | |
194 | } |