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