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