1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EssentialOCL.provider; |
8 | |
9 | |
10 | import EssentialOCL.EssentialOCLFactory; |
11 | import EssentialOCL.EssentialOCLPackage; |
12 | import EssentialOCL.IterateExp; |
13 | |
14 | import QVTBase.QVTBaseFactory; |
15 | |
16 | import java.util.Collection; |
17 | import java.util.List; |
18 | |
19 | import org.eclipse.emf.common.notify.AdapterFactory; |
20 | import org.eclipse.emf.common.notify.Notification; |
21 | |
22 | import org.eclipse.emf.ecore.EStructuralFeature; |
23 | |
24 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
25 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
26 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
27 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
28 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
29 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
30 | import org.eclipse.emf.edit.provider.ViewerNotification; |
31 | |
32 | /** |
33 | * This is the item provider adapter for a {@link EssentialOCL.IterateExp} object. |
34 | * <!-- begin-user-doc --> |
35 | * <!-- end-user-doc --> |
36 | * @generated |
37 | */ |
38 | public class IterateExpItemProvider |
39 | extends LoopExpItemProvider |
40 | implements |
41 | IEditingDomainItemProvider, |
42 | IStructuredItemContentProvider, |
43 | ITreeItemContentProvider, |
44 | IItemLabelProvider, |
45 | IItemPropertySource { |
46 | /** |
47 | * This constructs an instance from a factory and a notifier. |
48 | * <!-- begin-user-doc --> |
49 | * <!-- end-user-doc --> |
50 | * @generated |
51 | */ |
52 | public IterateExpItemProvider(AdapterFactory adapterFactory) { |
53 | super(adapterFactory); |
54 | } |
55 | |
56 | /** |
57 | * This returns the property descriptors for the adapted class. |
58 | * <!-- begin-user-doc --> |
59 | * <!-- end-user-doc --> |
60 | * @generated |
61 | */ |
62 | @Override |
63 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
64 | if (itemPropertyDescriptors == null) { |
65 | super.getPropertyDescriptors(object); |
66 | |
67 | } |
68 | return itemPropertyDescriptors; |
69 | } |
70 | |
71 | /** |
72 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
73 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
74 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
75 | * <!-- begin-user-doc --> |
76 | * <!-- end-user-doc --> |
77 | * @generated |
78 | */ |
79 | @Override |
80 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
81 | if (childrenFeatures == null) { |
82 | super.getChildrenFeatures(object); |
83 | childrenFeatures.add(EssentialOCLPackage.Literals.ITERATE_EXP__RESULT); |
84 | } |
85 | return childrenFeatures; |
86 | } |
87 | |
88 | /** |
89 | * <!-- begin-user-doc --> |
90 | * <!-- end-user-doc --> |
91 | * @generated |
92 | */ |
93 | @Override |
94 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
95 | // Check the type of the specified child object and return the proper feature to use for |
96 | // adding (see {@link AddCommand}) it as a child. |
97 | |
98 | return super.getChildFeature(object, child); |
99 | } |
100 | |
101 | /** |
102 | * This returns IterateExp.gif. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | @Override |
108 | public Object getImage(Object object) { |
109 | return overlayImage(object, getResourceLocator().getImage("full/obj16/IterateExp")); |
110 | } |
111 | |
112 | /** |
113 | * This returns the label text for the adapted class. |
114 | * <!-- begin-user-doc --> |
115 | * <!-- end-user-doc --> |
116 | * @generated |
117 | */ |
118 | @Override |
119 | public String getText(Object object) { |
120 | String label = ((IterateExp)object).getName(); |
121 | return label == null || label.length() == 0 ? |
122 | getString("_UI_IterateExp_type") : |
123 | getString("_UI_IterateExp_type") + " " + label; |
124 | } |
125 | |
126 | /** |
127 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
128 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
129 | * <!-- begin-user-doc --> |
130 | * <!-- end-user-doc --> |
131 | * @generated |
132 | */ |
133 | @Override |
134 | public void notifyChanged(Notification notification) { |
135 | updateChildren(notification); |
136 | |
137 | switch (notification.getFeatureID(IterateExp.class)) { |
138 | case EssentialOCLPackage.ITERATE_EXP__RESULT: |
139 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
140 | return; |
141 | } |
142 | super.notifyChanged(notification); |
143 | } |
144 | |
145 | /** |
146 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
147 | * that can be created under this object. |
148 | * <!-- begin-user-doc --> |
149 | * <!-- end-user-doc --> |
150 | * @generated |
151 | */ |
152 | @Override |
153 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
154 | super.collectNewChildDescriptors(newChildDescriptors, object); |
155 | |
156 | newChildDescriptors.add |
157 | (createChildParameter |
158 | (EssentialOCLPackage.Literals.ITERATE_EXP__RESULT, |
159 | EssentialOCLFactory.eINSTANCE.createVariable())); |
160 | |
161 | newChildDescriptors.add |
162 | (createChildParameter |
163 | (EssentialOCLPackage.Literals.ITERATE_EXP__RESULT, |
164 | QVTBaseFactory.eINSTANCE.createFunctionParameter())); |
165 | } |
166 | |
167 | /** |
168 | * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. |
169 | * <!-- begin-user-doc --> |
170 | * <!-- end-user-doc --> |
171 | * @generated |
172 | */ |
173 | @Override |
174 | public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) { |
175 | Object childFeature = feature; |
176 | Object childObject = child; |
177 | |
178 | boolean qualify = |
179 | childFeature == EssentialOCLPackage.Literals.CALL_EXP__SOURCE || |
180 | childFeature == EssentialOCLPackage.Literals.LOOP_EXP__BODY || |
181 | childFeature == EssentialOCLPackage.Literals.LOOP_EXP__ITERATOR || |
182 | childFeature == EssentialOCLPackage.Literals.ITERATE_EXP__RESULT; |
183 | |
184 | if (qualify) { |
185 | return getString |
186 | ("_UI_CreateChild_text2", |
187 | new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); |
188 | } |
189 | return super.getCreateChildText(owner, feature, child, selection); |
190 | } |
191 | |
192 | } |