1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package QVTRelation.provider; |
8 | |
9 | |
10 | import EMOF.provider.QvtmodelsEditPlugin; |
11 | |
12 | import QVTBase.provider.DomainItemProvider; |
13 | |
14 | import QVTRelation.QVTRelationFactory; |
15 | import QVTRelation.QVTRelationPackage; |
16 | import QVTRelation.RelationDomain; |
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.ComposeableAdapterFactory; |
29 | import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; |
30 | import org.eclipse.emf.edit.provider.IItemLabelProvider; |
31 | import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; |
32 | import org.eclipse.emf.edit.provider.IItemPropertySource; |
33 | import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; |
34 | import org.eclipse.emf.edit.provider.ITreeItemContentProvider; |
35 | import org.eclipse.emf.edit.provider.ViewerNotification; |
36 | |
37 | /** |
38 | * This is the item provider adapter for a {@link QVTRelation.RelationDomain} object. |
39 | * <!-- begin-user-doc --> |
40 | * <!-- end-user-doc --> |
41 | * @generated |
42 | */ |
43 | public class RelationDomainItemProvider |
44 | extends DomainItemProvider |
45 | implements |
46 | IEditingDomainItemProvider, |
47 | IStructuredItemContentProvider, |
48 | ITreeItemContentProvider, |
49 | IItemLabelProvider, |
50 | IItemPropertySource { |
51 | /** |
52 | * This constructs an instance from a factory and a notifier. |
53 | * <!-- begin-user-doc --> |
54 | * <!-- end-user-doc --> |
55 | * @generated |
56 | */ |
57 | public RelationDomainItemProvider(AdapterFactory adapterFactory) { |
58 | super(adapterFactory); |
59 | } |
60 | |
61 | /** |
62 | * This returns the property descriptors for the adapted class. |
63 | * <!-- begin-user-doc --> |
64 | * <!-- end-user-doc --> |
65 | * @generated |
66 | */ |
67 | @Override |
68 | public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { |
69 | if (itemPropertyDescriptors == null) { |
70 | super.getPropertyDescriptors(object); |
71 | |
72 | addRootVariablePropertyDescriptor(object); |
73 | } |
74 | return itemPropertyDescriptors; |
75 | } |
76 | |
77 | /** |
78 | * This adds a property descriptor for the Root Variable feature. |
79 | * <!-- begin-user-doc --> |
80 | * <!-- end-user-doc --> |
81 | * @generated |
82 | */ |
83 | protected void addRootVariablePropertyDescriptor(Object object) { |
84 | itemPropertyDescriptors.add |
85 | (createItemPropertyDescriptor |
86 | (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), |
87 | getResourceLocator(), |
88 | getString("_UI_RelationDomain_rootVariable_feature"), |
89 | getString("_UI_PropertyDescriptor_description", "_UI_RelationDomain_rootVariable_feature", "_UI_RelationDomain_type"), |
90 | QVTRelationPackage.Literals.RELATION_DOMAIN__ROOT_VARIABLE, |
91 | true, |
92 | false, |
93 | true, |
94 | null, |
95 | null, |
96 | null)); |
97 | } |
98 | |
99 | /** |
100 | * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an |
101 | * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or |
102 | * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. |
103 | * <!-- begin-user-doc --> |
104 | * <!-- end-user-doc --> |
105 | * @generated |
106 | */ |
107 | @Override |
108 | public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) { |
109 | if (childrenFeatures == null) { |
110 | super.getChildrenFeatures(object); |
111 | childrenFeatures.add(QVTRelationPackage.Literals.RELATION_DOMAIN__DEFAULT_ASSIGNMENT); |
112 | childrenFeatures.add(QVTRelationPackage.Literals.RELATION_DOMAIN__PATTERN); |
113 | } |
114 | return childrenFeatures; |
115 | } |
116 | |
117 | /** |
118 | * <!-- begin-user-doc --> |
119 | * <!-- end-user-doc --> |
120 | * @generated |
121 | */ |
122 | @Override |
123 | protected EStructuralFeature getChildFeature(Object object, Object child) { |
124 | // Check the type of the specified child object and return the proper feature to use for |
125 | // adding (see {@link AddCommand}) it as a child. |
126 | |
127 | return super.getChildFeature(object, child); |
128 | } |
129 | |
130 | /** |
131 | * This returns RelationDomain.gif. |
132 | * <!-- begin-user-doc --> |
133 | * <!-- end-user-doc --> |
134 | * @generated |
135 | */ |
136 | @Override |
137 | public Object getImage(Object object) { |
138 | return overlayImage(object, getResourceLocator().getImage("full/obj16/RelationDomain")); |
139 | } |
140 | |
141 | /** |
142 | * This returns the label text for the adapted class. |
143 | * <!-- begin-user-doc --> |
144 | * <!-- end-user-doc --> |
145 | * @generated |
146 | */ |
147 | @Override |
148 | public String getText(Object object) { |
149 | String label = ((RelationDomain)object).getName(); |
150 | return label == null || label.length() == 0 ? |
151 | getString("_UI_RelationDomain_type") : |
152 | getString("_UI_RelationDomain_type") + " " + label; |
153 | } |
154 | |
155 | /** |
156 | * This handles model notifications by calling {@link #updateChildren} to update any cached |
157 | * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. |
158 | * <!-- begin-user-doc --> |
159 | * <!-- end-user-doc --> |
160 | * @generated |
161 | */ |
162 | @Override |
163 | public void notifyChanged(Notification notification) { |
164 | updateChildren(notification); |
165 | |
166 | switch (notification.getFeatureID(RelationDomain.class)) { |
167 | case QVTRelationPackage.RELATION_DOMAIN__DEFAULT_ASSIGNMENT: |
168 | case QVTRelationPackage.RELATION_DOMAIN__PATTERN: |
169 | fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); |
170 | return; |
171 | } |
172 | super.notifyChanged(notification); |
173 | } |
174 | |
175 | /** |
176 | * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children |
177 | * that can be created under this object. |
178 | * <!-- begin-user-doc --> |
179 | * <!-- end-user-doc --> |
180 | * @generated |
181 | */ |
182 | @Override |
183 | protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
184 | super.collectNewChildDescriptors(newChildDescriptors, object); |
185 | |
186 | newChildDescriptors.add |
187 | (createChildParameter |
188 | (QVTRelationPackage.Literals.RELATION_DOMAIN__DEFAULT_ASSIGNMENT, |
189 | QVTRelationFactory.eINSTANCE.createRelationDomainAssignment())); |
190 | |
191 | newChildDescriptors.add |
192 | (createChildParameter |
193 | (QVTRelationPackage.Literals.RELATION_DOMAIN__PATTERN, |
194 | QVTRelationFactory.eINSTANCE.createDomainPattern())); |
195 | } |
196 | |
197 | /** |
198 | * Return the resource locator for this item provider's resources. |
199 | * <!-- begin-user-doc --> |
200 | * <!-- end-user-doc --> |
201 | * @generated |
202 | */ |
203 | @Override |
204 | public ResourceLocator getResourceLocator() { |
205 | return QvtmodelsEditPlugin.INSTANCE; |
206 | } |
207 | |
208 | } |